-
1. Re: ClassCastException looking up EJB3.0 SLSB
gajos Mar 14, 2006 3:40 PM (in response to khooke)Hi,
I have the same problem, this is funny, but when I simply comment out://@PersistenceContext(unitName="someUnitName") //private EntityManager em;
jndi lookup works (i.e. myEARName/BeanName/local) :)
I don't understand it, it tried to learn EJB3 following trailblazer tutorial,
but I failed with this issue.
Has anyone the same experience ?
Best regards,
MichalG. -
2. Re: ClassCastException looking up EJB3.0 SLSB
khooke Mar 14, 2006 5:19 PM (in response to khooke)I worked out the issue, and it all depended on the correct config for the persistence.xml file.
Since the @PersistenceContext annotation introduces a dependency between my SLSB and the Persistence Context/Persistence Unit, if the persistence.xml file is incorrect, the SLSB would not deploy correctly and hence would not be bound in JNDI.
I found this same issue that you are seeing - remove the @PersistenceContext and then my bean would deploy (minus of course the dependency on the PersistenceContext.
In my case I had incorrectly packaged the persistence.xml file in the META-INF of the EAR instead of the JAR containing the bean. Once I'd worked that out, repackaged and redeployed, I did run into a string of other datasource issues (MySQL JDBC jar missing. wrong URL in datasource .xml file), but these were easy to fix.
If deploying and redeploying while the server was already running I noticed that some of the errors were not reporting. If I stopped and restarted the server when my ear was alreasdy deployed, I saw more informative dependency messages, which helped point me in the right direction:--- MBeans waiting for other MBeans --- ObjectName: jboss.j2ee:service=EJB3,ear=test1.ear,jar=test.jar,name=AddressBookBean State: NOTYETINSTALLED I Depend On: persistence.units:unitName=em --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM --- ObjectName: persistence.units:unitName=em State: NOTYETINSTALLED Depends On Me: jboss.j2ee:service=EJB3,ear=test1.ear,jar=test.jar,name=AddressBookBean
I also found that also the persistence.xml format had changed. With JBoss 4.0.4RC1, the syntax is like this:<persistence> <persistence-unit name="em"> <jta-data-source>java:/DefaultDS</jta-data-source> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/> <property name="hibernate.hbm2ddl.auto" value="create-drop"/> </properties> </persistence-unit> </persistence>
Hope that helps,
Kevin Hooke -
3. Re: ClassCastException looking up EJB3.0 SLSB
bill.burke Mar 14, 2006 5:39 PM (in response to khooke)I'm aware of the errors not showing and some of it has been fixed.