I am trying to deploy an application on WAS 6.1 Server.
However, I am getting the below error:
java.lang.NoClassDefFoundError: org.apache.log4j.Logger
at myPackage.myClass.<clinit>(myClass.java:40)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:194)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1328)
at com.ibm.ejs.container.EJSContainer.loadBeanMetaData(EJSContainer.java:1756)
at com.ibm.ejs.container.HomeOfHomes.loadBeanMetaData(HomeOfHomes.java:1073)
at com.ibm.ejs.container.HomeRecord.getHomeAndInitialize(HomeRecord.java:454)
at com.ibm.ejs.container.EJSContainer.getHomeWrapperCommon(EJSContainer.java:1322)
at com.ibm.ejs.container.EJSContainer.getHomeInstance(EJSContainer.java:1231)
at com.ibm.ejs.container.EJSContainer.startBean(EJSContainer.java:1217)
at com.ibm.ws.runtime.component.EJBContainerImpl.startBean(EJBContainerImpl.java:3385)
at com.ibm.ws.runtime.component.EJBContainerImpl.startModule(EJBContainerImpl.java:2589)
at com.ibm.ws.runtime.component.EJBContainerImpl.start(EJBContainerImpl.java:3719)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1304)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1165)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:587)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:832)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:950)
at com.ibm.ws.runtime.component.ApplicationMgrImpl$AppInitializer.run(ApplicationMgrImpl.java:2131)
at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:342)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1473)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
at com.ibm.ws.classloader.CompoundClassLoader.findClass(CompoundClassLoader.java:579)
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:414)
at java.lang.ClassLoader.loadClass(ClassLoader.java:597)
... 22 more
In
Admin Console -> Servers -> Application Servers -> myServerName -> Java and Process Management -> Process Definition -> Java Virtual Machine -> ClassPath
I have an entry as below:
${MY_JARS}\log4j-1.2.15.jar
Where in 'Custom Properties' MY_JARS key contains value as the path to the log4j jar
I did server clean and restart, republish, redeploy the application umpteen number of times. But this error is not going.
What am I doing wrong ?
To use ${MY_JARS} that way, you need to define it in Environment > WebSphere Variables, not in Custom Properties.
However I'd caution you about adding log4j in that manner. I seem to recall log4j might not work correctly if a single jar is shared across multiple apps. I think we attempted using log4j as a Shared Library (probably the more recommended way of doing what you're trying to do, BTW), but ended up needing to deploy to each application's WEB-INF/lib instead.
As dbreaux already pointed out you have to create environment variables with the correct scope. A custom property is available at runtime, but not for the server configuration level.
Within the WAS you can check what libraries are loaded. IIRC you have to click on the Application, afterwards on the Web Module and than you should be able to check the classloaders. If you open up the classloaders, you will see what libraries are loaded.
Please make sure log4j.jar is on the CLASSPATH of your application.For example; under WEB-INF\lib
Related
I deployed have build the .war file on centos with eclipse and then deployed it on tomcat 8.5 on centos(Linux). It is working with that. But when I deployed the same ".war" or build a new ".war" file with eclipse on windows It is not working on Tomcat8.5 and it throws BeansInCreation Exception. Having the same Java1.7 and Tomcat8.5 version windows7.
The build was also working on windows on the previous version(before updating)
and there are nothing major changes done in the latest code.
Here are the logs from localhost :
Caused by: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name '': Bean with name '' has been injected into other beans ['','',''] in its raw version as part of a circular reference, but has eventually been wrapped (for example as part of auto-proxy creation). This means that said other beans do not use the final version of the bean. This is often the result of over-eager type matching - consider using 'getBeanNamesOfType' with the 'allowEagerInit' flag turned off, for example.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:485)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:268)
... 98 more
I think the problem may be because of "large file path" as Linux support more large file path than windows. I have changed in the regedit also to support but that doesn't need to have changed.
If it works on linux but not on windows i assume that there is a class loading issue (order of classes) while your war is deployed. I would recommend to check /lib directory inside your .war file.
Maybe it contains different versions from the same jar.
Edited:
You can track the class loading of tomcat (or any java application) on linux and windows. For this you need to start it with a special vm paramter (-verbose:class). take a look here:
Java verbose class loading
I've got into a scenario where I have to get an Axis2 based ws consumer working within WebMethods as a java service. I've implemented the ws consumer first in netbeans just to see if it works and thus i found that the minimal amount of jars I'll require are the following:
[ xmlschema-1.4.7.jar, apache-mime4j-core-0.7.2.jar,
axiom-api-1.2.13.jar, axiom-impl-1.2.13.jar, axis2-adb-1.6.2.jar,
axis2-kernel-1.6.2.jar, axis2-transport-http-1.6.2.jar,
axis2-transport-local-1.6.2.jar, commons-codec-1.3.jar,
commons-httpclient-3.1.jar, commons-logging-1.1.1.jar,
httpcore-4.0.jar, mail-1.4.jar, neethi-3.0.2.jar, wsdl4j-1.6.2.jar ]
I've uploaded these jar files under the IS/packages/{package_name}/code/jars folder. Whenever I try to execute the java service that would send the request and process the response I get the following exception:
java.lang.reflect.InvocationTargetException:
org.apache.axiom.om.OMFactory.getMetaFactory()Lorg/apache/axiom/om/OMMetaFactory;
From the IS error log file I found that the actual error message is as follows:
org.apache.axiom.om.OMFactory.getMetaFactory()Lorg/apache/axiom/om/OMMetaFactory;
Caused by: java.lang.reflect.InvocationTargetException: null Caused
by:
java.lang.NoSuchMethodError:org.apache.axiom.om.OMFactory.getMetaFactory()Lorg/apache/axiom/om/OMMetaFactory;
The platform is WebMethods 8.2 under Linux environment. The JDK version is 1.6.0_32 and the application server under WebMethods is Jetty.
Actually the solve of this problem was a bit more tricky. First of all I manually had to configure the manifest file of the package on the IS server to use the jars provided in the package abnd thus it wouldn't get in conflict with the Axis used by the IS itself. On the other hand I had to manually add the ClassLoader because WebMethods can't use META-INF based information from jar files as it seems. To solve this problem simply use:
System.setProperty("org.apache.axiom.om.OMMetaFactory", "org.apache.axiom.om.impl.llom.factory.OMLinkedListMetaFactory");
That solves all the problems.
Im following http://www.mkyong.com/spring/spring-quartz-scheduler-example/ to develop a job for my spring app... Im getting the following exception when im trying to run it.
Can anyone tell whats the resolution for this?
Exception in thread "Main Thread" java.lang.NoClassDefFoundError: weblogic/logging/LogEntryFormatter >
at java.lang.ClassLoader.findBootstrapClass(Native Method)
at java.lang.ClassLoader.findBootstrapClass0(ClassLoader.java:891)
at java.lang.ClassLoader.loadClass(ClassLoader.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at weblogic.logging.commons.LogImpl.<init>(LogImpl.java:14)
at weblogic.logging.commons.LogFactoryImpl.getInstance(LogFactoryImpl.java:21)
at weblogic.logging.commons.LogFactoryImpl.getInstance(LogFactoryImpl.java:18)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:145)
at org.springframework.context.support.AbstractRefreshableApplicationContext.<init>(AbstractRefreshableApplicationContext.java:70)
at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.<init>(AbstractRefreshableConfigApplicationContext.java:45)
at org.springframework.context.support.AbstractXmlApplicationContext.<init>(AbstractXmlApplicationContext.java:59)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:136)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:84)
at com.jobs.RunMeJob.main(RunMeJob.java:10)
Seems like you are using the weblogic common logging mechanism in your app...and missing some jars/classes in your WL classpath. Can you post your classpath?
Also, you might want to try SLF4J for logging (http://www.slf4j.org) which I find so much easier to use (as well as versatile, allowing you to use any underlying logging mechanism, such as popular log4j for example)
If you deployed quartz to your Weblogic domain's lib directory you need to ensure that all of quartz dependencies are also deployed to the same directory.
I solved a similar problem by deploying jcl-over-slf4j and slf4j-api.
I am working with a Web application written in cocoon framework (Java) and running on WAS 7.0.0.0.
When running on WAS 6.X.X.X everything works fine.
However, on WAS 7 during runtime I am receiving the following error:
java.lang.ClassCastException org.apache.xerces.jaxp.DocumentBuilderFactoryImpl incompatible with javax.xml.parsers.DocumentBuilderFactory
at javax.xml.parsers.DocumentBuilderFactory.newInstance
We suspect that this is a ClassLoader issue.
I have tried many steps to overcome this issue:
I have tried to add in the WAS Administration Console a new Custom properties:
Application servers -> Server Name -> Process definition -> Java Virtual Machine -> Custom properties
Name = javax.xml.parsers.DocumentBuilderFactory
Value = org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
But this did not resolve the problem!
I tried to change the WAS class loader order in the WAS Admin Console between parent first and parent last - both options did not resolve the issue.
Please let me know if you need additional information.
Because was7 must have these jars inbuilt. You need to remove these jars from your ear/war and then deploy. Multiple copies of the same jars are conflicting.
Regards,
I am trying to add metrics library to existing webservice on WAS 7. I am getting below error
Error 404: javax.servlet.UnavailableException: SRVE0203E: Servlet [AdminServlet]: com.yammer.metrics.reporting.AdminServlet was found, but is missing another required class. SRVE0206E: This error typically implies that the servlet was originally compiled with classes which cannot be located by the server. SRVE0187E: Check your class path to ensure that all classes required by the servlet are present.SRVE0210I: This problem can be debugged by recompiling the servlet using only the classes in the application's runtime class path SRVE0234I
What are the other run-time dependencies required for metrics-servlet-2.2.0?
I have metrics-core-2.2.0.jar and metrics-servlet-2.2.0.jar in my WEB-INF\lib folder.
Threads, ping and healthcheck servlets work fine.
I think your missing some more required jars, are you not using maven or gradle for dependency management
Please refer here to know all required jars that metrics-servlet-2.2.0.jar depends on. http://mvnrepository.com/artifact/com.yammer.metrics/metrics-servlets/3.0.0-BETA1
My suggestion is, it is always difficult to maintain dependencies without Maven/Gradle or any other build tools :).