5

I have a project developed under Eclipse with JBoss tools installed. When I deploy the application to the Jboss server, some helper jar files which are made available to the project through Maven are not copied inside the WEB-INF/lib folder. Hence, I get a ClassNotFound exception at runtime.

Is there any approach to convince Eclipse (or Maven) to copy the jars into the lib folder at deployment?

EDIT: the pom.xml looks like:

<project xmlns="http://maven.apache.org/POM/4.0.0" 
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
                                   http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>com.whatever.simulators</groupId>
<artifactId>eebuildingsim</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>eebuildingsim Maven Webapp</name>
<url>http://maven.apache.org</url>

<dependencies>

    <!-- begin JBoss -->

    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-jaxrs</artifactId>
        <version>2.3.2.FINAL</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>jaxrs-api</artifactId>
        <version>2.3.0.GA</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.1.2</version>
        <scope>provided</scope>
    </dependency>

    <!-- end JBoss -->

    <dependency>
        <groupId>ro.mysite</groupId>
        <artifactId>petrinetexec</artifactId>
        <version>0.1.3.81</version>
    </dependency>

    <dependency>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.4.3</version>
    </dependency>

    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.16</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.6.6</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.whatever.myAuxiliaryStuff</groupId>
        <artifactId>myAuxiliaryStuff </artifactId>
        <version>0.1.0.1305</version>
    </dependency>
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.2.0-m09</version>
    </dependency>
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-impl</artifactId>
        <version>2.2.0-m09</version>
    </dependency>
</dependencies>

<build>
    <finalName>eebuildingsim</finalName>
</build>

The artifact myAuxiliaryStuff should be deployed under WEB-INF/lib, under the jboss deployment server.

Using:

  • Eclipse: Juno Service Release 1
  • Jboss: 7.1.1. final
  • m2e 1.3.1.20130219-1424
  • eclipse web tools platform 3.4.2.v2013

Later edit: the error reported in jboss' log file looks like:

 12:31:38,507 INFO  [org.jboss.weld.deployer] (MSC service thread 1-5)
 JBAS016002: Processing weld deployment mywar.war 12:31:38,522 ERROR
 [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC00001: Failed
 to start service jboss.deployment.unit."mywar.war".POST_MODULE:
 org.jboss.msc.service.StartException in service
 jboss.deployment.unit."mywar.war".POST_MODULE: Failed to process phase
 POST_MODULE of deployment "mywar.war"  at
 org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119)
 [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]  at
 org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
 [jboss-msc-1.0.2.GA.jar:1.0.2.GA]  at
 org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
 [jboss-msc-1.0.2.GA.jar:1.0.2.GA]  at
 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
 [rt.jar:1.7.0_05]  at
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
 [rt.jar:1.7.0_05]  at java.lang.Thread.run(Thread.java:722)
 [rt.jar:1.7.0_05] Caused by: java.lang.NoSuchFieldError: FLOW  at
 com.sun.faces.flow.FlowDiscoveryCDIExtension.<clinit>(FlowDiscoveryCDIExtension.java:90)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
 Method) [rt.jar:1.7.0_05]  at
 sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
 [rt.jar:1.7.0_05]  at
 sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 [rt.jar:1.7.0_05]  at
 java.lang.reflect.Constructor.newInstance(Constructor.java:525)
 [rt.jar:1.7.0_05]  at
 org.jboss.as.weld.deployment.processors.WeldPortableExtensionProcessor.loadExtension(WeldPortableExtensionProcessor.java:117)
    at
 org.jboss.as.weld.deployment.processors.WeldPortableExtensionProcessor.loadAttachments(WeldPortableExtensionProcessor.java:100)
    at
 org.jboss.as.weld.deployment.processors.WeldPortableExtensionProcessor.deploy(WeldPortableExtensionProcessor.java:86)
    at
 org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113)
 [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]  ... 5 more

 12:31:38,522 INFO  [org.jboss.as.server] (DeploymentScanner-threads -
 2) JBAS015870: Deploy of deployment "mywar.war" was rolled back with
 failure message {"JBAS014671: Failed services" =>
 {"jboss.deployment.unit.\"mywar.war\".POST_MODULE" =>
 "org.jboss.msc.service.StartException in service
 jboss.deployment.unit.\"mywar.war\".POST_MODULE: Failed to process
 phase POST_MODULE of deployment \"mywar.war\""}} 12:31:38,647 INFO 
 [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015877:
 Stopped deployment mywar.war in 115ms 12:31:38,647 INFO 
 [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774:
 Service status report JBAS014775:    New missing/unsatisfied
 dependencies:
       service jboss.naming.context.java.module.mywar.mywar (missing) dependents: [service
 jboss.naming.context.java.module.mywar.mywar.ValidatorFactory, service
 jboss.naming.context.java.module.mywar.mywar.Validator]  JBAS014777:  
 Services which failed to start:      service
 jboss.deployment.unit."mywar.war".POST_MODULE:
 org.jboss.msc.service.StartException in service
 jboss.deployment.unit."mywar.war".POST_MODULE: Failed to process phase
 POST_MODULE of deployment "mywar.war"

 12:31:38,647 ERROR [org.jboss.as.server.deployment.scanner]
 (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation
 failed and was rolled back. Steps that failed:" => {"Operation step-2"
 => {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"mywar.war\".POST_MODULE" =>
 "org.jboss.msc.service.StartException in service
 jboss.deployment.unit.\"mywar.war\".POST_MODULE: Failed to process
 phase POST_MODULE of deployment \"mywar.war\""}}}}
Sam R.
  • 16,027
  • 12
  • 69
  • 122
lmsasu
  • 7,459
  • 18
  • 79
  • 113
  • "some helper jar files which are made available to the project through Maven" which one ? and how are those dependencies defined in the pom.xml? Post your pom.xml and the error trace if you need help. – ben75 Mar 25 '13 at 15:50
  • How do you deploy the application to the Jboss server in Eclipse? via Maven build (which requires m2e Eclipse plugin) or plain Eclipse Run As? – yorkw Apr 05 '13 at 02:26
  • @yorkow - Run as from Eclipse. – lmsasu Apr 05 '13 at 20:42
  • In your project, go to `Properties -> Java Build Path -> Order and Export` and try ticking `Maven Dependencies` and see if this helps. – yorkw Apr 07 '13 at 11:28
  • @yorkw: nope, sorry... I get the same error as in my comment for Attila's answer. – lmsasu Apr 08 '13 at 09:19
  • added jboss log seems to indicate some java server faces (configuration?) issue with latest milestone. It is not really related to anymore to deploying a web app with dependencies (=this question), so apparently you got that one fixed with `mvn package` or with the answer provided by @yorkw. – eis Apr 09 '13 at 09:58
  • Would you please set the dependency scope to `provided` for both `jsf-api` and `jsf-impl` and report back? Add this `provided` under _version_. – Sam R. Apr 09 '13 at 10:14

5 Answers5

7

Eclipse and the plugins are a bit finicky. This is what I've done to get it to work.

Project -> Properties -> Deployment Assembly
Add...
Java Build Path Entries (Next >)
Maven Dependencies (Finish)

The Deploy Properties panel should now include an entry for Source: Maven Dependecies -> Deploy Path: WEB_INF/lib

Old Pro
  • 24,624
  • 7
  • 58
  • 106
  • Thanks for reply. The same error occur as for other suggested approaches, see "Later edit" in my question. – lmsasu Apr 09 '13 at 09:42
  • 1
    After applying Sam Red's approach, your solution worked like a charm. I decided to give him the bounty. I hope you don't mind. Thanks for contributing to the solution. – lmsasu Apr 09 '13 at 12:55
  • @lmsasu Honestly I do mind that you didn't give me the bonus. The question you asked and offered a bounty for was "Is there any approach to convince Eclipse (or Maven) to copy the jars into the lib folder at deployment?" and I completely nailed that answer (after spending about half an hour digging up and reconstituting an old project where I had solved this problem). Then it turned out that you had problems in your Maven configuration so solving the bounty problem wasn't enough to completely fix your project, but that's a different problem. It's only brownie points, but I do feel gypped. – Old Pro Apr 11 '13 at 14:26
7

This is suspicious:

java.lang.NoSuchFieldError: FLOW

Which is related to JSF, if I'm not mistaken. I've got a few suggestions but I'm not an expert in any aspect.

First try to add provided dependency scope for jsf-api and jsf-impl like this (since the JBoss has them):

<dependency>
    <groupId>com.sun.faces</groupId>
    <artifactId>jsf-api</artifactId>
    <version>2.2.0-m09</version>
    <scope>provided</scope>   // <----- do it for both
</dependency>

AFAIK, JBoss 7.1.1 already has the JSF 2.1.7. So, if you really need the JSF 2.2 you should update the JSF module in JBoss. Here is how to Migration to JSF 2.2.

Another option is to bundle the JSF in to your WAR and inform JBoss to exclude the container version (the one that is shipped with JBoss) of it:

in web.xml add:

<context-param>
      <param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
      <param-value>true</param-value>
</context-param>

and in jboss-deployment-structure.xml exclude the JBoss's implementation:

<jboss-deployment-structure>
    <deployment>

        <exclusions>
            <module name="javax.faces.api" />
        </exclusions>
             .
             .
             .
Sam R.
  • 16,027
  • 12
  • 69
  • 122
  • Have you tried it with the scope set to `provided`? What did you get? I think you need the dependency somehow but you may remove it and test to see what happens. – Sam R. Apr 09 '13 at 12:28
  • Glad to hear that. I had guessed that it was compatibility issue of JSF modules in your project and in JBoss. – Sam R. Apr 09 '13 at 12:34
  • Silly me, I have some useless jsf dependencies added to the pom file, but I do not need jsf for now. It is working now, by followinf "Old Pro"'s solution. – lmsasu Apr 09 '13 at 12:37
  • But anyway if you wanna keep those dependencies, you should update the JBoss JSF modules or tell JBoss to exclude it's own module and uses your project bundled JSF. I will edit my answer to include that. – Sam R. Apr 09 '13 at 12:45
  • Sure. I think it's fair to give you the bounty. Normally, it should be shared between you and "Old Pro", but his/her solution only did not work. Old Pro, I how you don't mind on this. – lmsasu Apr 09 '13 at 12:53
  • @SamRad I get some errors when I add the jboss-deployment-structure.xml file. I need to do something? – John Alexander Betts Dec 16 '14 at 15:21
  • @SamRad Este es el error que me sale: MSC00001: Failed to start service jboss.deployment.unit."wsait.war".POST_MODULE ... Caused by: java.lang.NoClassDefFoundError: javax/faces/validator/ValidatorException ... Caused by: java.lang.ClassNotFoundException: javax.faces.validator.ValidatorException from [Module "deployment.wsait.war:main" from Service Module Loader] ... 13:00:00,717 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:"=>{"Operation step-2"=>{"JBAS014671: Failed services"... – John Alexander Betts Dec 16 '14 at 17:59
  • @JohnB, I'm not sure what would cause that, but post your problem as a new question with all of your error logs and I'm pretty sure you'll get an answer soon. – Sam R. Dec 16 '14 at 18:09
  • Ok @SamRad, thanks I have posted a new question with the full stack trace http://stackoverflow.com/questions/27511430/problems-migrating-jsf-2-1-to-jsf-2-2 – John Alexander Betts Dec 16 '14 at 18:28
2

Based on your description, you only have Eclipse and JBoss Tools in use and dependencies stored in Maven pom files. For Eclipse to become aware of those dependencies, you need to have eclipse-maven integration. M2e is the common choice for it.

So you would need these installed:

eis
  • 51,991
  • 13
  • 150
  • 199
  • @lmsasu please add that information to question also, including which versions you have. we cannot know if you don't tell. Also, version information about JBoss and Eclipse would be nice. – eis Apr 08 '13 at 11:48
  • Eclipse: Juno Service Release 1, Jboss: 7.1.1. final, m2e 1.3.1.20130219-1424, eclipse web tools platform 3.4.2.v2013.... – lmsasu Apr 09 '13 at 09:24
1

Go to the directory where your pom.xml resides and execute following command.

mvn package

This command should create a war file for you to deploy to your application server. This file is a zip file, look to its contents and see if your myAuxiliaryStuff.jar is in web-inf/lib. If it is, your problem lies with eclipse integration with maven.

Jan Petzold
  • 1,561
  • 1
  • 15
  • 24
Atilla Ozgur
  • 14,339
  • 3
  • 49
  • 69
  • Thanks for reply. After issuing this command, the war file indeed contains all the needed jar files. However, when I deploy it with the JBoss management console (web page), I get some errors: [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.deployment.unit."mywar.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."mywar.war".POST_MODULE: Failed to process phase POST_MODULE of deployment "mywar.war" – lmsasu Apr 08 '13 at 08:57
  • is there any other exception in this log? – Atilla Ozgur Apr 08 '13 at 21:06
0

You seem to have everything installed. I had this problem too. Just needed to right click on the project and choose.

"Mark as Deployable"

Stoffe
  • 81
  • 1
  • 2