1
votes

I wonder why my app throws this error:

[ERROR] java.lang.NoClassDefFoundError: javax/validation/Validator [ERROR] at java.lang.ClassLoader.defineClass1(Native Method) [ERROR] at java.lang.ClassLoader.defineClass(ClassLoader.java:800) [ERROR] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) [ERROR] at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) [ERROR] at java.net.URLClassLoader.access$100(URLClassLoader.java:71) [ERROR] at java.net.URLClassLoader$1.run(URLClassLoader.java:361) [ERROR] at java.net.URLClassLoader$1.run(URLClassLoader.java:355) [ERROR] at java.security.AccessController.doPrivileged(Native Method) [ERROR] at java.net.URLClassLoader.findClass(URLClassLoader.java:354) [ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:425) [ERROR] at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:215) [ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:358) [ERROR] at org.jboss.resteasy.core.ResourceMethod.(ResourceMethod.java:162) [ERROR] at org.jboss.resteasy.core.ResourceMethodRegistry.processMethod(ResourceMethodRegistry.java:280) [ERROR] at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:129) [ERROR] at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:111) [ERROR] at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:88) [ERROR] at org.jboss.resteasy.plugins.guice.ModuleProcessor.processInjector(ModuleProcessor.java:66) [ERROR] at org.jboss.resteasy.plugins.guice.ModuleProcessor.process(ModuleProcessor.java:45) [ERROR] at org.jboss.resteasy.plugins.guice.GuiceResteasyBootstrapServletContextListener.contextInitialized(GuiceResteasyBootstrapServletContextListener.java:31)

When it has this dependency in place:

pom.xml

   <dependency>
       <groupId>javax.validation</groupId>
       <artifactId>validation-api</artifactId>
       <version>1.0.0.GA</version>
       <scope>provided</scope>
   </dependency>

   <dependency>
       <groupId>javax.validation</groupId>
       <artifactId>validation-api</artifactId>
       <version>1.0.0.GA</version>
       <classifier>sources</classifier>
       <scope>provided</scope>
   </dependency>
1
As provided, you're saying that the container will provide them so they aren't included in the build. Does your container provide them? - Sotirios Delimanolis
I see, I don't think that this is provided by the container... so I should just remove the scope? - quarks
If you get rid of it, the jars will be included in the (I assume that's what you have) generated WAR. - Sotirios Delimanolis
NEVER depend on a source artifact, and you also need to include an implementation of the spec in your war, not just the API - like hibernate validator - radai
@radai: dependency on validation-api source is required for GWT. don't know if it's the case here, but never say never :) - Denis Tulskiy

1 Answers

0
votes

I scratched my head on this one, but I found a solution that worked for me.

Open up standalone.xml (assuming you are in standalone mode) from your JBOSS folder (JBOSS 7 and WildFly). The path should be something like:

/{JBOSS_ROOT_FOLDER}/standalone/configuration/standalone.xml

In the file, look for the following XML snippet:

<subsystem xmlns="urn:jboss:domain:ee:2.0">
...
</subsystem>

It'll have all sorts of XML configurations in-between. Add the following content to it:

<global-modules>
    <module name="{MODULE_NAME}" slot="main"/>  <--- where {MODULE_NAME} is the name of your module
</global-modules>

Obviously, if you already have a <global-modules> section, don't add it twice, but do insert which module you want to use. It's a quirky thing, but that got my WildFly running.

Do note that the version #2.0 in '' is specific to WildFly (JBOSS 8). JBOSS 7 will/should have a lower version.

NOTE: you do have to keep <provided> in your pom.xml's entry.