6 Replies Latest reply on Apr 13, 2012 5:50 PM by dgolovin

    target/project.war different from project.war that is Run On Server

    daxxy

      I have gone back and forth between manually building my project using a Run Configuration and simply deploying my app onto the server using Run As... -> Run On Server.  The latter is easier, you don't have to take that first step of building the war file manually and you don't have to mark the target/project.war as Deployable (for some reason the voice in my brain always says "Mark as Deplorable" , but I digress....)

       

      So today I needed to customize the packaging of my app to put persistence.xml into /META-INF rather than in /WEB-INF/classes/META-INF.  Building the war file manually using a Run Configuration produces different results than what I get in the my deployed app.  I assume that what gets deployed uses the pom to build the app, is that true?  What actually happens when you do a Run On Server?  Is it supposed to be different than what you do when you do a "mvn clean package"?   How can I get the result I want in the Run As->Run On Server version?

       

      Here are the two structures.  The first is take from my target subdirectory right after mvn clean package and the second is from the deployments directory, which I reached by right-clicking on the deployed app icon and selecting Explore from the context menu.  In the first (correct - manually generated) build,  persistence.xml is in the correct place. In the 2nd build, it appears twice, and this is messing up the deployment.

       

      d:\Development2\j2ee6\contacts-as7\target>jar -tf contacts-as7.war
      META-INF/
      META-INF/MANIFEST.MF
      icons/
      style/
      WEB-INF/
      WEB-INF/classes/
      WEB-INF/classes/gov/
      WEB-INF/classes/gov/ssa/
      WEB-INF/classes/gov/ssa/dne/
      WEB-INF/classes/gov/ssa/dne/nmst/
      WEB-INF/classes/gov/ssa/dne/nmst/action/
      WEB-INF/lib/
      contact.xhtml
      favicon.ico
      icons/add.png
      icons/check.png
      icons/delete.png
      icons/edit.png
      index.html
      index.xhtml
      META-INF/persistence.xml
      style/nmst.css
      test.xhtml
      WEB-INF/beans.xml
      WEB-INF/classes/gov/ssa/dne/nmst/action/ContactService.class
      WEB-INF/classes/gov/ssa/dne/nmst/action/ContactView.class
      WEB-INF/faces-config.xml
      WEB-INF/lib/commons-beanutils-1.8.0.jar
      WEB-INF/lib/commons-digester-2.0.jar
      WEB-INF/lib/commons-lang-2.6.jar
      WEB-INF/lib/commons-logging-1.1.1.jar
      WEB-INF/lib/contacts-model-as7-0.0.1-SNAPSHOT.jar
      WEB-INF/lib/cssparser-0.9.5.jar
      WEB-INF/lib/ehcache-1.6.0.jar
      WEB-INF/lib/guava-10.0.1.jar
      WEB-INF/lib/hibernate-validator-4.2.0.Final.jar
      WEB-INF/lib/javax.faces-2.1.5.jar
      WEB-INF/lib/joda-time-1.6.jar
      WEB-INF/lib/jsr305-1.3.9.jar
      WEB-INF/lib/jstl-api-1.2.jar
      WEB-INF/lib/picketlink-idm-api-1.5.0.Alpha02.jar
      WEB-INF/lib/picketlink-idm-common-1.5.0.Alpha02.jar
      WEB-INF/lib/picketlink-idm-spi-1.5.0.Alpha02.jar
      WEB-INF/lib/prettyfaces-core-3.3.2.jar
      WEB-INF/lib/richfaces-components-api-4.2.0.Final.jar
      WEB-INF/lib/richfaces-components-ui-4.2.0.Final.jar
      WEB-INF/lib/richfaces-core-api-4.2.0.Final.jar
      WEB-INF/lib/richfaces-core-impl-4.2.0.Final.jar
      WEB-INF/lib/sac-1.3.jar
      WEB-INF/lib/seam-faces-3.1.0.Final.jar
      WEB-INF/lib/seam-faces-api-3.1.0.Final.jar
      WEB-INF/lib/seam-international-3.1.0.Final.jar
      WEB-INF/lib/seam-international-api-3.1.0.Final.jar
      WEB-INF/lib/seam-persistence-api-3.1.0.Final.jar
      WEB-INF/lib/seam-security-api-3.1.0.Final.jar
      WEB-INF/lib/seam-transaction-api-3.1.0.Final.jar
      WEB-INF/lib/servlet-api-2.5.jar
      WEB-INF/lib/slf4j-api-1.6.1.jar
      WEB-INF/lib/solder-api-3.1.0.Final.jar
      WEB-INF/lib/solder-impl-3.1.0.Final.jar
      WEB-INF/lib/solder-logging-3.1.0.Final.jar
      WEB-INF/lib/validation-api-1.0.0.GA.jar
      WEB-INF/web.xml
      META-INF/maven/
      META-INF/maven/gov.ssa.dne.nmst/
      META-INF/maven/gov.ssa.dne.nmst/contacts-as7/
      META-INF/maven/gov.ssa.dne.nmst/contacts-as7/pom.xml
      META-INF/maven/gov.ssa.dne.nmst/contacts-as7/pom.properties

       

       

      d:\Development2\jboss-eap-6.0.0.Beta1\jboss-eap-6.0\standalone\deployments>jar -tf contacts-as7.jar
      contact.xhtml
      favicon.ico
      icons/
      icons/add.png
      icons/check.png
      icons/delete.png
      icons/edit.png
      index.html
      index.xhtml
      META-INF/
      META-INF/MANIFEST.MF
      META-INF/maven/
      META-INF/maven/gov.ssa.dne.nmst/
      META-INF/maven/gov.ssa.dne.nmst/
      META-INF/maven/gov.ssa.dne.nmst/pom.properties
      META-INF/maven/gov.ssa.dne.nmst/pom.xml
      META-INF/persistence.xml
      style/
      style/nmst.css
      test.xhtml
      WEB-INF/
      WEB-INF/beans.xml
      WEB-INF/classes/
      WEB-INF/classes/gov/
      WEB-INF/classes/gov/ssa/
      WEB-INF/classes/gov/ssa/dne/
      WEB-INF/classes/gov/ssa/dne/nmst/
      WEB-INF/classes/gov/ssa/dne/nmst/action/
      WEB-INF/classes/gov/ssa/dne/nmst/action/ContactService.class
      WEB-INF/classes/gov/ssa/dne/nmst/action/ContactView.class
      WEB-INF/classes/import.sql
      WEB-INF/classes/META-INF/
      WEB-INF/classes/META-INF/persistence.xml
      WEB-INF/faces-config.xml
      WEB-INF/lib/
      WEB-INF/lib/commons-beanutils-1.8.0.jar
      WEB-INF/lib/commons-digester-2.0.jar
      WEB-INF/lib/commons-lang-2.6.jar
      WEB-INF/lib/commons-logging-1.1.1.jar
      WEB-INF/lib/contacts-model-as7-0.0.1-SNAPSHOT.jar
      WEB-INF/lib/cssparser-0.9.5.jar
      WEB-INF/lib/ehcache-1.6.0.jar
      WEB-INF/lib/guava-10.0.1.jar
      WEB-INF/lib/hibernate-validator-4.2.0.Final.jar
      WEB-INF/lib/javax.faces-2.1.5.jar
      WEB-INF/lib/joda-time-1.6.jar
      WEB-INF/lib/jsr305-1.3.9.jar
      WEB-INF/lib/jstl-api-1.2.jar
      WEB-INF/lib/picketlink-idm-api-1.5.0.Alpha02.jar
      WEB-INF/lib/picketlink-idm-common-1.5.0.Alpha02.jar
      WEB-INF/lib/picketlink-idm-spi-1.5.0.Alpha02.jar
      WEB-INF/lib/prettyfaces-core-3.3.2.jar
      WEB-INF/lib/richfaces-components-api-4.2.0.Final.jar
      WEB-INF/lib/richfaces-components-ui-4.2.0.Final.jar
      WEB-INF/lib/richfaces-core-api-4.2.0.Final.jar
      WEB-INF/lib/richfaces-core-impl-4.2.0.Final.jar
      WEB-INF/lib/sac-1.3.jar
      WEB-INF/lib/seam-faces-3.1.0.Final.jar
      WEB-INF/lib/seam-faces-api-3.1.0.Final.jar
      WEB-INF/lib/seam-international-3.1.0.Final.jar
      WEB-INF/lib/seam-international-api-3.1.0.Final.jar
      WEB-INF/lib/seam-persistence-api-3.1.0.Final.jar
      WEB-INF/lib/seam-security-api-3.1.0.Final.jar
      WEB-INF/lib/seam-transaction-api-3.1.0.Final.jar
      WEB-INF/lib/servlet-api-2.5.jar
      WEB-INF/lib/slf4j-api-1.6.1.jar
      WEB-INF/lib/solder-api-3.1.0.Final.jar
      WEB-INF/lib/solder-impl-3.1.0.Final.jar
      WEB-INF/lib/solder-logging-3.1.0.Final.jar
      WEB-INF/lib/validation-api-1.0.0.GA.jar
      WEB-INF/web.xml

       

       

      This is the stack trace I get when the deployment bombs

       

      14:22:57,349 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015876: Starting deployment of "contacts-as7.war"
      14:22:58,502 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015893: Encountered invalid class name 'com.sun.faces.vendor.Tomcat6InjectionProvider:org.apache.catalina.util.DefaultAnnotationProcessor' for service type 'com.sun.faces.spi.injectionprovider'
      14:22:58,502 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015893: Encountered invalid class name 'com.sun.faces.vendor.Jetty6InjectionProvider:org.mortbay.jetty.plus.annotation.InjectionCollection' for service type 'com.sun.faces.spi.injectionprovider'
      14:22:58,593 INFO  [org.jboss.as.jpa] (MSC service thread 1-1) JBAS011401: Read persistence.xml for contactsDb
      14:22:58,593 INFO  [org.jboss.as.jpa] (MSC service thread 1-1) JBAS011401: Read persistence.xml for contactsDb
      14:22:58,593 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC000001: Failed to start service jboss.deployment.unit."contacts-as7.war".DEPENDENCIES: org.jboss.msc.service.StartException in service jboss.deployment.unit."contacts-as7.war".DEPENDENCIES: Failed to process phase DEPENDENCIES of deployment "contacts-as7.war"
      at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.0.Final-redhat-1.jar:7.1.0.Final-redhat-1]
      at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA-redhat-1.jar:1.0.2.GA-redhat-1]
      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA-redhat-1.jar:1.0.2.GA-redhat-1]
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_25]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_25]
      at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_25]
      Caused by: java.lang.IllegalArgumentException: JBAS011470: Persistence unitName was not specified and there are 2 persistence unit definitions in application deployment "contacts-as7.war".  Either change the application to have only one persistence unit definition or specify the unitName for each reference to a persistence unit.
      at org.jboss.as.jpa.container.PersistenceUnitSearch.resolvePersistenceUnitSupplier(PersistenceUnitSearch.java:69)
      at org.jboss.as.jpa.processor.JPAAnnotationParseProcessor.getPersistenceUnit(JPAAnnotationParseProcessor.java:284)
      at org.jboss.as.jpa.processor.JPAAnnotationParseProcessor.getBindingSource(JPAAnnotationParseProcessor.java:220)
      at org.jboss.as.jpa.processor.JPAAnnotationParseProcessor.processField(JPAAnnotationParseProcessor.java:151)
      at org.jboss.as.jpa.processor.JPAAnnotationParseProcessor.processPersistenceAnnotations(JPAAnnotationParseProcessor.java:118)
      at org.jboss.as.jpa.processor.JPAAnnotationParseProcessor.deploy(JPAAnnotationParseProcessor.java:90)
      at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.0.Final-redhat-1.jar:7.1.0.Final-redhat-1]
      ... 5 more

      14:22:58,633 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 1) JBAS015870: Deploy of deployment "contacts-as7.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"contacts-as7.war\".DEPENDENCIES" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"contacts-as7.war\".DEPENDENCIES: Failed to process phase DEPENDENCIES of deployment \"contacts-as7.war\""}}
      14:22:58,733 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015877: Stopped deployment contacts-as7.war in 95ms
      14:22:58,733 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 1) JBAS014774: Service status report
      JBAS014777:   Services which failed to start:      service jboss.deployment.unit."contacts-as7.war".DEPENDENCIES: org.jboss.msc.service.StartException in service jboss.deployment.unit."contacts-as7.war".DEPENDENCIES: Failed to process phase DEPENDENCIES of deployment "contacts-as7.war"

        • 1. Re: target/project.war different from project.war that is Run On Server
          daxxy

          oh boy, this is a big "DUH" for me!

           

          the 2nd persistence.xml was from my ejb jar (a dependency) -- I left it in there accidentally.  Once I removed it, Run As - > Run On Server worked beautifully.

           

          Maven must have been using an "installed" version of the ejb jar that did not have persistence.xml in it and that's why it looked "correct" to me.

           

          Somehow no matter how long I linger before I press teh "Submit" button when I write one of these up, the answer becomes obvious only AFTER I've pressed it!  Usually within 5 minutes of pressing it, too.

           

          Have a nice day.

          TDR

          • 2. Re: target/project.war different from project.war that is Run On Server
            rob.stryker

            > I assume that what gets deployed uses the pom to build the app, is that true?

             

            The toolset itself does not necessarily use pom.xml at all.  If you have m2e installed only, then it will not use pom.xml at all. It uses a file in {your.project}/.settings/org.eclipse.wst.common.component     which is an xml file driving the server deployment model.  It maps folders that should be included in the deployment among other things.

             

            m2e-wtp is another add-on which I assume you are using. This file tries to make the component.xml file match the behaviour of pom.xml as closely as possible.

            1 of 1 people found this helpful
            • 3. Re: target/project.war different from project.war that is Run On Server
              daxxy

              So, m2e and m2e-wtp are different. I've never been quite clear on that. 

               

              If you change your pom.xml you get an error that says the project is out of configuration or something like that and running Maven -> Update Project Configuration... updates that file?  If you have changed your dependencies and don't update that file, not only will the list of libraries entitled Maven Dependencies be out of date, but the project itself won't incorporate the correct libraries into the lib when you deploy it. Is that right?  And I assume any structural changes to that app you have made in the pom like <includes> and <excludes> won't make it into the deployed app unless you run Update Project Configuration...  as well.

               

              The bottom line is that running Maven -> Update Project Configuration... synchronizes the org.eclipse.wst.common.component to the pom.xml.  True?

               

              That takes some of the magic out of it ( that is a good thing)

              Thanks.

              TDR

              • 4. Re: target/project.war different from project.war that is Run On Server
                maxandersen

                m2e provides the basic Maven integration for Eclipse Java based projects.

                 

                m2e-wtp are add-ons to m2e which provides Maven integration for Eclipse Webtools (WTP) based projects.

                 

                And yes, you can view update project configuration as the step needed to force eclipse to read the pom.xml and update the eclipse project configuration.

                 

                In some cases you can have pom.xml content that cannot be fully represented in eclipse, or simply just haven't been implemented yet - we have done our best to ensure most common scenarios we know of is covered - if you find something that is not matching let us know

                1 of 1 people found this helpful
                • 5. Re: target/project.war different from project.war that is Run On Server
                  daxxy

                  This original problem is showing up again  -  though the details are different and I'm pretty sure this time it's not my mistake.

                   

                  The file starts in src/main/resources/META-INF/persistence.xml

                   

                  In the maven build, the persistence.xml is showing up in the right place, under META-INF.The eclipse build doesn't include the persistence.xml at all.

                   

                  To coax maven into including persistence.xml into the WAR I include this in the pom.xml

                   

                  <plugin>
                  <artifactId>maven-war-plugin</artifactId>
                  <version>2.1.1</version>
                  <configuration>
                    <!-- Java EE 6 doesn't require web.xml, Maven needs to catch up! -->
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <webResources>
                      <resource>
                        <directory>src/main/resources/META-INF</directory>
                        <!-- override the destination directory for this resource -->
                        <targetPath>META-INF</targetPath>
                        <includes>
                          <include>persistence.xml</include>
                        </includes>
                      </resource>
                    </webResources>
                  </configuration>
                  </plugin>

                   

                  and this

                   

                  <resources>
                    <resource>
                      <directory>src/resources/META-INF</directory>
                      <excludes>
                        <exclude>persistence.xml</exclude>
                      </excludes>
                    </resource>
                  </resources>

                   

                  mvn package puts it into contacts-as7.war/META-INF

                   

                  Run On Server doesn't put it anywhere and I get this error when I deploy

                   

                  Can't find a persistence unit named null in deployment "contacts-as7.war"

                   

                  • 6. Re: target/project.war different from project.war that is Run On Server
                    dgolovin

                    Have you tried to configure it in "Web Deployment Assembly" properties for the project?

                    WebDeploymentAssembly.png