weblogic log4j Rolling appender - log4j

log4j:ERROR Could not create an Appender. Reported error follows.
java.lang.ClassNotFoundException: org.apache.log4j.rolling.RollingFileAppender
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:297)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:270)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:64)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:179)
at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:52)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.apache.log4j.helpers.Loader.loadClass(Loader.java:198)
at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:247)
at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:176)
at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:191)
at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:284)
at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:176)
at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:191)
at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:523)
at org.apache.log4j.xml.DOMConfigurator.parseCategory(DOMConfigurator.java:436)
at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:999)
at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:867)
at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:773)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:483)
at org.apache.log4j.LogManager.<clinit>(LogManager.java:127)
Please help me in solving this issue.
I have copied log4j.xml in the weblogic server domain but when I started server I get this exception on the console.

Looks like you're missing apache-log4j-extras-1.1.jar in your classpath; it is required in order to use the RollingFileAppender.
http://www.apache.org/dyn/closer.cgi/logging/log4j/extras/1.2.17/apache-log4j-extras-1.2.17-bin.tar.gz

Related

Karaf bundle using ch.qos.logback , log4j org/apache/logging/log4j/util/ReflectionUtil

I have an osgi 6.0.0 project which uses logback and slf4j.
Currently I am implementing a bundle which depends on an external jar which uses
org.apache.logging.log4j
during the command line execution the bundle my karaf console freezes by displaying this error :
Exception in thread "Karaf local console user karaf" java.lang.NoClassDefFoundError: org/apache/logging/log4j/util/ReflectionUtil
at org.apache.logging.log4j.core.impl.ThrowableProxy.(ThrowableProxy.java:145)
at org.apache.logging.log4j.core.impl.ThrowableProxy.(ThrowableProxy.java:125)
at org.apache.logging.log4j.core.impl.MutableLogEvent.getThrownProxy(MutableLogEvent.java:338)
at org.ops4j.pax.logging.log4j2.internal.PaxLoggingEventImpl.getThrowableStrRep(PaxLoggingEventImpl.java:76)
at org.apache.karaf.log.core.internal.KarafLogEvent.(KarafLogEvent.java:45)
at org.apache.karaf.log.core.internal.LogServiceImpl.doAppend(LogServiceImpl.java:177)
at org.ops4j.pax.logging.log4j2.internal.PaxAppenderProxy.doAppend(PaxAppenderProxy.java:65)
at org.ops4j.pax.logging.log4j2.appender.PaxOsgiAppender.append(PaxOsgiAppender.java:82)
at org.apache.logging.log4j.core.config.AppenderControl.tryCallAppender(AppenderControl.java:156)
at org.apache.logging.log4j.core.config.AppenderControl.callAppender0(AppenderControl.java:129)
at org.apache.logging.log4j.core.config.AppenderControl.callAppenderPreventRecursion(AppenderControl.java:120)
at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:84)
at org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:448)
at org.apache.logging.log4j.core.config.LoggerConfig.processLogEvent(LoggerConfig.java:433)
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:417)
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:403)
at org.apache.logging.log4j.core.config.AwaitCompletionReliabilityStrategy.log(AwaitCompletionReliabilityStrategy.java:63)
at org.apache.logging.log4j.core.Logger.logMessage(Logger.java:146)
at org.ops4j.pax.logging.log4j2.internal.PaxLoggerImpl.doLog0(PaxLoggerImpl.java:151)
at org.ops4j.pax.logging.log4j2.internal.PaxLoggerImpl.doLog(PaxLoggerImpl.java:144)
at org.ops4j.pax.logging.log4j2.internal.PaxLoggerImpl.error(PaxLoggerImpl.java:192)
at org.ops4j.pax.logging.internal.TrackingLogger.error(TrackingLogger.java:96)
at org.ops4j.pax.logging.slf4j.Slf4jLogger.error(Slf4jLogger.java:953)
at org.apache.karaf.shell.support.ShellUtil.logException(ShellUtil.java:152)
at org.apache.karaf.shell.impl.console.ConsoleSessionImpl.doExecute(ConsoleSessionImpl.java:474)
at org.apache.karaf.shell.impl.console.ConsoleSessionImpl.run(ConsoleSessionImpl.java:407)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.util.ReflectionUtil not found by org.apache.logging.log4j.api [112]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1639)
at org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:80)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2053)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.apache.felix.framework.BundleWiringImpl.getClassByDelegation(BundleWiringImpl.java:1414)
at org.apache.felix.framework.BundleWiringImpl.searchImports(BundleWiringImpl.java:1660)
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1590)
at org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:80)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2053)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 27 more
I found the solution, the class org/apache/logging/log4j/util/ReflectionUtil no longer exists as of 2.9.0.
i just have to use a version lower than this one

Getting this error when I try to run jar file that I created : Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Appender

I am getting an exception when I try to run the jar file that I created for my java application. I am using log4j for logging purpose and I created a custom log that records per cron job transactions.
Then I have written a shell script where I call the jar file. I have put the properties file outside the jar file.
I am running the jar file through a shell script. The command I use is
java -jar app.jar $1
The java application has 2 properties files
1) app.properties
2) sublog4j.properties
The sublog4j properties file has data like this:
log4j.appender.log=package.CustomFileAppender
log4j.appender.log.File=/serverpath/error.log
I have a gut feeling that I am getting error because of package.CustomFileAppender. It is a java file in app.jar but I don't know how to create a custom appender and use it in the external properties file.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Appender
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2615)
at java.lang.Class.getMethod0(Class.java:2856)
at java.lang.Class.getMethod(Class.java:1668)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Appender
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
I was getting this error because I was not building the jar file correctly. So what I did is I created an executable jar file and also copied source code when I created the jar. This is how the issue got resolved.

Configuring slf4j and log4j correctly on WebSphere 8.5

WHat's the correct way to configure slf4j + log4j on WebSphere 8.5.
My approach was:
* Include slf4j-api in WEB-INF\lib of the war files of the applications
* Include the binding ja slf4j-log4j in WebSphere lib
* Include log4j.xml in JVM classpath external to the war file.
Only problem is that it doesn't work. It fails with an error on initializing.
Guess my approach is wrong?
Thanks for any assistance!
Here's the stack trace. Note that slfj-api is found in WEB-INF\lib of the WAR file:
Caused by: java.lang.NoClassDefFoundError: org.slf4j.spi.LoggerFactoryBinder
at java.lang.ClassLoader.defineClassImpl(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:295)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:154)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:711)
at java.net.URLClassLoader.access$400(URLClassLoader.java:92)
at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:1159)
at java.security.AccessController.doPrivileged(AccessController.java:314)
at java.net.URLClassLoader.findClass(URLClassLoader.java:594)
at com.ibm.ws.bootstrap.ExtClassLoader.findClass(ExtClassLoader.java:204)
at com.ibm.ws.bootstrap.ExtClassLoader.loadClass(ExtClassLoader.java:116)
at java.lang.ClassLoader.loadClass(ClassLoader.java:690)
at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:62)
at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:58)
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:616)
at java.lang.ClassLoader.loadClass(ClassLoader.java:690)
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:584)
at java.lang.ClassLoader.loadClass(ClassLoader.java:690)
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:584)
at java.lang.ClassLoader.loadClass(ClassLoader.java:690)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:121)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:111)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:268)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:241)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:254)
at no.klp.minside.handler.SoapLoggingHandler.<clinit>(SoapLoggingHandler.java:28)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:236)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:80)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:57)`enter code here`
at java.lang.reflect.Constructor.newInstance(Constructor.java:539)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:110)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:280)
... 113 more
Caused by: java.lang.ClassNotFoundException: org.slf4j.spi.LoggerFactoryBinder
at java.net.URLClassLoader.findClass(URLClassLoader.java:599)
at com.ibm.ws.bootstrap.ExtClassLoader.findClass(ExtClassLoader.java:204)
at com.ibm.ws.bootstrap.ExtClassLoader.loadClass(ExtClassLoader.java:116)
at java.lang.ClassLoader.loadClass(ClassLoader.java:690)
... 147 more

loging to hazelcast management center is throwing NullPointerException

When I log in to Hazelcast management center I get the following exception. Not sure what exactly is causing this issue.
The Management Center is deployed in Weblogic 12c
Hazelcast version: 3.1.3
java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor534.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.java:282)
at org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.java:226)
at org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.java:177)
at com.hazelcast.webmonitor.service.DataService.invokeMethod(DataService.java:108)
at com.hazelcast.webmonitor.service.DataService.getResponse(DataService.java:86)
at com.hazelcast.webmonitor.servlet.MainServlet.doGet(MainServlet.java:80)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:844)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:242)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:216)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:132)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:338)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:221)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3284)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.__run(WebAppServletContext.java:3254)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2163)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2089)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2074)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1513)
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Caused by: java.lang.NullPointerException
at java.util.LinkedList$ListItr.next(LinkedList.java:891)
at java.util.SubList$1.next(AbstractList.java:707)
at java.util.AbstractCollection.toArray(AbstractCollection.java:141)
at java.util.Collections.sort(Collections.java:216)
at com.hazelcast.webmonitor.service.WarningLogsManager.getSystemWarnings(WarningLogsManager.java:96)
at com.hazelcast.webmonitor.service.DataService.showSystemWarning(DataService.java:717)
... 29 more
So finally this issue got resolved . I added the following preferred packages list to my weblogic.xml file because it was suggested by CAT tool .
<wls:package-name>javax.activation.*</wls:package-name>
<wls:package-name>javax.mail.*</wls:package-name>
<wls:package-name>javax.mail.event.*</wls:package-name>
<wls:package-name>javax.mail.internet.*</wls:package-name>
<wls:package-name>javax.mail.search.*</wls:package-name>
<wls:package-name>javax.mail.util.*</wls:package-name>
<wls:package-name>org.apache.commons.*</wls:package-name>
Removing those fixed the issue.
I just checked the code. The exception doesn't make any sense. Which JVM are you using. And perhaps it is smarter to run on a more lightweight container like jetty,tomcat etc.

wsdl2java exception

java org.apache.axis2.wsdl.WSDL2Java -s -p studs.exchange -uri https://api.betfair.com/exchange/v5/BFExchangeService.wsdl
Retrieving document at 'https://api.betfair.com/exchange/v5/BFExchangeService.wsdl'.
log4j:WARN No appenders could be found for logger (org.apache.axis2.description.WSDL11ToAllAxisServicesBuilder).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.apache.axis2.wsdl.codegen.CodeGenerationException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:271)
at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:35)
at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:24)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension.engage(SimpleDBExtension.java:53)
at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:224)
... 2 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension.engage(SimpleDBExtension.java:50)
... 3 more
Caused by: java.lang.NoSuchMethodError: org.apache.ws.commons.schema.XmlSchema.getTypeByName(Ljava/lang/String;)Lorg/apache/ws/commons/schema/XmlSchemaType;
at org.apache.axis2.schema.SchemaCompiler.isComponetExists(SchemaCompiler.java:2728)
at org.apache.axis2.schema.SchemaCompiler.getParentSchemaFromIncludes(SchemaCompiler.java:2670)
at org.apache.axis2.schema.SchemaCompiler.getParentSchemaFromIncludes(SchemaCompiler.java:2704)
at org.apache.axis2.schema.SchemaCompiler.getParentSchema(SchemaCompiler.java:2644)
at org.apache.axis2.schema.SchemaCompiler.processElement(SchemaCompiler.java:758)
at org.apache.axis2.schema.SchemaCompiler.processElement(SchemaCompiler.java:552)
at org.apache.axis2.schema.SchemaCompiler.process(SchemaCompiler.java:1991)
at org.apache.axis2.schema.SchemaCompiler.processParticle(SchemaCompiler.java:1874)
at org.apache.axis2.schema.SchemaCompiler.processComplexType(SchemaCompiler.java:1081)
at org.apache.axis2.schema.SchemaCompiler.processAnonymousComplexSchemaType(SchemaCompiler.java:980)
at org.apache.axis2.schema.SchemaCompiler.processSchema(SchemaCompiler.java:934)
at org.apache.axis2.schema.SchemaCompiler.processElement(SchemaCompiler.java:592)
at org.apache.axis2.schema.SchemaCompiler.processElement(SchemaCompiler.java:563)
at org.apache.axis2.schema.SchemaCompiler.compile(SchemaCompiler.java:370)
at org.apache.axis2.schema.SchemaCompiler.compile(SchemaCompiler.java:280)
at org.apache.axis2.schema.ExtensionUtility.invoke(ExtensionUtility.java:103)
... 8 more
whats is happening here? what about log4j
Don't worry about the Log4j stuff for the moment. That's simply telling you that the Log4j framework can't find its configuration. It'll run ok without it.
The important line is
Caused by: java.lang.NoSuchMethodError: org.apache.ws.commons.schema.XmlSchema.getTypeByName(Ljava/lang/String;)Lorg/apache/ws/commons/schema/XmlSchemaType;
which says to me that you have some library mismatch. You have some library in your classpath that doesn't match Axis' requirements (most probably an old version of the library). Check Axis' dependencies versus what you're running with (your JVM version and the libraries on your classpath).

Resources