javamaventomcatosx-mavericksvraptor

Upgrade vRaptor to 3.5.3 Java.lang.NoClassDefFoundError: br/com/caelum/vraptor/validator/Validator


I have trouble when update my pom.xml for upgrade some jars, like vraptor and hibernate... My environment is, Web project, maven, tomcat 7, vraptor, jpa, osx mavericks, before update jars, all work's fine, after the update I got this error on start tomcat:

SEVERE: Exception starting filter vraptor
java.lang.NoClassDefFoundError: br/com/caelum/vraptor/validator/Validator
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2483)
at java.lang.Class.getDeclaredConstructors(Class.java:1891)
at br.com.caelum.vraptor.ioc.guice.GuiceComponentRegistry.getConstructor(GuiceComponentRegistry.java:154)
at br.com.caelum.vraptor.ioc.guice.GuiceComponentRegistry.bindToConstructor(GuiceComponentRegistry.java:140)
at br.com.caelum.vraptor.ioc.guice.GuiceComponentRegistry.register(GuiceComponentRegistry.java:84)
at br.com.caelum.vraptor.ioc.guice.GuiceComponentRegistry.deepRegister(GuiceComponentRegistry.java:101)
at br.com.caelum.vraptor.scan.DynamicWebAppBootstrap.configure(DynamicWebAppBootstrap.java:46)
at br.com.caelum.vraptor.ioc.guice.GuiceProvider$2.configure(GuiceProvider.java:123)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
at com.google.inject.spi.Elements.getElements(Elements.java:101)
at com.google.inject.spi.Elements.getElements(Elements.java:92)
at com.google.inject.util.Modules$RealOverriddenModuleBuilder$1.configure(Modules.java:172)
at com.google.inject.AbstractModule.configure(AbstractModule.java:59)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
at com.google.inject.spi.Elements.getElements(Elements.java:101)
at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:133)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:103)
at com.google.inject.Guice.createInjector(Guice.java:95)
at com.google.inject.Guice.createInjector(Guice.java:83)
at br.com.caelum.vraptor.ioc.guice.GuiceProvider.start(GuiceProvider.java:97)
at br.com.caelum.vraptor.VRaptor.init(VRaptor.java:119)
at br.com.caelum.vraptor.VRaptor.init(VRaptor.java:113)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:262)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:107)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4797)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5473)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.ClassNotFoundException: br.com.caelum.vraptor.validator.Validator
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
... 36 more

About the error I found this interface in other package: br.com.caelum.vraptor.Validator here is my pom.xml:

<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>br.com.eco</groupId>
<artifactId>e-co</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.vraptor.version>3.5.3</project.vraptor.version>
</properties>

<build>
    <sourceDirectory>src</sourceDirectory>
    <finalName>${project.artifactId}-${project.version}</finalName>
    <resources>
        <resource>
            <directory>src</directory>
            <includes>
                <include>**/*.properties</include>
            </includes>
            <filtering>true</filtering>
        </resource>
    </resources>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1-beta-1</version>
            <configuration>
                <webappDirectory>${project.basedir}/WebContent</webappDirectory>
                <warSourceDirectory>${project.basedir}/WebContent</warSourceDirectory>
                <webXml>${project.basedir}/WebContent/WEB-INF/web.xml</webXml>
                <packagingIncludes>**/*.properties,**/*.jsp,**/*.jar,**/*.class,theme/**/*,images/**/*,**/*.xml,**/*.swf,**/*.tld,**/*.txt</packagingIncludes>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <phase>process-sources</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>WebContent/WEB-INF/lib/</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>br.com.caelum</groupId>
        <artifactId>vraptor</artifactId>
        <version>${project.vraptor.version}</version>
        <optional>true</optional>
        <scope>compile</scope>
        <exclusions>
            <exclusion>
                <groupId>javassist</groupId>
                <artifactId>javassist</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>br.com.caelum.vraptor</groupId>
        <artifactId>vraptor-environment</artifactId>
        <version>1.1.2</version>
    </dependency>

    <dependency>
        <groupId>commons-fileupload</groupId>
        <artifactId>commons-fileupload</artifactId>
        <version>1.2.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-io</artifactId>
        <version>1.3.2</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>taglibs</groupId>
        <artifactId>standard</artifactId>
        <version>1.1.2</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.3.0.Final</version>
    </dependency>
    <dependency>
        <groupId>br.com.caelum.vraptor</groupId>
        <artifactId>vraptor-jpa</artifactId>
        <version>4.0.0</version> <!-- or the latest version -->
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-c3p0</artifactId>
        <version>4.3.0.Final</version>
    </dependency>
</dependencies>
</project>

I really can't find any reason for this, if someone have this trouble and can solved please help-me on this situation.


Solution

  • Figured out what was happening with the upgrade process. I'm using the project, a jar that manages instances of EntityManager vraptor-jpa, when I kept the update, it occasioned the error. Compatibility could be:

    vraptor in version 3.4.2, use the plugin vraptor-jpa-4.0.0.jar

    Vraptor in version 3.5.3, the plugin uses vraptor-jpa-1.0.1.jar

    This change was enough to solve the problem.