Getting error in JCommander, java.lang.NoClassDefFoundError in java - java

Hey I am getting following complete error on my console, while trying to run my project.
Exception in thread "main" java.lang.NoClassDefFoundError: com/beust/jcommander/JCommander
at ro.uaic.info.VRPRunner.main(VRPRunner.java:42)
Caused by: java.lang.ClassNotFoundException: com.beust.jcommander.JCommander
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
I have added jcommander dependency in pom.xml file
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<version>1.48</version>
</dependency>
</dependencies>
Can you help me what should i do to resolve this error?

Related

Read a xlsx file using apache poi in java? not working

I have used all poi jars but still i ame getting this error
Exception in thread "main" org.apache.poi.POIXMLException:
java.lang.reflect.InvocationTargetException
at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:62)
at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:456)
at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:162)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.(XSSFWorkbook.java:271)
at ReadExcel.readXLSXFile(ReadExcel.java:38)
at ReadExcel.main(ReadExcel.java:69)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:60)
... 5 more
Caused by: java.lang.NoClassDefFoundError: org/apache/poi/POIXMLTypeLoader
at org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument$Factory.parse(Unknown
Source)
at org.apache.poi.xssf.model.ThemesTable.(ThemesTable.java:46)
... 10 more
Caused by: java.lang.ClassNotFoundException: org.apache.poi.POIXMLTypeLoader
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 12 more
Sounds like you do not have the correct dependencies in you project.
POIXMLTypeLoader comes with POI 3.14-Beta1 and the ooxml-schemas:1.3 reference that class.You have the following options, you can add any of this dependency in your project:
use poi 3.14 beta1
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.14</version>
</dependency>
use ooxml-schemas 1.2
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.14</version>
</dependency>

MercadoPago API Java ClassNotFoundException

The tutorial says that I just have to put these on maven:
<repository>
<id>mercadopago</id>
<url>https://github.com/mercadopago/sdk-java/raw/master/releases</url>
</repository>
<dependency>
<groupId>com.mercadopago</groupId>
<artifactId>sdk</artifactId>
<version>0.3.4</version>
</dependency>
API (https://www.mercadopago.com.br/developers/en/tools/sdk/server/java#install)
and I did, but I'm getting this error:
java.lang.NoClassDefFoundError: com/mercadopago/MP
at io.github.margato.vippago.Main.onEnable(Main.java:31)
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217)
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:457)
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:382)
at org.bukkit.craftbukkit.v1_5_R3.CraftServer.loadPlugin(CraftServer.java:305)
at org.bukkit.craftbukkit.v1_5_R3.CraftServer.enablePlugins(CraftServer.java:287)
at org.bukkit.craftbukkit.v1_5_R3.CraftServer.reload(CraftServer.java:630)
at org.bukkit.Bukkit.reload(Bukkit.java:275)
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:24)
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:189)
at org.bukkit.craftbukkit.v1_5_R3.CraftServer.dispatchCommand(CraftServer.java:546)
at org.bukkit.craftbukkit.v1_5_R3.CraftServer.dispatchServerCommand(CraftServer.java:535)
at net.minecraft.server.v1_5_R3.DedicatedServer.an(DedicatedServer.java:263)
at net.minecraft.server.v1_5_R3.DedicatedServer.r(DedicatedServer.java:228)
at net.minecraft.server.v1_5_R3.MinecraftServer.q(MinecraftServer.java:472)
at net.minecraft.server.v1_5_R3.MinecraftServer.run(MinecraftServer.java:404)
at net.minecraft.server.v1_5_R3.ThreadServerApplication.run(SourceFile:573)
Caused by: java.lang.ClassNotFoundException: com.mercadopago.MP
at java.net.URLClassLoader.findClass(Unknown Source)
at org.bukkit.plugin.java.PluginClassLoader.findClass0(PluginClassLoader.java:80)
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:53)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 17 more
What do I have to do?

NoClassDefFoundError: com/google/appengine/api/urlfetch/ResponseTooLargeException

I am using Google + API to search for people using the following statement.
Plus plus = new Plus.Builder(httpTransport, jsonFactory, null).
setApplicationName("AppName").setGoogleClientRequestInitializer(new
PlusRequestInitializer(API_KEY)).build();
Plus.People.Search searchPeople = plus.people().search(personName).setMaxResults(1L);
PeopleFeed peopleFeed = searchPeople.execute();
I put the dependencies for the library in pom.xml so that it can be build when maven executed
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-plus</artifactId>
<version>v1-rev64-1.13.2-beta</version>
</dependency>
But I get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/appengine/api/urlfetch/ResponseTooLargeException
at com.google.api.client.extensions.appengine.http.urlfetch.UrlFetchTransport.buildGetRequest(UrlFetchTransport.java:61)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:867)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:399)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:328)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:449)
at com.google.PeopleSearch.googleAccountSearch(PeopleSearch.java:52)
at com.google.Search.main(Search.java:128)
Caused by: java.lang.ClassNotFoundException: com.google.appengine.api.urlfetch.ResponseTooLargeException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Any suggestions?
I had a similar error NoClassDefFoundError: com/google/appengine/api/urlfetch/HTTPMethod , for me it was resolved by copying the App Engine SDK jar file from SDK/lib/user/appengine-api-1.0-sdk-1.9.27.jar into my project's WEB-INF/lib folder (I was not using Maven).

java.lang.NoClassDefFoundError: org/eclipse/jetty/server/nio/SelectChannelConnector using com.j256.simplejmx.web.JmxWebServer

I am trying to implement simple JMX Client/Server using com.j256.simplejmx. I want to spy my objects using Web Browser. I copied a really simple piece of code:
package com.my.package.jmx;
import com.j256.simplejmx.web.JmxWebServer;
public class JMXServer {
public static void main(String[] args) throws Exception {
JmxWebServer jmxWebServer = new JmxWebServer(8123);
jmxWebServer.start();
}
}
When I run it I have got an exception:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/jetty/util/thread/ThreadPool
at com.my.package.jmx.JMXServer.main(JMXServer.java:9)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.util.thread.ThreadPool
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
I added this to my pom.xml:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>9.1.3.v20140225</version>
</dependency>
I run it once again and I have got an another excpetion:
Ex
ception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/jetty/server/AbstractConnector
at com.my.package.jmx.JMXServer.main(JMXServer.java:9)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.server.AbstractConnector
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
So once again, I update my pom.xml:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.1.3.v20140225</version>
</dependency>
And it gives me an error once again:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/jetty/server/nio/SelectChannelConnector
at com.mu.package.jmx.JMXServer.main(JMXServer.java:9)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.server.nio.SelectChannelConnector
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
and I cannot find any solution for that. What else I should add to my pom.xml file? Maybe it is an issue with versions of dependencies?
Thank you in advance.
I edited my pom.xml
<project...>
<properties>
<jetty-version>8.1.9.v20130131</jetty-version>
</properties>
<dependencies>
<dependency>
<groupId>com.j256.simplejmx</groupId>
<artifactId>simplejmx</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>${jetty-version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty-version}</version>
<optional>true</optional>
</dependency>
</dependencies>
</project>
Now, I can run this server:
INFO Server - jetty-8.1.9.v20130131
INFO AbstractConnector - Started SelectChannelConnector#0.0.0.0:8123
but when I go to my Web Browser and I put:
localhost:8123
it thows an exception:
WARN nio -
java.lang.SecurityException: class "javax.servlet.AsyncContext"'s signer information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(Unknown Source)
at java.lang.ClassLoader.preDefineClass(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.eclipse.jetty.server.AbstractHttpConnection.<init>(AbstractHttpConnection.java:157)
at org.eclipse.jetty.server.AsyncHttpConnection.<init>(AsyncHttpConnection.java:50)
at org.eclipse.jetty.server.nio.SelectChannelConnector.newConnection(SelectChannelConnector.java:285)
at org.eclipse.jetty.server.nio.SelectChannelConnector$ConnectorSelectorManager.newConnection(SelectChannelConnector.java:325)
at org.eclipse.jetty.server.nio.SelectChannelConnector.newEndPoint(SelectChannelConnector.java:272)
at org.eclipse.jetty.server.nio.SelectChannelConnector$ConnectorSelectorManager.newEndPoint(SelectChannelConnector.java:331)
at org.eclipse.jetty.io.nio.SelectorManager$SelectSet.createEndPoint(SelectorManager.java:841)
at org.eclipse.jetty.io.nio.SelectorManager$SelectSet.doSelect(SelectorManager.java:496)
at org.eclipse.jetty.io.nio.SelectorManager$1.run(SelectorManager.java:290)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.server.nio.SelectChannelConnector
So right now SimpleJMX has an optional dependency for 8.1.9.v20130131 Jetty to support publishing JMX over web/HTTP. If you check out the pom.xml you'll see:
<jetty-version>8.1.9.v20130131</jetty-version>
...
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty-version}</version>
<optional>true</optional>
</dependency>
Can you try this version of Jetty? I'm not sure there is a way for me to support both 8.X.X and 9.X.X but I'll look into it.

Spring project getting exceptions

I have tried a spring(3.1.0) project for the first time,but it gives me runtime errors.I have added log4j but still error occurs.and the org.springframework.beans.factory.xml.XmlBeanFactory is deprecated too.
please help me
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.<init>(DefaultSingletonBeanRegistry.java:83)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.<init>(FactoryBeanRegistrySupport.java:43)
at org.springframework.beans.factory.support.AbstractBeanFactory.<init>(AbstractBeanFactory.java:175)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.<init>(AbstractAutowireCapableBeanFactory.java:157)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.<init>(AbstractAutowireCapableBeanFactory.java:168)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.<init>(DefaultListableBeanFactory.java:158)
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:77)
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:66)
at com.vehicle.SpringDemoApp.main(SpringDemoApp.java:21)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 9 more<br/>
this is what i got
You need apache commons-logging in the classpath. Log4j is not commons-logging.
download commons logging jar from
http://commons.apache.org/logging/download_logging.cgi
You can check which class is in which Opensource (OSS) library here.
If you are using Maven, you can try adding the following dependency:
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
<classifier>api</classifier>
</dependency>

Categories

Resources