9 Replies Latest reply on Jan 23, 2008 5:56 PM by Srinivasan N. Raguraman

    problem with multiple seam component jars in a WAR

    Alex Sun Newbie

      i want to divide my web application into some modules, so i have some seam component jar each with Entity classes, my problem is that Entity in module jar can not be loaded or mapped by JPA, why?

      my WAR looks like :
      ---------------------------------------------

      my-application.war/
       META-INF/
       MANIFEST.MF
       WEB-INF/
       web.xml
       components.xml
       faces-config.xml
       pages.xml
       lib/
       jboss-seam.jar
       jboss-seam-ui.jar
       jboss-el.jar
       jsf-facelets.jar
       jsf-api.jar
       jsf-impl.jar
       ...
       classes/
       persistence.xml
      
       my-module1.jar/
       META-INF/
       MANIFEST.MF
       components.xml(blank)
       org/
       jboss/
       module1/
       User.class
       Login.class
       LoginBean.class
       Register.class
       RegisterBean.class
       seam.properties
       ...
       my-module2.jar/
       META-INF/
       MANIFEST.MF
       components.xml(blank)
       org/
       jboss/
       module2/
       Entity2.class
       seam.properties
       ...
       login.jsp
       register.jsp
       ...
      


        • 1. Re: problem with multiple seam component jars in a WAR
          Alex Sun Newbie

          my WAR looks like :
          ---------------------------------------------

          my-application.war/
           META-INF/
           MANIFEST.MF
           WEB-INF/
           web.xml
           components.xml
           faces-config.xml
           pages.xml
           lib/
           jboss-seam.jar
           jboss-seam-ui.jar
           jboss-el.jar
           jsf-facelets.jar
           jsf-api.jar
           jsf-impl.jar
           ...
           classes/
           META-INF/
           persistence.xml
          
           my-module1.jar/
           META-INF/
           MANIFEST.MF
           components.xml(blank)
           org/
           jboss/
           module1/
           User.class
           Login.class
           LoginBean.class
           Register.class
           RegisterBean.class
           seam.properties
           ...
           my-module2.jar/
           META-INF/
           MANIFEST.MF
           components.xml(blank)
           org/
           jboss/
           module2/
           Entity2.class
           seam.properties
           ...
           login.jsp
           register.jsp
           ...
          


          • 2. Re: problem with multiple seam component jars in a WAR
            Alex Sun Newbie

            my WAR looks like :
            ---------------------------------------------

            my-application.war/
             META-INF/
             MANIFEST.MF
             WEB-INF/
             web.xml
             components.xml
             faces-config.xml
             pages.xml
             lib/
             jboss-seam.jar
             jboss-seam-ui.jar
             jboss-el.jar
             jsf-facelets.jar
             jsf-api.jar
             jsf-impl.jar
             my-module1.jar/
             META-INF/
             MANIFEST.MF
             components.xml(blank)
             org/
             jboss/
             module1/
             User.class
             Login.class
             LoginBean.class
             Register.class
             RegisterBean.class
             seam.properties
             ...
             my-module2.jar/
             META-INF/
             MANIFEST.MF
             components.xml(blank)
             org/
             jboss/
             module2/
             Entity2.class
             seam.properties
             ...
             ...
             classes/
             META-INF/
             persistence.xml
             login.jsp
             register.jsp
             ...
            


            • 3. Re: problem with multiple seam component jars in a WAR
              Nicklas Karlsson Master

              Well, I'm no expert but I'm guessing that the same classloader that picks up persistence.xml need to see all the entities that should be used by that persistence context.

              • 4. Re: problem with multiple seam component jars in a WAR
                Alex Sun Newbie

                then, any idea about solving my problem?

                • 5. Re: problem with multiple seam component jars in a WAR
                  Techie Exchange Newbie

                  Hi,
                  If you want to load your Entities (with or without Seam component) from a seperate JAR then you should register those entities in your persistence.xml file like this:


                   <persistence-unit name="4cWebDatabase" transaction-type="RESOURCE_LOCAL">
                   <provider>org.hibernate.ejb.HibernatePersistence</provider>
                   <class>com.fpc.carconfig.frontoffice.entity.Allocation</class>
                   <class>com.fpc.carconfig.frontoffice.entity.LoginData</class>
                   <class>com.fpc.carconfig.frontoffice.entity.EndUser</class>
                   <class>com.fpc.carconfig.frontoffice.entity.TestClass</class>
                   <class>com.fpc.carconfig.frontoffice.entity.UserData</class>
                   <class>com.fpc.carconfig.frontoffice.entity.Offer</class>
                   <properties>
                   <property name="hibernate.hbm2ddl.auto" value="update"/>
                   <property name="hibernate.show_sql" value="true"/>
                   <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
                   <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
                  
                  
                   </properties>
                   </persistence-unit>
                  


                  Hope this helps.

                  http://techieexchange.wordpress.com

                  • 6. Re: problem with multiple seam component jars in a WAR
                    Alex Sun Newbie

                    i want to use <jar-file> config element with a relative path, instead of the element, how to config a <jar-file> in a relative path?

                    Thanks!

                    • 7. Re: problem with multiple seam component jars in a WAR
                      Srinivasan N. Raguraman Newbie

                      try this...

                      <jar-file>file:../lib/myapp1.jar</jar-file>

                      i.e. file:<relative-path> in the entry for jar file.

                      or something like file:/WEB-INF/lib/myapp.jar

                      • 8. Re: problem with multiple seam component jars in a WAR
                        Alex Sun Newbie

                         

                        "srini.ragu" wrote:
                        try this...

                        <jar-file>file:../lib/myapp1.jar</jar-file>

                        i.e. file:<relative-path> in the entry for jar file.

                        or something like file:/WEB-INF/lib/myapp.jar


                        i have all tries, only absolute path works!

                        • 9. Re: problem with multiple seam component jars in a WAR
                          Srinivasan N. Raguraman Newbie

                          in case you want relative path

                          try this..
                          <jar-file>file:my-application.war!/WEB-INF/lib/myapp1.jar</jar-file>

                          otherwise the best/cleaner option is to bundle your application as ear, with the entity jars directly inside the ear

                          myapp.ear
                          ---entity.jar
                          ---mywebapp.war
                          ------WEB-INF
                          ---------lib

                          on that case you will just need to specify as <jar-file>entity.jar<jar-file> in the persistence.xml

                          or just bundle your persistence.xml inside the entity.jar/META-INF

                          post this question in hibernate forum, you could get better answers.