1 Reply Latest reply on Mar 14, 2009 2:40 AM by jaikiran pai

    Cannot use persistence unit from different jar

    Gary Madden Newbie

      Hey

      I have a persistence unit defined in an ejb3 jar (gsw-0.0.1.jar) called gsw-db. I have this jar along with a war (gsw-0.0.1.war) in an ear (gsw-0.0.1.ear) and I am trying to deploy it on jboss AS (version 5.0.1GA).

      When I deploy the ear I see this message in the logs:
      Bound factory to JNDI name: persistence.unit:unitName=gsw-app-0.0.1.ear/gsw-data-0.0.1.jar#gsw-db

      Also, when I dump the initial context from my war, I see this:
      persistence.unit:unitName=gsw-app-0.0.1.ear (type org.jnp.interfaces.NamingContext)
      gsw-data-0.0.1.jar#gsw-db (type org.hibernate.impl.SessionFactoryImpl)

      If I try to intialize an EntityManager with @PersistenceContext(unitName="gsw-app-0.0.1.ear/gsw-data-0.0.1.jar#gsw-db") from a servlet in my WAR, I get an exception: java.lang.IllegalArgumentException: Can't find a deployment unit named gsw-app-0.0.1.ear

      I found this post (http://www.jboss.org/index.html?module=bb&op=viewtopic&t=146250) but this is an issue with JBoss 5.0.0.CR2. I'm hoping this issue has been fixed in 5.0.1GA. Has it?

      Any help or hints would be greatly appreciated!

      Thanks

        • 1. Re: Cannot use persistence unit from different jar
          jaikiran pai Master

           

          "tony_green" wrote:


          If I try to intialize an EntityManager with @PersistenceContext(unitName="gsw-app-0.0.1.ear/gsw-data-0.0.1.jar#gsw-db") from a servlet in my WAR, I get an exception: java.lang.IllegalArgumentException: Can't find a deployment unit named gsw-app-0.0.1.ear



          Try:

          @PersistenceContext(unitName="gsw-data-0.0.1.jar#gsw-db")


          I don't have my setup in front of me right now - so i can't say whether this is the right approach or whether this is going to work.