java.lang.ClassNotFoundException: com.ibm.mq.MQEnvironment in jar file - java

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

Related

ClassNotFoundException com.mysql.cj.jdbc.Driver

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)

Exception in thread "main" java.lang.NoClassDefFoundError maven jar

i am new to maven, after running Maven with mvn clean package command.
it compiles the project into an executable jar.
i run the jar in the terminal and got this error:
$ java -jar create_pass_criteria-1.0-SNAPSHOT.jar
Exception in thread "main" java.lang.NoClassDefFoundError: com/mprv/automation/core/exceptions/AutomationException
at Create_pass_criteria.Main.main(Main.java:23)
Caused by: java.lang.ClassNotFoundException: com.mprv.automation.core.exceptions.AutomationException
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 a lot of jars that i use in my code by importing them.
how can i make the jar also include those jars?
is this what this error means?
appreciate any help,
thank you
Try it
Just add all the required libraries to the classpath when using java -jar target/PriseDeNotes-0.0.1-SNAPSHOT.jar with the --classpath argument.

Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Logger in XPages

In our XPages project now we have to use Quartz Scheduler. I've tried to import all necessary jars which includes the following:
c3p0-0.9.5.2
log4j-1.2.16.jar
quartz-2.3.0-SNAPSHOT.jar
quartz-jobs-2.3.0-SNAPSHOT.jar
slf4j-api-1.7.7.jar
slf4j-log4j12-1.7.7.jar
I've imported all the jars to our project but when loading a page (which doesn't even call quartz or anything) I get the following exception:
Error 500
HTTP Web Server: Command Not Handled Exception
In a log I see:
01.12.19 2:04: Exception Thrown
java.lang.RuntimeException: com.ibm.xsp.FacesExceptionEx: org.apache.commons.logging.LogConfigurationException: java.lang.reflect.InvocationTargetException
at com.ibm.designer.runtime.domino.adapter.ComponentModule.initModule(ComponentModule.java:473)
at com.ibm.domino.xsp.module.nsf.NSFComponentModule.initModule(NSFComponentModule.java:498)
at com.ibm.domino.xsp.module.nsf.NSFService.createNSFModule(NSFService.java:752)
at com.ibm.domino.xsp.module.nsf.NSFService.loadModule(NSFService.java:735)
at com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:588)
at com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:482)
at com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:357)
at com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:313)
at com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)
Caused by: com.ibm.xsp.FacesExceptionEx: org.apache.commons.logging.LogConfigurationException: java.lang.reflect.InvocationTargetException
at com.ibm.xsp.config.CLBootStrap.initContext(CLBootStrap.java:89)
at com.ibm.xsp.config.BootStrap.init(BootStrap.java:82)
at com.ibm.xsp.config.ConfigureCoreListener.contextInitialized(ConfigureCoreListener.java:39)
at com.ibm.designer.runtime.domino.adapter.ComponentModule.initModule(ComponentModule.java:465)
... 8 more
Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.reflect.InvocationTargetException
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:532)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:272)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:414)
at org.apache.commons.digester.Digester.<init>(Digester.java:346)
at com.sun.faces.config.ConfigureListener.digester(ConfigureListener.java:1005)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:383)
at com.ibm.xsp.config.CLBootStrap.initContext(CLBootStrap.java:81)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedConstructorAccessor1791.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:57)
at java.lang.reflect.Constructor.newInstance(Constructor.java:437)
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:525)
... 17 more
Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Logger
at org.apache.commons.logging.impl.Log4JLogger.<init>(Log4JLogger.java:102)
... 21 more
I suspect that this problem is related to Axis 1.4 log4j-1.2.8.jar incompatible with XPages?
I've tried to follow the advice and added the following to java.policy (section grant codeBase):
permission java.lang.RuntimePermission "setContextClassLoader";
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
But still with no luck.
What's the problem?
Thanks in advance
I've resolved the issue by adding all logging libraries:
log4j-1.2.16.jar
slf4j-api-1.7.7.jar
slf4j-log4j12-1.7.7.jar
to lib/ext

Talend Error: Exception in thread "Thread-0" java.lang.NoClassDefFoundError: org/apache/http/conn/scheme/SchemeSocketFactory

I am using Talend to load some data from Redshift, then upload it to S3 and then Redshift again.
The logic is tRedshiftInput -> tRedshiftOutputBulkExec
However, I am getting this error:
Exception in thread "Thread-0" java.lang.NoClassDefFoundError: org/apache/http/conn/scheme/SchemeSocketFactory at com.amazonaws.AmazonWebServiceClient.(AmazonWebServiceClient.java:136) at com.amazonaws.services.s3.AmazonS3Client.(AmazonS3Client.java:481) at com.amazonaws.services.s3.AmazonS3Client.(AmazonS3Client.java:461) at com.amazonaws.services.s3.AmazonS3Client.(AmazonS3Client.java:443) at momox.ga2redshift_tvvisits_inside_0_1.GA2Redshift_TVvisits_Inside.tGoogleAnalyticsInput_1Process(GA2Redshift_TVvisits_Inside.java:1516) at momox.ga2redshift_tvvisits_inside_0_1.GA2Redshift_TVvisits_Inside.runJobInTOS(GA2Redshift_TVvisits_Inside.java:2082) at momox.ga2redshift_tvvisits_inside_0_1.GA2Redshift_TVvisits_Inside.runJob(GA2Redshift_TVvisits_Inside.java:1911) at momox.ga2redshift_tvvisits_loop_0_1.GA2Redshift_TVvisits_Loop.tRedshiftInput_1Process(GA2Redshift_TVvisits_Loop.java:1149) at momox.ga2redshift_tvvisits_loop_0_1.GA2Redshift_TVvisits_Loop.tRedshiftRow_2Process(GA2Redshift_TVvisits_Loop.java:567) at momox.ga2redshift_tvvisits_loop_0_1.GA2Redshift_TVvisits_Loop$2.run(GA2Redshift_TVvisits_Loop.java:2613) Caused by: java.lang.ClassNotFoundException: org.apache.http.conn.scheme.SchemeSocketFactory at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 10 more
The libraries I have for the job are:
aws-java-sdk-1.10.52.jar
cimt.talendcomp.gaanalytics-2.1-jar-with-dependencies.jar
commons-codec-1.6.jar
commons-logging-1.1.3.jar
dom4j-1.6.1.jar
httpclient-4.5.2.jar
httpclient-4.5.3.jar
httpcore-4.3.3.jar
jackson-annotations-2.5.3.jar
jackson-core-2.5.3.jar
jackson-databind-2.5.3.jar
joda-time-2.8.1.jar
log4j-1.2.17.jar
routines.jar
Any ideas?

Why is my jar not running?

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.

Categories

Resources