2 Replies Latest reply on Jul 29, 2008 9:38 AM by Hung Truong

    OpenJPA and JBoss

    Hung Truong Newbie

      Hi there,
      Has anyone used OpenJPA with JBoss?
      I've run into a problem where I have an application running in WAS utilizing OpenJPA and porting it over to JBoss. However, when deployed in JBoss, after removing a slew of errors, it seems that one of my EJBs is stuck.

      I think that because i see it created in the server.log, but never started. It contains @PersistenceContext and i can see in the server.log that it states that the bean is dependent on the persistence unit. Which I'm gathering that the persistence unit needs to appear in JNDI or somewhere before JBoss will complete the startup.

      Can anyone help :) ??

      I have all the jars for openjpa in the jboss/server/all/lib directory. I did try to move them into my application directory, it was no help.

      Any help would be greatly appreciated.

      H

        • 1. Re: OpenJPA and JBoss
          jaikiran pai Master

          Please post the entire exception stacktrace, the logs that you see on the console and also the version of JBoss and Java you are using.

          • 2. Re: OpenJPA and JBoss
            Hung Truong Newbie

            Hi there.

            The strange thing is that I don't really have exceptions.

            I'm using JBoss 4.2.2, OpenJPA 1.1.0, and Java 1.5.

            In two beans, I am injecting the OpenJPA context via the @PersistenceContext(unitName="EventData")

            But I never see these two beans deploy completely, as it says it is waiting for the persistence unit "EventData" to start.

            My persistence.xml
            <?xml version="1.0" encoding="UTF-8"?>
            <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
            <persistence-unit name="EventData" transaction-type="JTA">
            org.apache.openjpa.persistence.PersistenceProviderImpl
            <jta-data-source>java:jdbc/ds</jta-data-source>
            I have classes here



            </persistence-unit>



            I get the following in the JBoss server log:
            2008-07-29 00:32:07,373 DEBUG [org.jboss.ejb3.Ejb3Module] Starting jboss.j2ee:service=EJB3,module=app_ejb-1.0.0.jar
            2008-07-29 00:32:07,394 DEBUG [org.jboss.injection.PersistenceUnitHandler] ******* could not find PU dependency so adding a default: persistence.units:unitName=EventData
            2008-07-29 00:32:07,402 DEBUG [org.jboss.ejb3.EJBContainer] Initialising interceptors for DataAccessBean...
            2008-07-29 00:32:07,402 DEBUG [org.jboss.ejb3.EJBContainer] Default interceptors: null
            2008-07-29 00:32:07,402 DEBUG [org.jboss.ejb3.EJBContainer] Class interceptors: []
            2008-07-29 00:32:07,403 DEBUG [org.jboss.ejb3.EJBContainer] All applicable interceptor classes: []

            ...
            2008-07-29 00:32:07,442 INFO [org.jboss.ejb3.JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=App.ear,jar=app_ejb-1.0.0.jar,name=DataAccessBean,service=EJB3 with dependencies:
            2008-07-29 00:32:07,442 INFO [org.jboss.ejb3.JmxKernelAbstraction] persistence.units:unitName=EventData
            2008-07-29 00:32:07,443 DEBUG [org.jboss.system.ServiceController] Creating service jboss.j2ee:ear=App.ear,jar=app_ejb-1.0.0.jar,name=DataAccessBean,service=EJB3
            2008-07-29 00:32:07,443 DEBUG [org.jboss.system.ServiceController] adding depenApp in ServiceController.register: [persistence.units:unitName=EventData]
            ...
            2008-07-29 00:32:07,443 DEBUG [org.jboss.system.ServiceController] waiting in create of jboss.j2ee:ear=App.ear,jar=app_ejb-1.0.0.jar,name=DataAccessBean,service=EJB3 waiting on persistence.units:unitName=EventData
            2008-07-29 00:32:07,443 DEBUG [org.jboss.system.ServiceController] starting service jboss.j2ee:ear=App.ear,jar=app_ejb-1.0.0.jar,name=DataAccessBean,service=EJB3



            It never hits the
            2008-07-29 00:32:07,450 INFO [org.jboss.ejb3.EJBContainer] STARTED EJB:

            Like all my other session beans do.


            Does that mean that the bean is still waiting for the persistence unit? These are the only two that don't get deployed completely and available in JNDI and the only ones that use the persistence stuff.

            Sometimes...and not always, i will get trace logs from OpenJPA:
            70 EventData INFO [pool-13-thread-1] openjpa.Runtime - Starting OpenJPA 1.1.0
            71 EventData TRACE [pool-13-thread-1] openjpa.Runtime - Properties: openjpa.EntityManagerFactory: default
            99 EventData TRACE [pool-13-thread-1] openjpa.Runtime - No cache marshaller found for id org.apache.openjpa.conf.MetaDataCacheMaintenance.
            195 EventData TRACE [pool-13-thread-1] openjpa.MetaData - Using metadata factory "org.apache.openjpa.persistence.jdbc.PersistenceMappingFactory@3a3b6b".
            206 EventData TRACE [pool-13-thread-1] openjpa.jdbc.JDBC - OpenJPA will now connect to the database to attempt to determine what type of database dictionary to use. You may prevent this connection in the future by setting your openjpa.jdbc.DBDictionary configuration property to the appropriate value for your database (see the documentation for available values).

            Not that I don't always get the openjpa.log, I don't know why though...it is rather inconsistent.

            Thanks for any help.
            H