-
30. Re: WildFly 10.0 - NoClassDefFoundError on deploy for classes defined in pom
bmiddleb Jun 24, 2016 3:08 PM (in response to jamezp)That fixed the compile problem. Now I have this: java.lang.RuntimeException: java.lang.ClassNotFoundException: org.jboss.resteasy.spi.ResteasyProviderFactory
But, I only get that for the mvn clean install wildfly:deploy as a runtime excepting during the testing phase.
I am now able to deploy my app to WildFly 10 from Eclipse Neon. Yay!
The RWS deploys but I get a 405 Method Not Allowed on any POST method. Response:
HTTP method POST is not supported by this URL
Not being very familiar with RESTEasy, I'm guessing I have to do some more configuration work.
Here's the final pom.xml that worked for me in case someone else needs it:
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.meritagesystems.codecompliance.rws</groupId>
<artifactId>CodeComplianceServices</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>CodeComplianceServices</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- BEGIN Careful not to break this version dependency -->
<powermock.version>1.6.4</powermock.version>
<mockito.version>1.10.19</mockito.version>
<!-- END Careful not to break this version dependency -->
<jackson.version>2.7.4</jackson.version>
<hibernate.version>4.3.11.Final</hibernate.version>
<jboss.bom.version>1.0.0.Final</jboss.bom.version>
<wildfly.version>10.0.0.Final</wildfly.version>
<!-- other plug-in versions -->
<version.surefire.plugin>2.10</version.surefire.plugin>
<version.war.plugin>2.1.1</version.war.plugin>
<!-- maven-compiler-plugin -->
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<version.wildfly.maven.plugin>1.1.0.Alpha9</version.wildfly.maven.plugin>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>wildfly-javaee7-with-tools</artifactId>
<version>${wildfly.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.spec.javax.servlet</groupId>
<artifactId>jboss-servlet-api_3.1_spec</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- Import the Common Annotations API (JSR-250), we use provided scope
as the API is included in WildFly -->
<dependency>
<groupId>org.jboss.spec.javax.annotation</groupId>
<artifactId>jboss-annotations-api_1.2_spec</artifactId>
<scope>provided</scope>
</dependency>
<!-- Import the JAX-RS API, we use provided scope as the API is included
in WildFly -->
<dependency>
<groupId>org.jboss.spec.javax.ws.rs</groupId>
<artifactId>jboss-jaxrs-api_2.0_spec</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.2.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
<!-- Test Dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<!-- Maven will append the version to the finalName (which is the name
given to the generated WAR, and hence the context root) -->
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>${version.war.plugin}</version>
<configuration>
<!-- Java EE doesn't require web.xml, Maven needs to catch up! -->
<failOnMissingWebXml>false</failOnMissingWebXml>
<archive>
<manifestEntries>
<Dependencies>com.fasterxml.jackson.datatype.jackson-datatype-jsr310</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>
<!-- The WildFly plug-in deploys the WAR to a local WildFly container -->
<!-- To use, run: mvn package wildfly:deploy -->
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>${version.wildfly.maven.plugin}</version>
</plugin>
</plugins>
</build>
</project>
-
31. Re: WildFly 10.0 - NoClassDefFoundError on deploy for classes defined in pom
jamezp Jun 24, 2016 4:13 PM (in response to bmiddleb)Not too sure about the CNFE during testing. Maybe just something from the test environment isn't setup quite right.
As far as the 405 response make sure the endpoint your targeting is annotated with @javax.ws.rs.POST.
--
James R. Perkins
-
32. Re: WildFly 10.0 - NoClassDefFoundError on deploy for classes defined in pom
bmiddleb Jun 24, 2016 6:32 PM (in response to jamezp)The Status Code=405 failures are occurring on REST web service code that has been working in my Glassfish 4.0/Jersey configuration for nearly a year. I am reasonably sure it is annotated correctly.
I just re-started WildFly via Eclipse and now I'm getting these errors:
16:02:52,572 INFO [org.jboss.weld.Bootstrap] (Weld Thread Pool -- 1) WELD-000119: Not generating any bean definitions from com.meritagesystems.codecompliance.data.object.HibernateConfiguration because of underlying class loading error: Type org.hibernate.service.ServiceRegistry from [Module "deployment.CodeComplianceServices.war:main" from Service Module Loader] not found. If this is unexpected, enable DEBUG logging to see the full error.
16:02:52,579 INFO [org.jboss.weld.Bootstrap] (Weld Thread Pool -- 2) WELD-000119: Not generating any bean definitions from com.meritagesystems.codecompliance.businessmodel.CodeViolation because of underlying class loading error: Type org.apache.commons.lang3.builder.ToStringStyle from [Module "deployment.CodeComplianceServices.war:main" from Service Module Loader] not found. If this is unexpected, enable DEBUG logging to see the full error
When I look at $WILDFLY_HOME/standalone/deployments/CodeComplianceServices.war/WEB-INF the classes dir and beans.xml file are there but no lib directory.
I have also not been able to resolve the myriad java.lang.RuntimeException: java.lang.ClassNotFoundException: org.jboss.resteasy.spi.ResteasyProviderFactory errors that occur in the test phase of the mvn clean install wildfly:deploy execution.
-
33. Re: WildFly 10.0 - NoClassDefFoundError on deploy for classes defined in pom
bmiddleb Jun 24, 2016 7:16 PM (in response to bmiddleb)I can see an older version of org.apache.lang (not lang3) in the base modules directory. Do need to replace that module?
-
34. Re: WildFly 10.0 - NoClassDefFoundError on deploy for classes defined in pom
jamezp Jun 24, 2016 7:25 PM (in response to bmiddleb)Weird. How are you deploying the application? It looks like it's an exploded deployment which maybe JBoss Tools does. I'm not too familiar with how JBoss Tools deploys content. Using the standalone/deployments directory uses the deployment-scanner which by default scans every 5 seconds.
With regard to the CFNE it's tough to say. If it's in the test phase, then the wildfly-maven-plugin is likely not used at all, unless you explicitly defined an execution for it in that phase. Not know how your test environment is setup it's tough to say what it might be. Are you using Arquillian or something similar?
--
James R. Perkins
-
35. Re: WildFly 10.0 - NoClassDefFoundError on deploy for classes defined in pom
jamezp Jun 24, 2016 7:26 PM (in response to bmiddleb)No. You normally don't want to replace system modules. Those are generally required by server dependencies. I believe the org.apache.common.lang is required by CXF. You'll just want to include commons.lang3 in your deployment in the WEB-INF/lib directory.
--
James R. Perkins
-
36. Re: WildFly 10.0 - NoClassDefFoundError on deploy for classes defined in pom
bmiddleb Jun 24, 2016 7:59 PM (in response to jamezp)Here's what worked to get past the weld hibernate and lang3 issues...
1. modified <build> stanza of pom.xml like this:
<archive>
<manifestEntries>
<Dependencies>com.fasterxml.jackson.datatype.jackson-datatype-jsr310</Dependencies>
<Dependencies>org.hibernate</Dependencies>
<Dependencies>org.apache.commons.lang3.commons-lang3</Dependencies>
</manifestEntries>
</archive>
2. executed: module add --name=org.apache.commons.lang3.commons-lang3 --resources=C:\Users\b\.m2\repository\org\apache\commons\commons-lang3\3.4\commons-lang3-3.4.jar
3. created jboss-deployment-structure.xml in Deployed Resources/webapp/WEB-INF with this content:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<exclusions>
<module name="org.apache.commons.lang" />
</exclusions>
<dependencies>
<module name="org.apache.commons.lang3.commons-lang3" services="import" />
</dependencies>
</deployment>
</jboss-deployment-structure>
-
37. Re: WildFly 10.0 - NoClassDefFoundError on deploy for classes defined in pom
jamezp Jun 24, 2016 8:04 PM (in response to bmiddleb)That should work though I think the Dependencies configuration in the compiler plugin needs to look like:
<archive> <manifestEntries> <Dependencies>com.fasterxml.jackson.datatype.jackson-datatype-jsr310,org.hibernate,org.apache.commons.lang3.commons-lang3</Dependencies> </manifestEntries> </archive>
I'm not sure what would happen if you defined multiple entries lines of entries. Only one might be written or only one might be read. A comma delimited list should work though.
FWIW if you're using JPA the org.hibernate shouldn't be needed.
--
James R. Perkins
-
38. Re: WildFly 10.0 - NoClassDefFoundError on deploy for classes defined in pom
bmiddleb Jun 24, 2016 8:35 PM (in response to jamezp)You are right. I checked,my manifest.mf and it only listed the first one. Making the edit you suggested fixed it.
I'm still getting this error:
underlying class loading error: Type org.hibernate.service.ServiceRegistry (as well as for org.hibernate.criterion.Criterion)
I kind of understand now why commons-lang3 wasn't being loaded by the class loader. But I really don't get this one. Isn't this part of the build-in set of hibernate libs?
-
39. Re: WildFly 10.0 - NoClassDefFoundError on deploy for classes defined in pom
bmiddleb Jun 24, 2016 8:43 PM (in response to bmiddleb)I want to use Hibernate 4.3. How do I define the slot?
-
40. Re: WildFly 10.0 - NoClassDefFoundError on deploy for classes defined in pom
jamezp Jun 24, 2016 8:44 PM (in response to bmiddleb)Ah I could be wrong about the org.hibernate module being automatically added to the deployment. There is an abstraction layer over JPA to allow other providers to be used. I don't know a lot about it though.
So if you're using those objects in your code then you'll need to include the org.hibernate module in our Dependencies. That said I'm not sure too sure what those two objects are, but I'm not certain they should be used in container managed Hibernate. I'm just making guesses now though
--
James R. Perkins
-
41. Re: WildFly 10.0 - NoClassDefFoundError on deploy for classes defined in pom
jamezp Jun 24, 2016 8:52 PM (in response to bmiddleb)I'm not too sure. This documentation looks slightly out of date and was mostly copied from WildFly 8 docs, but maybe it has some clues JPA Reference Guide - WildFly 10 - Project Documentation Editor. Maybe we could also rope smarlow into giving a hint.
-
42. Re: WildFly 10.0 - NoClassDefFoundError on deploy for classes defined in pom
bmiddleb Jun 24, 2016 9:02 PM (in response to jamezp)I added this stanza to the dependency section of the jboss-deployment-structure.xml file:
<module name="org.hibernate" slot="4.3" /> and I have "org.hibernate" listed as a dependency in the pom.xml <build> dependencies.
That didn't resolve the class loader fussing about those 2 classes. However, the exception is
17:48:10,039 WARN [org.jboss.modules] (Weld Thread Pool -- 1) Failed to define class com.meritagesystems.codecompliance.data.object.ChronoLocalDateTypeUserType in Module "deployment.CodeComplianceServices.war:main" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link com/meritagesystems/codecompliance/data/object/ChronoLocalDateTypeUserType (Module "deployment.CodeComplianceServices.war:main" from Service Module Loader): org/hibernate/usertype/EnhancedUserType
What I realized is that I probably need hibernate-core because, as you pointed out, the default is the JPA impl.