Maven does not export all Classnotfoundexception jars

Asked

Viewed 99 times

0

I have a web project (.War) and it exports SOME jars to WEB-INF/lib folder, as it does not export the jar org.json and I’m getting Classnotfoundexception!

I am using Maven, would like to know how I force it to be exported all depenicas to WEB-INF/lib folder, or to appropriate folder.

Details of the error

Allocate exception for servlet login: java.lang.ClassNotFoundException: org.json.JSONException from BaseClassLoader@771510a9{vfs:///opt/syonet/jboss6/server/default/deploy/ModuloAgenda.war}
    at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:480) [jboss-classloader.jar:2.2.1.GA]

Follow 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ModuloAgenda</groupId>
<artifactId>ModuloAgenda</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>ModuloAgenda</name>
<description />
<properties>
    <webVersion>3.0</webVersion>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>bean-validator</artifactId>
        <version>3.0-JBoss-4.0.2</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.enterprise.deploy</artifactId>
        <version>3.0.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.jms</artifactId>
        <version>3.0.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.management.j2ee</artifactId>
        <version>3.0.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>javax.persistence</artifactId>
        <version>2.0.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.resource</artifactId>
        <version>3.0.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.security.auth.message</artifactId>
        <version>3.0.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.security.jacc</artifactId>
        <version>3.0.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.servlet</artifactId>
        <version>3.0.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.servlet.jsp</artifactId>
        <version>3.0.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.servlet.jsp.jstl</artifactId>
        <version>3.0.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api-osgi</artifactId>
        <version>2.2.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.ws.rs</groupId>
        <artifactId>jsr311-api</artifactId>
        <version>1.1.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.glassfish.web</groupId>
        <artifactId>jstl-impl</artifactId>
        <version>1.2</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.4.3</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.xml</groupId>
        <artifactId>webservices-api-osgi</artifactId>
        <version>2.0.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.jboss.weld</groupId>
        <artifactId>weld-osgi-bundle</artifactId>
        <version>1.0.1-SP3</version>
        <scope>provided</scope>
    </dependency>

    <!-- CONFLITO COM O PORTAL <dependency> <groupId>org.glassfish.web</groupId> 
        <artifactId>javax.servlet.jsp.jstl</artifactId> <version>1.2.1</version> 
        </dependency> -->

    <!-- https://mvnrepository.com/artifact/com.squareup.okhttp/okhttp -->
    <dependency>
        <groupId>com.squareup.okhttp</groupId>
        <artifactId>okhttp</artifactId>
        <version>2.7.5</version>
    </dependency>


    <!-- https://mvnrepository.com/artifact/com.squareup.retrofit/retrofit -->
    <dependency>
        <groupId>com.squareup.retrofit</groupId>
        <artifactId>retrofit</artifactId>
        <version>1.9.0</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.7</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.json/json -->
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20160212</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
    <dependency>
        <groupId>commons-codec</groupId>
        <artifactId>commons-codec</artifactId>
        <version>1.9</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>2.7.5</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.7.5</version>
    </dependency>


</dependencies>
<build>
    <sourceDirectory>src</sourceDirectory>
    <resources>
        <resource>
            <directory>src</directory>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </resource>
    </resources>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <warSourceDirectory>${basedir}/WebRoot</warSourceDirectory>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
    </plugins>
</build>

  • Strange, you already added the plugin to package War. Which command you are using to generate the Maven jar?

  • I’m using myEclipse2015, I’m using War by itself...

  • Ahhh, bug him. Use the same Maven: mvn package War:War. Tell me if it worked that I put in the answer ^^

  • @Giulianabezerra I’ve been using Maven for a couple of days, how and where I should use this command?

  • Do you use linux? If you do go to the terminal, enter the directory where your project’s pom.xml is, and run: mvn package War:War. If you use Windows, go to Computer > Right-click > Properties > Advanced System Settings > Environment Variables. Find the PATH variable and add the path to the Maven bin folder. Then just run the same command: mvn package War:War.

  • I didn’t have the Maven installed, I’ll test it here

  • Didn’t work...

  • Pera, did it generate War in the target folder? It is the War generated there that you need to use pro server deploy.

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.