I build a jar file and this jar file was placed on the linux server.
This jar file catches files in specific folder and execute an insert query.
But I got this error.
I have no idea how to solve this. I already searched and tried setting classpath and etc.
How can I build a jar with jdbc.driver jar?
is there anyone who knows this?
java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver
at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at
com.macrogenusa.cjp.ab1.server.DaoManager.updatePlateRun(DaoManager.java:33)
at UntarFromBoston.update(UntarFromBoston.java:211)
at UntarFromBoston.run(UntarFromBoston.java:43)
at UntarFromBoston.main(UntarFromBoston.java:215)
Related
I got this error when running a maven built jar file:
I build my jar file using maven on NetBean, I able to run without issue on my Netbean, but when I run the jar file java -jar SimpleTestMQ-1.0-SNAPSHOT.jar this error happens:
Exception in thread "main" java.lang.NoClassDefFoundError: com/ibm/mq/MQEnvironment
at com.stee.simpletestmq.SimpleTestApp.main(SimpleTestApp.java:16)
Caused by: java.lang.ClassNotFoundException: com.ibm.mq.MQEnvironment
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 1 more
I have auto generated classes from a WSDL file using Axis2 wsdl2java script. After adding the generated Java files to a Maven project the dependencies were only axis2-adb and axis2-kernel. However during runtime it is throwing the following:
Caused by: java.lang.ClassNotFoundException: org.apache.axiom.util.UIDGenerator
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
and
Caused by: java.lang.NoClassDefFoundError: org/apache/axiom/util/UIDGenerator
at org.apache.axis2.description.AxisOperation.<init>(AxisOperation.java:90)
at org.apache.axis2.description.AxisOperation.<init>(AxisOperation.java:95)
at org.apache.axis2.description.TwoChannelAxisOperation.<init>(TwoChannelAxisOperation.java:52)
at org.apache.axis2.description.OutInAxisOperation.<init>(OutInAxisOperation.java:65)
at org.apache.axis2.description.RobustOutOnlyAxisOperation.<init>(RobustOutOnlyAxisOperation.java:47)
at org.apache.axis2.client.Stub.addAnonymousOperations(Stub.java:233)
at com.tobeprecise.sms.webservices.HttpReceiverStub.populateAxisService(HttpReceiverStub.java:42)
at com.tobeprecise.sms.webservices.HttpReceiverStub.<init>(HttpReceiverStub.java:184)
at com.tobeprecise.sms.webservices.HttpReceiverStub.<init>(HttpReceiverStub.java:173)
at com.tobeprecise.sms.webservices.HttpReceiverStub.<init>(HttpReceiverStub.java:222)
at com.tobeprecise.sms.webservices.HttpReceiverStub.<init>(HttpReceiverStub.java:214)
at in.capillary.nsadmin.gateway.tobeprecisebulk.TobepreciseBulkGatewayChannel.sendMessages(TobepreciseBulkGatewayChannel.java:122)
at in.capillary.nsadmin.gateway.BufferedGatewayChannelProcessor.process(BufferedGatewayChannelProcessor.java:150)
at in.capillary.nsadmin.gateway.BaseGateway.process(BaseGateway.java:207)
at org.apache.camel.processor.DelegateSyncProcessor.process(DelegateSyncProcessor.java:63)
... 18 more
While looking at the dependencies I have found the axiom-api-1.2.11 as a dependency and it very well contains the UIDGenerator class. Is this due to version mismatch?
Found a similar issue ClassNotFoundException axiom-api-1.2.7.jar but I coudn't make much sense out of it(my manifest file: http://pastebin.com/n4jKWPck). Any help?
i'm trying to export a runnable jar from eclipse, but this is the result:
Exception in thread "main" java.lang.NoClassDefFoundError: neg1
Caused by: java.lang.ClassNotFoundException: neg1
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
This is the manifest:
Manifest-Version: 1.0
Rsrc-Class-Path: ./ itextpdf-5.4.3.jar itext-pdfa-5.4.3.jar itext-xtra
-5.4.3.jar
Class-Path: .
Rsrc-Main-Class: Negozio.Start
Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader
And this is how the files are packed into the jar:
http://i.stack.imgur.com/uXEaQ.png
Where Operazioni and Negozio are the my packages and the itext are the external library
Did you forget to include an external jar file?
You must have external jars that you did not include when you exported or were not put in your class path. Right click on your project Properties->Java Build Path and then ensure the "Libraries" tab is selected. Ensure the jars are added here.
I can run my program outside of a jar file, but I want to deploy it and run it as a jar.
This command works for running the .class file:
java -classpath .;./libs/mail.jar;./libs/jcommon-1.0.16.jar;./libs/jfreechart-1.0.13.jar;./libs/jxl.jar;./libs/ojdbc5.jar gdsreports/ReportsDriver
This is how I package my jar file:
jar -cfvm GDSReports.jar GDSReports.mf gdsreports/* util/* libs/*
My manifest looks like this:
Manifest-Version: 1.0
Main-Class: gdsreports.ReportsDriver
Created-By: Me
This is how I run my jar:
java -classpath .;./libs/mail.jar;./libs/jcommon-1.0.16.jar;./libs/jfreechart-1.0.13.jar;./libs/jxl.jar;./libs/ojdbc5.jar;./util;./gdsreports -jar GDSReports.jar
However, run I run the jar file, it fails to load all the libraries. This is what it spits out:
Error loading configuration file: config/reportConfig
Error loading configuration file: config/gdsIds
Exception in thread "main" java.lang.NoClassDefFoundError: jxl/write/WriteException
at util.ReportConfig.setupReports(ReportConfig.java:197)
at util.ReportConfig.setup(ReportConfig.java:65)
at gdsreports.ReportsDriver.main(ReportsDriver.java:36)
Caused by: java.lang.ClassNotFoundException: jxl.write.WriteException
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)
... 3 more
This is the expected output:
Error loading configuration file: config/reportConfig
Error loading configuration file: config/gdsIds
-------------------------------------
Running TimingReport with parameters:
Filename: Reports/06-26-2012/TimingRptZL_06-26-2012.xls
Brand: ZL
Using production database: false
-------------------------------------
-------------------------------------
Exception in thread "main" java.lang.NullPointerException
at gdsreports.TimingReport.fillChartData(TimingReport.java:417)
at gdsreports.TimingReport.fillReport(TimingReport.java:238)
at gdsreports.TimingReport.run(TimingReport.java:131)
at gdsreports.ReportsDriver.main(ReportsDriver.java:40)
What am I doing wrong?
The -classpath argument (and the CLASSPATH environment variable) are ignored when you use the -jar argument.
If a jar file depends on other libraries, you have two choices:
Use the Class-Path header in your MANIFEST.MF file to call out the other jars, or
Unpack the other jars and include them in your jar.
I have created jar in the following folder usr/local/bin/niidle.jar and my MANIFEST.MF file is as follows:
Manifest-Version: 1.0
Main-Class: com.ensarm.niidle.web.scraper.NiidleScrapeManager
Class-Path: hector-0.6.0-17.jar
I verified that the file hector-0.6.0-17.jar is also present in the folder:
/Projects/EnwelibDatedOct13/Niidle/lib/hector-0.6.0-17.jar
I don't want to give full class-path name in MANIFEST.MF file, because I have to run this jar on another machine. So I gave only jar file name Class-Path=hector-0.6.0-17.jar in MANIFEST.MF file.
In spite of mentioning the Class-Path in MANIFEST.MF file, when I run this using command:
java -jar /usr/local/bin/niidle.jar arguments...
It is showing the error message:
--Exception in thread "main" java.lang.NoClassDefFoundError:
me/prettyprint/hector/api/Serializer
at
com.ensarm.niidle.web.scraper.NiidleScrapeManager.main(NiidleScrapeManager.java:21)
Caused by: java.lang.ClassNotFoundException:
me.prettyprint.hector.api.Serializer
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 1 more
Please give me a solution for this error message.
Class-Path is relative or absolute to the directory where your jar file is located.
so for your case you have to hector-0.6.0-17.jar to /usr/local/bin