9 Replies Latest reply on Sep 3, 2010 2:01 PM by cosmo

    How to add additional jars to the deployed war

    bossy

      Hello,


      I have a seam application which is deployed to JBoss as a war.
      I used JBoss Tools to generate the project and that added all the builders/launchers that do the job of building and deploying the application to JBoss AS.
      I need to add some additional jars, but they do not get deployed in the war file by the standard builders.
      One way out of this would be to create my own ant build.xml that will do the job of compiling, building and deploying.


      I was wondering if there's a way of adding these jars (or a user library for that matter) to the standard builder (I'm not sure which builder that is, to be honest), instead of creating a custom ant script.
      Thanks.

        • 1. Re: How to add additional jars to the deployed war

          How did you add those additional jars? Did you copy them in WEB-INF\lib?


          • 2. Re: How to add additional jars to the deployed war
            bossy

            In my eclipse project I have them included in my build path. But they don't get copied in WEB-INF/lib authomatically as the rest of the seam jars by the builders(or whatever process that deploys the war to JBoss). That's what my question is about - how to copy them authomatically when the war file is built and deployed to JBoss.

            • 3. Re: How to add additional jars to the deployed war

              You configure that at Project Properties -> Java EE Module Dependencies. In that place you will see a table with all your referenced .jars, if the checkbox for each .jar is checked, the .jar is copied to WEB-INF\lib

              • 4. Re: How to add additional jars to the deployed war
                asookazian

                build.xml:


                <target name="ear" description="Build the EAR">
                                <copy todir="${ear.dir}">
                                        <fileset dir="${basedir}/resources">
                                                <include name="*jpdl.xml" />
                                                <include name="*hibernate.cfg.xml" />
                                                <include name="jbpm.cfg.xml" />
                                        </fileset>
                                          <fileset dir="${lib.dir}">
                                                    <include name="jboss-seam.jar" />
                                          </fileset>
                                     <!-- refactored these libraries into deployed-jars-ear.list 
                                          <fileset dir="${basedir}">
                                                <include name="lib/jbpm*.jar" />
                                                <include name="lib/jboss-el.jar" />
                                                <include name="lib/drools-*.jar"/>
                                                <include name="lib/janino-*.jar"/>
                                                <include name="lib/antlr-*.jar"/>
                                                <include name="lib/mvel*.jar"/>
                                                  <include name="lib/richfaces-api*.jar" />
                                                  <include name="lib/jcifs*.jar" />
                                                  <include name="lib/v20070621-common.jar" />
                                                  <include name="lib/*-cadils.jar" />
                                        </fileset>
                                        -->
                                 </copy>
                                 <copy todir="${ear.dir}/lib">
                                        <fileset dir="${lib.dir}">
                                                <includesfile name="deployed-jars-ear.list" />
                                        </fileset>
                                </copy>
                                <copy todir="${ear.dir}/META-INF">
                                        <fileset dir="${basedir}/resources/META-INF">
                                                <include name="application.xml" />
                                                <include name="jboss-app.xml" />
                                        </fileset>
                                </copy>
                        </target>

                • 5. Re: How to add additional jars to the deployed war
                  bossy

                  Thanks Francisco,
                  That's exactly what I was after.

                  • 6. Re: How to add additional jars to the deployed war
                    peduardo
                    Hello, I'm try to copy my jar file to myproject.ear\lib, and I have in my build.xml

                    `<copy todir="${ear.dir}/lib">
                                <fileset dir="${lib.dir}">
                                    <includesfile name="deployed-jars-ear.list"/>
                                    <include name="myjar1.jar"/>
                                    <include name="myjar2.jar"/>
                                </fileset>
                    </copy>`

                    I don't know how to put my jars files into deployed-jars-ear.list.
                    All files are copied to myproject\lib , but myjars files not.

                    Can you help-me?

                    thanks.





                    • 7. Re: How to add additional jars to the deployed war
                      bossy

                      Hello,


                      this works for me:



                      <copy todir="${ear.dir}/lib">
                        <fileset dir="${lib.dir}">
                            <include name="*.jar"/>
                        </fileset>
                      </copy>



                      • 8. Re: How to add additional jars to the deployed war
                        ptbnl123

                        You configure that at Project Properties -> Java EE Module Dependencies.

                        I can't find Java EE Module Dependencies in my Eclipse Project Properties (Eclipse Galileo 3.5.2). I see Resource, Builders, CDI Settings, Hibernate Settings, Java Build Path, etc. but not Java EE Module Dependencies.


                        I tried changing my build.xml file from:


                        <copy todir="${ear.dir}/lib">
                           <fileset dir="${lib.dir}">
                              <includesfile name="deployed-jars-ear.list"/>
                              <exclude name="icefaces-ahs.jar" if="icefaces.present"/>
                           </fileset>
                        </copy>



                        to:


                        <copy todir="${ear.dir}/lib">
                          <fileset dir="${lib.dir}">
                              <include name="*.jar"/>
                          </fileset>
                        </copy>



                        The copying worked fine, but then I get a deployment error.


                        08:01:30,944 ERROR [AbstractKernelController] Error installing to Real: name=vfszip:/C:/Users/JT/Desktop/jboss-5.1.0.GA/server/MyProj/deploy/MyProj.ear/ state=PreReal mode=Manual requiredState=Real
                        org.jboss.deployers.spi.DeploymentException: Error deploying MyProj.ear: failed to initialize bean container
                                at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:196)
                                at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:99)
                                at org.jboss.deployers.vfs.spi.deployer.AbstractVFSRealDeployer.internalDeploy(AbstractVFSRealDeployer.java:45)
                                at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
                                at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
                                at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
                                at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
                                at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
                                at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
                                at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
                                at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
                                at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
                                at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
                                at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
                                at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
                                at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
                                at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)
                                at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
                                at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)
                                at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)
                                at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:361)
                                at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
                                at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
                                at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
                                at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
                                at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
                                at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
                                at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
                                at org.jboss.system.server.profileservice.repository.AbstractProfileService.activateProfile(AbstractProfileService.java:306)
                                at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:271)
                                at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)
                                at org.jboss.Main.boot(Main.java:221)
                                at org.jboss.Main$1.run(Main.java:556)
                                at java.lang.Thread.run(Thread.java:619)
                        Caused by: java.lang.RuntimeException: failed to initialize bean container
                                at org.jboss.ejb3.EJBContainer.<init>(EJBContainer.java:253)
                                at org.jboss.ejb3.session.SessionContainer.<init>(SessionContainer.java:119)
                                at org.jboss.ejb3.session.SessionSpecContainer.<init>(SessionSpecContainer.java:69)
                                at org.jboss.ejb3.stateless.StatelessContainer.<init>(StatelessContainer.java:112)
                                at org.jboss.ejb3.Ejb3AnnotationHandler.getStatelessContainer(Ejb3AnnotationHandler.java:310)
                                at org.jboss.ejb3.Ejb3AnnotationHandler.getContainers(Ejb3AnnotationHandler.java:203)
                                at org.jboss.ejb3.Ejb3Deployment.deployElement(Ejb3Deployment.java:718)
                                at org.jboss.ejb3.Ejb3Deployment.deployElement(Ejb3Deployment.java:669)
                                at org.jboss.ejb3.Ejb3Deployment.deployUrl(Ejb3Deployment.java:651)
                                at org.jboss.ejb3.Ejb3Deployment.deploy(Ejb3Deployment.java:614)
                                at org.jboss.ejb3.Ejb3Deployment.create(Ejb3Deployment.java:491)
                                at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:182)
                                ... 33 more
                        Caused by: java.lang.IllegalStateException: Null beannMetaData
                                at org.jboss.ejb3.interceptors.metadata.BeanInterceptorMetaDataBridge.setupMetaDataLists(BeanInterceptorMetaDataBridge.java:315)
                                at org.jboss.ejb3.interceptors.metadata.BeanInterceptorMetaDataBridge.initialise(BeanInterceptorMetaDataBridge.java:235)
                                at org.jboss.ejb3.interceptors.metadata.BeanInterceptorMetaDataBridge.<init>(BeanInterceptorMetaDataBridge.java:138)
                                at org.jboss.ejb3.interceptors.metadata.AdditiveBeanInterceptorMetaDataBridge.<init>(AdditiveBeanInterceptorMetaDataBridge.java:48)
                                at org.jboss.ejb3.aop.BeanContainer.initialize(BeanContainer.java:194)
                                at org.jboss.ejb3.EJBContainer.<init>(EJBContainer.java:249)
                                ... 44 more
                        Caused by: java.lang.NullPointerException
                                at org.jboss.ejb3.interceptors.metadata.BeanInterceptorMetaDataBridge.setupMetaDataLists(BeanInterceptorMetaDataBridge.java:268)
                                ... 49 more
                        08:01:30,989 ERROR [ProfileServiceBootstrap] Failed to load profile: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):
                        
                        DEPLOYMENTS IN ERROR:
                          Deployment "vfszip:/C:/Users/JT/Desktop/jboss-5.1.0.GA/server/MyProj/deploy/MyProj.ear/" is in error due to the following reason(s): java.lang.NullPointerException





                        When I switch back to the original build.xml, everything works fine again. Any help would be appreciated. Thanks.

                        • 9. Re: How to add additional jars to the deployed war
                          cosmo

                          Try editting deployed-jars-ear.list xor deployed-jars-war.list(textfiles) after you copy your jar(s) in ${lib.dir} (within your eclipse project).