NoClassDefFoundError: org/apache/log4j/Logger in Java applet - java

At the moment, I'm developing java applet for e-signing documents with smartcard, current applet code on server side looks like
echo "<Applet Code=\"Main.class\"
name = \"eParakstitajs\"
mayscript=\"true\"
codebase = \"".SERVER_FULL_URL."/EDOC2.4.0._22.05\"
archive = \"
classesEDOC2.4.jar,
log4j-1.2.17.jar,
eparaksts-bc-1.43.0.jar,
eparaksts-client-2.4.0.jar,
eparaksts-lib-2.4.0.jar,
org.apache.commons.codec_1.3.0.v201101211617.jar,
pkcs11wrapper-1.2.18.jar,
plugin.jar,
signing-applet-2.4.0.jar,
slf4j-api-1.7.7.jar,
slf4j-log4j12-1.7.7.jar,
xmlsec-2.0.2.jar,
./config/\"
width=1
Height=1
>
<PARAM NAME=\"key\" VALUE=\"{$signKey}\">
<PARAM NAME=\"URL\" VALUE=\"".SERVER_FULL_URL."\">
<PARAM NAME=\"PIN1\" VALUE=\"{$_SESSION["userdata"]["PIN1"]}\">
<PARAM NAME=\"PIN2\" VALUE=\"{$_SESSION["userdata"]["PIN2"]}\">
<PARAM NAME=\"USERID\" VALUE=\"{$user[0]["id_lietotajs"]}\">
</Applet>";
On this stage everything is ok, and all listed libraries are in mentioned folder. (ClassesEDOC2.4.jar is my archive with classes, all other are third-party jars)
In my java code, I am instantiating object, based on class QualifiedSignatureHelper from jar eparaksts-lib-2.4.0.jar. And during execution, an exception appears
java.lang.NoClassDefFoundError: org/apache/log4j/Logger
at lv.eparaksts.helpers.QualifiedSignatureHelper.<clinit>(QualifiedSignatureHelper.java:26)
at CreateNewSignTimestampedAction.CreateNewSignTimestamped(CreateNewSignTimestampedAction.java:128)
at Main.init(Main.java:221)
at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.init(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 6 more
I have decompiled class QualifiedSignatureHelper, and discovered that it imports log4j class, and also instantiating log4j object for some reasons
According to exception, QualifiedSignatureHelper class cant find log4j class. Any advice?

Related

java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory even my class did have the jars

This took me some time to debug , but still no clue.
I am using m2e under Eclipse, I checked the java.class.path, it did have below jars on the classpath.
Any idea ?
Exception in thread "main" java.lang.NoClassDefFoundError:
org/slf4j/LoggerFactory
at hadoop.ReadHDFS.main(ReadHDFS.java:18)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
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
C:\Users\xxxx\.m2\repository\org\slf4j\slf4j-api\1.7.10\slf4j-api-1.7.10.jar
C:\Users\xxxx\.m2\repository\log4j\log4j\1.2.17\log4j-1.2.17.jar
C:\Users\xxxx\.m2\repository\org\slf4j\slf4j-log4j12\1.7.10\slf4j-log4j12-1.7.10.jar
---add more context---
I am running the hadoop program. just found that when i add the hadoop-client dependency in the pom.xml, it will abort this error .
In the pom.xml , i did not explicitly add these dependencies but the effective pom have them and the java.class.path also include them.
Compile is good and only error in runtime
---workaround---
It will work if i excluded the slf4j-api from hadoop-client :
As for the root cause, still unknown.

Java Virtual Machine Launcher : A JNI Error with Spring

I use Windows10 Pro 32bit ENG, EclipseEE Mars, Java 8_66. If I want create a easy bean project with Spring and run it it show me a error in Windows dialog. When I enter this dialog it generated exception.
Java Virtual Machine Launcher - Error :
A JNI error has occurred, please check your installation and try it again.
I have in CLASSPATH : Apache *.jars
•commons-logging-1.2.jar
•commons-logging-1.2-javadoc.jar
Spring *.jars
•spring-aop-4.1.5.RELEASE.jar
•spring-beans-4.1.5.RELEASE.jar
•spring-context-4.1.5.RELEASE.jar
•spring-aspects-4.1.5.RELEASE.jar
•spring-context-support-4.1.5.RELEASE.jar
•spring-core-4.1.5.RELEASE.jar
•spring-web-4.1.5.RELEASE.jar
•spring-webmvc-4.1.5.RELEASE.jar
•spring-expression-4.1.5.RELEASE.jar
I have the tested Java 8_60 vs Spring 4.1.5, Java 8_66 vs Spring 4.1.5 or 4.2.2.
KlientMetaTest.java
package klient;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import server.ServerVypis;
public class KlientMetaTest {
public static void main(String[] args) {
#SuppressWarnings("resource")
ApplicationContext context = new ClassPathXmlApplicationContext("META-INF/Beans.xml");
ServerVypis obj = (ServerVypis) context.getBean("mujSpring"); // id beanu
obj.getMessage();
}
}
ServerVypis.java
package server;
public class ServerVypis {
private String message;
public void setMessage(String message){
this.message = message; }
public void getMessage(){
System.out.println("Zde je tvuj Spring vypis : " + message); }
}
beans.xml which is in /META-INF/ folder
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="mujSpring" class="server.ServerVypis">
<property name="message" value="Vypis z \META-INF\Bean.xml"/>
</bean>
</beans>
Exception which was showing in console :
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContext
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)
... 7 more
I have faced the same problem.
I made some changes in my pom.xml. Ff you are using the dependency of javax mail as well aws sdk then make sure that javax mail should be declare before the aws sdk's.
If you change the sequence then it will show the above error as it's loading jars in wrong sequence.As this worked in mine case, Hope this will work for you!
Problem solved. After I install Windows10, it broke my access to folders when I have save the external jars of frameworks.

java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory after building .jar with NetBeans [duplicate]

This question already has answers here:
java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory
(26 answers)
Closed 4 years ago.
I moved my project over from eclipse to netbeans and I am now receiving Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory error when I try to run the .jar file after building it. The program runs fine from
Here is what I have in my classpath:
slf4j-api-1.7.11.jar
slf4j-ext-1.7.11.jar
log4j-1.2.17.jar
Here is my logger:
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Log {
public static final Logger logger = LoggerFactory.getLogger(Log.class);
public Log(){
}
}
log4j.properties:
# Root logger option
log4j.rootLogger=INFO, file
# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
#Redirect to Tomcat logs folder
#log4j.appender.file.File=${catalina.home}/logs/logging.log
log4j.appender.file.File=C:\\Log.log
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
What I call when I want to log something (and this is where it bombs out and throws that error):
Log.logger.info("");
Exception:
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at com.xxx.xxxx.Log.<clinit>(Log.java:8)
at com.xxx.xxxx.MainGui.PrintHeaderForLog(MainGui.java:319)
at com.xxx.xxxx.MainGui.<init>(MainGui.java:69)
at com.xxx.xxxx.MainGui.<clinit>(MainGui.java:48)
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)
... 4 more
Probably slf4j.jar is not getting loaded for some reason.You can include some jars to class path:
slf4j-log4j12
slf4j-simple ..
After all clean your project and run.It will run successfully.
In case, your getting "java.lang.NoClassDefFoundError: Lorg/slf4j/Logger", while starting the Tomcat server,
Then either you have not copied the shared tomcat properly or
There is a issue with "apache tomcat/conf/catalina.properties" file.
Solution
Download new Apache tomcat server and use it.
Delete the existing server, copy the server from downloads and paste it again to the same location and use it.

Windows Service - Apache commons daemon class not found

I have a Jar file that needs to be installed as a windows service. I'm using Apache commons daemon procrun.
Though the service appears in the Services tab in task manager its not running. Its in stopped state and attempting to start it seems not working.
*In commons daemons logs I noticed that it cannot load the main class which is the "AgentApp".
I installed 32bit jre too.
Mentioned here under the log file contents.
imageprocagent stderr:
2015-01-07 15:47:47 Commons Daemon procrun stderr initialized
java.lang.NoClassDefFoundError: org/apache/commons/daemon/Daemon
at java.lang.ClassLoader.defineClass1(Native Method)
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)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.daemon.Daemon
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)
... 12 more
Exception in thread "main"
crawford-daemon:
[2015-01-07 15:47:47] [info] Commons Daemon procrun (1.0.10.0 32-bit) started
[2015-01-07 15:47:47] [info] Running 'ImageProcAgent' Service...
[2015-01-07 15:47:47] [info] Starting service...
[2015-01-07 15:47:49] [error] FindClass com/fx358/fx9/agent/AgentApp failed
[2015-01-07 15:47:49] [error] Failed to start Java
[2015-01-07 15:47:49] [error] ServiceStart returned 4
[2015-01-07 15:47:49] [info] Run service finished.
[2015-01-07 15:47:49] [info] Commons Daemon procrun finished
`[2015-01-07 15:47:49] [error] FindClass com/fx358/fx9/agent/AgentApp failed
Here is the script I'm using to install the agent:
SET DISPLAYNAME="ImageProcAgent"
SET DESCRIPTION="FX9 image processing Agent"
SET LOGPATH="C:\FX9\logs\ImageProcAgent"
SET STARTPATH=
SET JVMLOCATION="C:\Program Files (x86)\Java\jre7\bin\client\jvm.dll"
SET CUSTCLASSPATH="C:\FX9\release\ImageProcAgent\GenericAgent_jar\GenericAgent.jar;C:\FX9\release\ImageProcAgent\GenericAgent_jar\ImageProcAgent.jar;."
ECHO ON
ImageProcAgent.exe //IS//ImageProcAgent --DisplayName=%DISPLAYNAME% --Description=%DESCRIPTION% --Startup=auto --LogPath=%LOGPATH% --LogLevel=INFO --LogPrefix=crawford-daemon --StdOutput=auto --StdError=auto --StartPath=%STARTPATH% --StartClass=com.fx358.fx9.agent.AgentApp --StartMethod=main --StartParams=start --StartMode=jvm --StopPath=%% --StopClass=com.fx358.fx9.agent.AgentApp --StopMethod=stop --StopMode=jvm --Jvm=%JVMLOCATION% --Classpath=%CUSTCLASSPATH% --JvmOptions=-Xmx512M ++JvmOptions=-Djava.util.logging.config.file=logging.properties
`
Can someone point me out what I'm doing wrong? thanks in advance.
I had the same error. Turns out, I was attempting to use commons-logging and log4j directly within the Service class. However, the log4j was not initializing properly, thus causing the load to error out.
I removed all the log4j, replacing it with a simple System.out.* and it worked.
In your classpath declaration there are only 2 jar entries:
CUSTCLASSPATH="C:\FX9\release\ImageProcAgent\GenericAgent_jar\GenericAgent.jar;C:\FX9\release\ImageProcAgent\GenericAgent_jar\ImageProcAgent.jar;."
Is your application's your build as a fat-jar containing all compile and runtime dependencies? Otherwise you'll have to add each JAR that is needed at runtime of your service to the classpath. For example:
CUSTCLASSPATH="C:\FX9\release\ImageProcAgent\GenericAgent_jar\GenericAgent.jar;C:\FX9\release\ImageProcAgent\GenericAgent_jar\ImageProcAgent.jar;C:\FX9\release\ImageProcAgent\GenericAgent_jar\lib\commons-daemon-1.0.15.jar;<PROBABLY_MORE_JARS_NEED_TO_BE_ADDED_HERE>;."
Furthermore using . in the classpath of your service is probably not a good idea. You should only use fully qualified paths in there. Otherwise you'll be dependent on the location from where the service is executed by Windows.
I had the same error with a runnable jar build with ANT. The Service-Class fails with a severe error. One reason was, i used signed libraries SHA1-Digest, please check this. To avoid this problem don't build a runnable, deliver the libraries you are using, and set the Class-Path in the MANIFEST.MF of your JAR-File. Hope this helps you.

Solr 4.1 Core Initialization Failure [duplicate]

This question already has answers here:
Solr RequestHandler init failure
(2 answers)
Closed 7 years ago.
I have updated my version of Solr from 3.5 to 4.1
I have removed the old war file from my apache tomcat (7) webapps, and deployed the new war file that has been provided in the apache-solr package.
I got the following error upon trying to access solr from the web browser!
I have one core only(dbTrial)
Solr opens but this error appears.
SolrCore Initialization Failures
dbTrial: org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: RequestHandler init failure
There are no SolrCores running.
Using the Solr Admin UI currently requires at least one SolrCore.
Unable to load environment info from null/admin/system?wt=json.
This interface requires that you activate the admin request handlers in all SolrCores by adding the following configuration to your solrconfig.xml:
Can you help me out? I have tried adding the request handler as specified, but it didn't work.
It seems that the new versions of solr need a new format for solrconfig file. can you assist please! thank you!
the log is the following:
????? ?????? 21, 2014 9:19:05 ? org.apache.solr.common.SolrException log
SEVERE: null:org.apache.solr.common.SolrException: RequestHandler init failure
at org.apache.solr.core.RequestHandlers.initHandlersFromConfig(RequestHandlers.java:168)
at org.apache.solr.core.SolrCore.<init>(SolrCore.java:657)
at org.apache.solr.core.SolrCore.<init>(SolrCore.java:566)
at org.apache.solr.core.CoreContainer.create(CoreContainer.java:850)
at org.apache.solr.core.CoreContainer.load(CoreContainer.java:534)
at org.apache.solr.core.CoreContainer.load(CoreContainer.java:356)
at org.apache.solr.core.CoreContainer$Initializer.initialize(CoreContainer.java:308)
at org.apache.solr.servlet.SolrDispatchFilter.init(SolrDispatchFilter.java:107)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:277)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:258)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:382)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:103)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4624)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5281)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:866)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:842)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:958)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1599)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.solr.common.SolrException: Error loading class 'solr.DisMaxRequestHandler'
at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:436)
at org.apache.solr.core.SolrCore.createInstance(SolrCore.java:469)
at org.apache.solr.core.SolrCore.createRequestHandler(SolrCore.java:540)
at org.apache.solr.core.RequestHandlers.initHandlersFromConfig(RequestHandlers.java:154)
... 25 more
Caused by: java.lang.ClassNotFoundException: solr.DisMaxRequestHandler
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.net.FactoryURLClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:420)
... 28 more
Check the Solr log for a better error of what the issue is when Solr is starting up - you'll probably have a better error message there than the one you can see in the Admin interface (which is the error triggered when the interface attempts to access the Solr core). The reason why the core or requestHandler isn't loading will be in the log file, and not in the message produced by the UI. Remember that logging also changed at 4.3, if you've updated to 4.10 (I see that you wrote 4.1, but if you're planning on going the whole way (or meant 4.10) - the logging might have to be configured as well).
You'll also want to consider the "going from 3 to 4" document, that details the changed to the configuration files (as solrconfig.xml changed a bit).
Update
The log shows that it's complaining about loading "solr.DisMaxRequestHandler". This has been deprecated for quite some time and has been removed - just use the standard request handler from the example solrconfig.xml instead.
<requestHandler name="standard" class="solr.SearchHandler" default="true">
<lst name="defaults">
<str name="echoParams">explicit</str>
</lst>
</requestHandler>

Categories