Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » NoClassDefFoundError/ClassNotFoundException >>> ObjectMapper
NoClassDefFoundError/ClassNotFoundException >>> ObjectMapper [message #1780235] Thu, 18 January 2018 22:44 Go to next message
Florent Lesage is currently offline Florent LesageFriend
Messages: 2
Registered: January 2018
Junior Member
Hello,

Recent and amateur java developper, on Eclipse IDE, I have join the voluntary staff of a server game. I have a problem with the plugin of the server. It's normally link with our website, but the link seems break. The reason seems to be an "ObjectMapper" not found by the plugin :

[21:20:16] [Thread-8/WARN]: Exception in thread "Thread-8" 
[21:20:16] [Thread-8/WARN]: java.lang.NoClassDefFoundError: org/codehaus/jackson/map/ObjectMapper
[21:20:16] [Thread-8/WARN]:  at main.java.com.naheulcraft.specific.Ressources.FeatureFunctions$AsynchronousAPISender$APISenderRunnable.run(FeatureFunctions.java:669)
[21:20:16] [Thread-8/WARN]: 	at java.lang.Thread.run(Unknown Source)
[21:20:16] [Thread-8/WARN]: Caused by: java.lang.ClassNotFoundException: org.codehaus.jackson.map.ObjectMapper
[21:20:16] [Thread-8/WARN]: 	at java.net.URLClassLoader.findClass(Unknown Source)
[21:20:16] [Thread-8/WARN]: 	at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:101)
[21:20:16] [Thread-8/WARN]: 	at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:86)
[21:20:16] [Thread-8/WARN]: 	at java.lang.ClassLoader.loadClass(Unknown Source)
[21:20:16] [Thread-8/WARN]: 	at java.lang.ClassLoader.loadClass(Unknown Source)
[21:20:16] [Thread-8/WARN]: 	... 2 more


The following dependancy is in the pom.xml, and Maven seems detects it :

<dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>1.9.11</version>
        <type>jar</type>
        <scope>compile</scope> 
    </dependency>

There isn't error in the import :

import org.codehaus.jackson.map.ObjectMapper;
[...]

private class APISenderRunnable implements Runnable
        {
            Map<String, String> params;
            APISenderRunnable(Map<String, String> params)
            {
                this.params = params;
            }

            public void run()
            {
                ObjectMapper mapper = new ObjectMapper();
                String url = FeatureFunctions.BuildFullUrl(NCPlugin.API_URL, params);
                try
                {
                    array = mapper.readTree(new URL(url));
                }
                catch(Exception e)
                {
                    System.out.println("ERROR, URL BUILDING FAILED OR API IS DOWN.");
                }
            }
        }

But it don't work. I have try many propositions on the internet, as change the version, change the .classpath, use com.faster.xml.jackson.databind instead, add the .jar with buildpath > add external jars, clean and build the project... Without success.

This is the complete 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>com.naheulcraft</groupId>
    <artifactId>specific</artifactId>
    <url>http://www.naheulcraft.com/</url>
    <build>
     <sourceDirectory>src</sourceDirectory>
        <resources>
            <resource>
                <filtering>true</filtering>
                <directory>src</directory>
                <includes>
                    <include>plugin.yml</include>
                </includes>
            </resource>
        </resources>
    <plugins>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.0.2</version>
        <configuration>
            <source>1.8</source>
            <target>1.8</target>
            <encoding>${project.build.sourceEncoding}</encoding>
        </configuration>
        </plugin>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.4</version>
        <executions>
            <execution>
            <phase>package</phase>
            <goals>
                <goal>single</goal>
            </goals>
            </execution>
        </executions>       
        <configuration>
            <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
            </descriptorRefs>
        </configuration>
        </plugin>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.4.3</version>
        <configuration>
            <encoding>${project.build.sourceEncoding}</encoding>
        </configuration>
        </plugin>
    </plugins>
    </build>
    <repositories>
    <repository>
        <id>spigot-repo</id>
        <url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
    </repository>
    <!--<repository>
        <id>bukkit-repo</id>
        <url>http://repo.bukkit.org/content/groups/public</url>
    </repository>-->
    <repository>
        <id>codehaus-snapshots</id>
        <url>http://snapshots.repository.codehaus.org</url>
    </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.1</version>
        </dependency>
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>1.9.11</version>
        <type>jar</type>
        <scope>compile</scope> 
    </dependency>
    <!--<dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-annotations</artifactId>
        <version>2.9.3</version>
        <type>jar</type>
        <scope>compile</scope> 
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>2.9.3</version>
        <type>jar</type>
        <scope>compile</scope> 
    </dependency>
    <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.9.3</version>
            <type>jar</type>
            <scope>compile</scope> 
                <exclusions>
                    <exclusion> 
                        <groupId>com.fasterxml.jackson.core</groupId>
                        <artifactId>jackson-annotations</artifactId>
                    </exclusion>
                    <exclusion> 
                        <groupId>com.fasterxml.jackson.core</groupId>
                        <artifactId>jackson-core</artifactId>
                    </exclusion>
             </exclusions> 
    </dependency>-->
    <!--<dependency>
        <groupId>org.bukkit</groupId>
        <artifactId>bukkit</artifactId>
        <version>LATEST</version>
    </dependency>-->
        <dependency>
            <groupId>com.google.code.google-collections</groupId>
            <artifactId>google-collect</artifactId>
            <version>snapshot-20080530</version>
            <type>jar</type>
        </dependency>
    </dependencies>
    <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <name>NaheulcraftFR-Specific</name>
    <version>1.10</version>
</project>

And the actual .classpath :
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry exported="true" kind="lib" path="C:/Users/Florent_2/Desktop/Serveur test Spigot/bukkit.jar"/>
    <classpathentry exported="true" kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry exported="true" kind="lib" path="C:/Users/Florent_2/Desktop/spigot-1.12.2-R0.1-SNAPSHOT-b1577.jar"/>
    <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
    <classpathentry exported="true" kind="lib" path="C:/Users/Florent_2/Desktop/jackson-mapper-asl-1.9.11.jar"/>
    <classpathentry exported="true" kind="lib" path="C:/Users/Florent_2/Desktop/jackson-core-asl-1.9.11.jar"/>
    <classpathentry kind="output" path="target/classes"/>
</classpath>

Thank you in advance for your help.
Florent

P.S. : Sorry for my bad english, I'm french, I'm not english-speaker. I write in english forums because I hope receive more help.

[Updated on: Fri, 19 January 2018 23:20]

Report message to a moderator

Re: NoClassDefFoundError/ClassNotFoundException >>> ObjectMapper [message #1780319 is a reply to message #1780235] Fri, 19 January 2018 23:14 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1613
Registered: July 2009
Senior Member
This is not enough information for anyone to advise. We can't see how this application is configured, what's its classpath? What is PluginClassLoader and how is it configured?
I doubt that any of this is a problem caused by Eclipse.
Re: NoClassDefFoundError/ClassNotFoundException >>> ObjectMapper [message #1780320 is a reply to message #1780319] Fri, 19 January 2018 23:30 Go to previous message
Florent Lesage is currently offline Florent LesageFriend
Messages: 2
Registered: January 2018
Junior Member
Effectively, there are not enough information in the message. The reason is I have not been able to post the totality of my message because of links (anti-bot protection ?).
I edit my message immediately.

EDIT : I don't know if the problem is caused by Eclipse or not, but during my research I found this in a forum on the web with a similar problem, I quote : "It turns out that the environment I am using (Eclipse!) does not properly update the manifest file when you export your code to a JAR file. Without the proper manifest entries, the application cannot "find" the dependent jar files."

I don't know how to proceed.

EDIT2 : PROBLEM SOLVED. I installed m2Eclipse, I selected Run as > Maven Install. A jar-with-dependancies was generated in the target directory, including the missing ObjectMapper. I installed this on the server and this work, the link plugin>website is ok.

[Updated on: Sun, 21 January 2018 02:58]

Report message to a moderator

Previous Topic:workspace locked
Next Topic:How to add menuListener
Goto Forum:
  


Current Time: Wed Aug 22 04:02:06 GMT 2018

Powered by FUDForum. Page generated in 0.01925 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top