| Author |
EJB3 persistence unit setup in JBoss
|
Chad Foor
Greenhorn
Joined: Jul 03, 2007
Posts: 23
|
|
I have a situation where I've got the following: 1) JBoss 4.2.1 as the app server. 2) Development of an n-tier J2EE app using Netbeans 5.5.1 3) The back-end stuff: A Sybase-15 database my company had some dba gurus set up / populate with data. Ok, that being said. I've managed to create a JSF standalone app that calls simple JDBC to the database just to test connectivity / proof of concept. I'm now going through an effort to separate out the database logic and create a proper J2EE solution. (all this in EJB3) The steps I've taken so far in this effort : 1) Netbeans has a very nice tool that allows me to map all the database tables / relationships to their java object counterparts. (Took all the business objects and put them inside their own business object package.) 2) Created a simple set of DAO classes that references a combination of business objects created from item #1. 3) In the setup, told Netbeans that I'm having Hibernate to handle the persistence within JBoss. 4) Created a set of test EJB remote interfaces / beans to talk to the DAOs and implement the business logic. Here's where I'm starting to get a little lost. Netbeans created a jboss.xml file within its configuration files. Yet, that file has no content associated with it. (Looking at the literature, Netbeans says if you're going to use JBoss / WebLogic you got to provide this information. However, I'm not sure what goes in this file.) I'm not bundling the application as a full-fleged EAR file. (Basically, I want to take the EJB portion and hosting this on a separate JBoss 4.2.1 server. Then, writing a set of web applications to talk to that server via a JNDI lookup where it will be housed from a different server. Essentially, I want to take my JSF app and re-factor the JDBC calls to deal with the EJBs directly.) At this point, I'm not entirely sure whether this is an appropriate question for Netbeans 5.5.1 or JBoss. I havent put anything into JBoss.xml just yet. When I bundle the .jar file and deploy to a JBoss 4.2.1 server, JBoss complains about not being able to find the persistence unit. So, I'm a little stuck here. I'd appreciate any insights. Thank you, Chad
|
 |
Jaikiran Pai
Marshal
Joined: Jul 20, 2005
Posts: 8145
|
|
When I bundle the .jar file and deploy to a JBoss 4.2.1 server, JBoss complains about not being able to find the persistence unit. So, I'm a little stuck here.
Do you refer to EntityManager/PersistentContext in your jar? If yes, do you have a persistence.xml in the META-INF (case sensitive) folder of the ejb jar file? Also, post the exception stacktrace that you see.
|
[My Blog] [JavaRanch Journal]
|
 |
Chad Foor
Greenhorn
Joined: Jul 03, 2007
Posts: 23
|
|
Here's a list of the configuration files I have so far. ---persistence.xml----------- <?xml version="1.0" encoding="UTF-8"?> <persistence version="1.0" xmlns=...> <persistence-unit name="myDataTierPU" transaction-type="JTA"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>MyApp</jta-data-source> <properties> <property name="hibernate.hbm2ddl.auto" value="update"/> </properties> </persistence-unit> </persistence> -----jboss-ds.xml-------------- <?xml version="1.0" encoding="UTF-8"?> <datasources> <local-tx-datasource> <jndi-name>MyApp</jndi-name> <connection-url>jdbc:sybase:Tds:myserver.proj.org:7001/dummyDatabase </connection-url> <driver-class>com.sybase.jdbc3.jdbc.SybDriver</driver-class> <user-name>guestUser</user-name> <password>guest</password> <min-pool-size>5</min-pool-size> <max-pool-size>20</max-pool-size> <idle-timeout-minutes>5</idle-timeout-minutes> </local-tx-datasource> </datasources> ---------------------------- ---jboss.xml---------------- <?xml version="1.0"?> <jboss/> ---------------------------- I'll send a stack trace here shortly. This is what I have so far. Again, appreciate your help. Thanks, Chad [ December 03, 2007: Message edited by: Chad Foor ]
|
 |
Chad Foor
Greenhorn
Joined: Jul 03, 2007
Posts: 23
|
|
I had to sanitize this a bit, but here's the start of the error stack trace that I'm getting when I try to deploy the EJB to a jboss-4.2.1 server. ----------------------- 13:24:56, 266 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding, name=MyApp' to JNDI name 'java:MyApp' 13:24:45, 806 INFO [ConnecttionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding, name=JmsXA' to JNDI name 'java:JmsXA' ... 13:24:58, 318 INFO [PersistenceUnitDeployment] Starting persistence unit persistence.units:jar=MyAppDataTier.jar, unitName=MyAppDataTierPU 13:24:58, 609 WARN [ServiceController] Problem starting persistence unit persistence.units:jar=MyAppDataTier.jar, unitName=MyAppDataTierPU javax.naming.NameNotFoundException: MyApp not bound at org.jnp.server.NamingServer.getBinding(NamingServer.java:529) at org.jnp... at org.jboss.ejb3.entity.persistenceunitDeployment.start(PersistenceUnitDeployment.java:216) ... 13:24:59, 650 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3. stateless.StatelessContainer 13:24:59, 650 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=MyAppDataTier.jar, name=ChadEJBBean, service=EJB3 with dependencies: 13:24:59, 650 INFO [JmxkernelAbstraction] ----------------------------------- Anything helpful here ? Chad
|
 |
Jaikiran Pai
Marshal
Joined: Jul 20, 2005
Posts: 8145
|
|
By default, the datasources in JBoss are bound to the java: namespace. Change your persistence.xml as follows:
|
 |
 |
|
|
subject: EJB3 persistence unit setup in JBoss
|
|
|