java.lang.ClassNotFoundException: org.bouncycastle.asn1.ASN1Encodable - java

I am using IText 4.2.0 and bcprov-jdk15-1.43.jar and bctsp-jdk15-1.43.jar for signing pdf. I added these jars by add external jars button in Eclipse. When I execute it gives me following error.
ExceptionConverter: java.lang.Exception: Failed to get TSA response from tsaURL
at com.lowagie.text.pdf.TSAClientBouncyCastle.getTimeStampToken(TSAClientBouncyCastle.java:185)
at com.lowagie.text.pdf.TSAClientBouncyCastle.getTimeStampToken(TSAClientBouncyCastle.java:136)
at com.lowagie.text.pdf.PdfPKCS7.getEncodedPKCS7(PdfPKCS7.java:1236)
at pack1.PDFSigningWithHSM.PDFSigningWithHSM.main(PDFSigningWithHSM.java:489)
Caused by: java.lang.NoClassDefFoundError: org/bouncycastle/asn1/ASN1Encodable
at com.lowagie.text.pdf.TSAClientBouncyCastle.getTimeStampToken(TSAClientBouncyCastle.java:146)
... 3 more
Caused by: java.lang.ClassNotFoundException: org.bouncycastle.asn1.ASN1Encodable
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 java.lang.ClassLoader.loadClass(Unknown Source)
... 4 more
But I see Class ASN1Encodable in the jar file bcprov-jdk15-1.43.jar. I dont understand what is the problem.

That exception means that the classloader cannot find that class at runtime. We don't have enough information to determine why it is the case ... but it is definitely the cause of your problems.
Check that the offending JAR file is actually on your application's effective runtime classpath.

Related

java.lang.NoClassDefFoundError - Log4j doesn't work even with jar files

I've added log4j-api-2.13.0.jar:log4j-core-2.13.0.jar to CLASSPATH but still I get the following error. Any idea how to resolve the error?
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/logging/log4j/LogManager
at demo.selenium.IBanTest.<clinit>(IBanTest.java:22)
Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.LogManager
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
ENV:
CLASSPATH=".:selenium-chrome-driver-3.12.0.jar:selenium-server-standalone-3.13.0.jar:guava-13.0.1.jar:junit4.jar:log4j-api-2.13.0.jar:log4j-core-2.13.0.jar"
BASH:
java demo.selenium.IBanTest
Figured it out.
I also had to include log4j2-2.3.jar.
log4j-core-2.14.1.jar
log4j2-2.3.jar
log4j-api-2.14.1.jar
CLASSPATH for example would be like:
CLASSPATH = ".:/home/user/:selenium-chrome-driver-3.12.0.jar:selenium-server-standalone-3.13.0.jar:guava-13.0.1.jar:junit4.jar:log4j-core-2.14.1.jar:log4j2-2.3.jar:log4j-api-2.14.1.jar"
And run the program in directory target/classes/:
java demo.selenium.IBanTest

Executing jar file throws class not found error

Using Eclipse, I am modifying a Java project we have been using for years. a specific class method is typically executed by sending a message through IBM WebSphere MQ. However, I now have a need to develop some new functionality and I need to be able to test it out side the MQ world.
I am able to successfully debug the application in Eclipse, but if I attempt to execute the jar file from a command prompt I receive the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: XMLBuilder/Node
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: XMLBuilder.Node
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)
... 6 more
My build is done using an ant script. This does not include a Class-Path attribute when creating the manifest.
The XMLBuilder.jar file is included in the target jar. Running jar -tf file.jar shows
META-INF/)
META-INF/MANIFEST.MF)
... Omitted for Brevity ...
XMLBuilder.jar
What might I be missing?
Thank you

Quartz scheduler job

I have tried to make a scheduler job using quartz library. I have added the quartz-all-xxx.jar file but it's showing me error
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.quartz.impl.StdSchedulerFactory.<init>(StdSchedulerFactory.java:298)
at org.quartz.impl.StdSchedulerFactory.getDefaultScheduler(StdSchedulerFactory.java:1516)
at Main.Schedular.main(Schedular.java:19)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
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)
... 3 more
so is there any other jar file I have to add ???
As you can see on this Maven repository page the quartz library has a dependency to org.slf4j.
Given your version of quartz, add the proper dependency version to your classpath.
You need to add SLF4J-API. Or, you know, use maven or something…
Edit: and probably some implementation.

LibreOffice SDK bootstrap

I got the standard jar files + juh-2.4.1.jar and ridl-3.2.1.jar (got errors on import) as referenced libraries in my project. When i get an example piece of code from http://api.libreoffice.org/examples/DevelopersGuide/examples.html#FirstSteps i always land on this error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/star/comp/loader/JavaLoader
at com.sun.star.comp.helper.Bootstrap.createInitialComponentContext(Bootstrap.java:118)
at com.sun.star.comp.helper.Bootstrap.bootstrap(Bootstrap.java:241)
at TextDocuments.getRemoteServiceManager(TextDocuments.java:410)
at TextDocuments.storePrintExample(TextDocuments.java:378)
at TextDocuments.runDemo(TextDocuments.java:152)
at TextDocuments.main(TextDocuments.java:142)
Caused by: java.lang.ClassNotFoundException: com.sun.star.comp.loader.JavaLoader
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)
... 6 more
Always a NoClassDefFoundError on bootstrap.. Searching for this but can't find much.. Anybody has an idea how to fix this?
In my LibreOffice installation the missing class is located in the file jurt.jar

EJB exception while try to run the client

javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interf
aces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: o
rg.jnp.interfaces.NamingContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at Client_TestPortal.main(Client_TestPortal.java:54)
Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFac
tory
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)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
... 5 more
That exception says that initializing of the InitialContext has failed for your Client_TestPortal application. The resaon is that it has been unable to load the class org.jnp.interfaces.NamingContextFactory which (I presume) the default Java Naming provider for your platform.
It appears that your apps classpath is missing a required JAR file. According to this findjar query it could be one of the following:
[LOCAL] jbossall-client.jar
[LOCAL] jbossjmx-ant.jar
[MAVEN2] jnpserver-3.2.3.jar
[MAVEN2] jbossall-client-3.2.1.jar
[MAVEN2] jbossall-client-3.2.3.jar
[MAVEN2] jbossjmx-ant-3.2.3.jar
[MAVEN2] jnp-client-3.2.1.jar
[MAVEN2] jnp-client-4.0.2.jar
... or something like that. Which (if any) of the above JARs is most appropriate is hard to say.
You have not provided enough information like the environment you are using, The app server etc.
Any way it lloks like JNDI related JAR is not on the classpath. If it is in place and still not working, then you may have missed to put the correct context information, so pass the JNDI information to the constuctor of InitialContext.
I had the same problem but I found how to fix it. All you have to do is add the jbossall-client.jar library to the clients project, and done!!! You can find the file inside the client folder.
e.g jboss-6.1.0.Final_GPT\client
I was using Jboss 6.1.0
You can also get help from this link
https://community.oracle.com/thread/1157701?start=0
Hope it helps.

Categories