I am getting this error in my application which is running on EMR
Here are few details about this error
It is not consistent. This error comes once in while (in two days or in a week also).
We have tried building JARs from Local /Jenkins/Maven but no luck. Still this errors appears.
Verified class in the JAR file and it is present at correct location.
It does not look like corrupted jars or class not present issue as this error is not consistent.
Here is the complete stack trace
java.lang.IllegalArgumentException: Cannot parse pattern '%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n'
at org.apache.logging.log4j.core.layout.PatternLayout$SerializerBuilder.build(PatternLayout.java:490)
at org.apache.logging.log4j.core.layout.PatternLayout.<init>(PatternLayout.java:140)
at org.apache.logging.log4j.core.layout.PatternLayout.<init>(PatternLayout.java:61)
at org.apache.logging.log4j.core.layout.PatternLayout$Builder.build(PatternLayout.java:770)
at org.apache.logging.log4j.core.config.AbstractConfiguration.setToDefault(AbstractConfiguration.java:715)
at org.apache.logging.log4j.core.config.DefaultConfiguration.<init>(DefaultConfiguration.java:47)
at org.apache.logging.log4j.core.LoggerContext.<init>(LoggerContext.java:95)
at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.createContext(ClassLoaderContextSelector.java:254)
at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218)
at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:136)
at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:123)
at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:117)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:150)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:47)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:196)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:599)
at com.company.search.tcp.rdf.jumper.driver.processclass.processMessages(processclass.java:110)
at com.company.search.ecp.tcp.jumper.driver.processclass.lambda$process$5dfe0a07$1(processclass.java:95)
at org.apache.spark.api.java.JavaRDDLike$$anonfun$foreachPartitionAsync$1.apply(JavaRDDLike.scala:741)
at org.apache.spark.api.java.JavaRDDLike$$anonfun$foreachPartitionAsync$1.apply(JavaRDDLike.scala:741)
at org.apache.spark.SparkContext$$anonfun$37.apply(SparkContext.scala:2212)
at org.apache.spark.SparkContext$$anonfun$37.apply(SparkContext.scala:2212)
at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:90)
at org.apache.spark.scheduler.Task.run(Task.scala:123)
at org.apache.spark.executor.Executor$TaskRunner$$anonfun$10.apply(Executor.scala:408)
at org.apache.spark.util.Utils$.tryWithSafeFinally(Utils.scala:1360)
at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:414)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: zip file closed
at java.util.zip.ZipFile.ensureOpen(ZipFile.java:690)
at java.util.zip.ZipFile.access$200(ZipFile.java:61)
at java.util.zip.ZipFile$ZipEntryIterator.hasNext(ZipFile.java:512)
at java.util.zip.ZipFile$ZipEntryIterator.hasMoreElements(ZipFile.java:507)
at java.util.jar.JarFile$JarEntryIterator.hasNext(JarFile.java:264)
at java.util.jar.JarFile$JarEntryIterator.hasMoreElements(JarFile.java:273)
at org.apache.logging.log4j.core.config.plugins.util.ResolverUtil.loadImplementationsInJar(ResolverUtil.java:347)
at org.apache.logging.log4j.core.config.plugins.util.ResolverUtil.findInPackage(ResolverUtil.java:233)
at org.apache.logging.log4j.core.config.plugins.util.PluginRegistry.loadFromPackage(PluginRegistry.java:225)
at org.apache.logging.log4j.core.config.plugins.util.PluginManager.collectPlugins(PluginManager.java:136)
at org.apache.logging.log4j.core.pattern.PatternParser.<init>(PatternParser.java:132)
at org.apache.logging.log4j.core.pattern.PatternParser.<init>(PatternParser.java:113)
at org.apache.logging.log4j.core.layout.PatternLayout.createPatternParser(PatternLayout.java:255)
at org.apache.logging.log4j.core.layout.PatternLayout$SerializerBuilder.build(PatternLayout.java:473)
... 29 more
we don't use the pattern mentioned in the error stack trace at all .
We use below in our code
name="OFF_File_appender"
fileName="$${sys:spark.yarn.app.container.log.dir}/log4j2.log"
filePattern="$$${sys:spark.yarn.app.container.log.dir}/log4j2.log.%d{yyyy-MM-dd-HH}"
>
<PatternLayout pattern="%d{ISO8601} %-5level %c{3}[%X{currentContext}] - [log4j2] %msg%n"/>
Related
In my project I use Log4j to process all logging. The config I use:
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="%d - %-5p %-10c - %m%n"/>
</Console>
<File name="file" fileName="logs/TAF_${sys:current_date}.log">
<PatternLayout>
<Pattern>%d{yyyy-mm-dd_HH:mm:ss.SSS} - %-5p %-10c - %m%n</Pattern>
</PatternLayout>
</File>
</Appenders>
<Loggers>
<Root level="trace">
<AppenderRef ref="file" level="DEBUG"/>
<AppenderRef ref="STDOUT" level="DEBUG"/>
</Root>
</Loggers>
The error I get:
2018-11-19 16:12:59,531 main ERROR FileManager (logs\TAF_${sys:current_date}.log) java.io.IOException: De syntaxis van de bestandsnaam, mapnaam of volumenaam is onjuist java.io.IOException: De syntaxis van de bestandsnaam, mapnaam of volumenaam is onjuist
at java.base/java.io.WinNTFileSystem.canonicalize0(Native Method)
at java.base/java.io.WinNTFileSystem.canonicalize(WinNTFileSystem.java:432)
at java.base/java.io.File.getCanonicalPath(File.java:618)
at java.base/java.io.File.getCanonicalFile(File.java:643)
at org.apache.logging.log4j.core.util.FileUtils.makeParentDirs(FileUtils.java:142)
at org.apache.logging.log4j.core.appender.FileManager$FileManagerFactory.createManager(FileManager.java:418)
at org.apache.logging.log4j.core.appender.FileManager$FileManagerFactory.createManager(FileManager.java:406)
at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:113)
at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:114)
at org.apache.logging.log4j.core.appender.FileManager.getFileManager(FileManager.java:180)
at org.apache.logging.log4j.core.appender.FileAppender$Builder.build(FileAppender.java:95)
at org.apache.logging.log4j.core.appender.FileAppender$Builder.build(FileAppender.java:51)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:123)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:959)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:899)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:891)
at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:514)
at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:238)
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:250)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:547)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:619)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:636)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:231)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:153)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:581)
at nl.*****.Apl.<clinit>(Apl.java:9)
2018-11-19 16:12:59,536 main ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.FileAppender for element File: java.lang.IllegalStateException: ManagerFactory [org.apache.logging.log4j.core.appender.FileManager$FileManagerFactory#1ffaf86] unable to create manager for [logs\TAF_${sys:current_date}.log] with data [org.apache.logging.log4j.core.appender.FileManager$FactoryData#6574a52c] java.lang.IllegalStateException: ManagerFactory [org.apache.logging.log4j.core.appender.FileManager$FileManagerFactory#1ffaf86] unable to create manager for [logs\TAF_${sys:current_date}.log] with data [org.apache.logging.log4j.core.appender.FileManager$FactoryData#6574a52c]
at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:115)
at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:114)
at org.apache.logging.log4j.core.appender.FileManager.getFileManager(FileManager.java:180)
at org.apache.logging.log4j.core.appender.FileAppender$Builder.build(FileAppender.java:95)
at org.apache.logging.log4j.core.appender.FileAppender$Builder.build(FileAppender.java:51)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:123)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:959)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:899)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:891)
at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:514)
at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:238)
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:250)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:547)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:619)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:636)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:231)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:153)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:581)
at nl.*****.Apl.<clinit>(Apl.java:9)
2018-11-19 16:12:59,541 main ERROR Unable to invoke factory method in class org.apache.logging.log4j.core.appender.FileAppender for element File: java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.FileAppender java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.FileAppender
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.findFactoryMethod(PluginBuilder.java:235)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:135)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:959)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:899)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:891)
at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:514)
at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:238)
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:250)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:547)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:619)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:636)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:231)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:153)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:581)
at nl.******.Apl.<clinit>(Apl.java:9)
2018-11-19 16:12:59,543 main ERROR Null object returned for File in Appenders.
2018-11-19 16:12:59,550 main ERROR Unable to locate appender "file" for logger config "root"
The first error is in dutch, which translates to: "The filename, directory name, or volume label syntax is incorrect".
This Log4J config file is used under an Ubuntu environment and works perfectly. Now I have added a Win10 machine to the pool, but I receive this error.
What am I doing wrong?
I tried to make the path absolute, "c:/Project/logs/TAF_${sys:current_date}.log", but it did not solve the problem. Every user has read/write access to the logs directory.
Other stuff I tried:
Log4j logfile error FileNotFoundException
#edit:
For what I can see, it looks like log4j is trying to create a file named "TAF_${sys:current_date}.log". That ofcourse doesn't work, because { and } are not valid for filenames. When the "_${sys:current_date}" is removed, I am able to create the log file. How am I able to use the expression again, to add the current date/time?
#edit2:Found the answer here. I needed to set the system property "current_date" in the code.
I have a J2EE web application with logback as the logging function
and use Tomcat 7 as the server.
I am using the logback ConsoleAppender right now, so I can go to
/var/log/tomcat7/catalina.out to check the log.
Right now, I want to move the log into a file. I will use a RollingFileAppender to save the log.
I DO NOT want to use a absolute path like:
<appender name="FILE" class="xxx.RollingFileAppender">
<file>/var/log/testFile1.log</file>
<encoder>
<pattern>%msg%n</pattern>
</encoder>
</appender>
I DO NOT want to use a system environment variable, either, like:
<appender name="FILE" class="xxx.RollingFileAppender">
<file>{LOG_LOCATION}\testFile2.log</file>
<encoder>
<pattern>%msg%n</pattern>
</encoder>
</appender>
If I only write the name of log file in the tag, like:
<appender name="FILE" class="xxx.RollingFileAppender">
<file>testFile3.log</file>
<encoder>
<pattern>%msg%n</pattern>
</encoder>
</appender>
I will receive the error:
21:29:45,265 |-ERROR in ch.qos.logback.core.FileAppender[TEST_LOG] - openFile(testFile3.log,true) call failed. java.io.FileNotFoundException: testFile3.log (Permission denied)
at java.io.FileNotFoundException: testFile3.log (Permission denied)
at at java.io.FileOutputStream.open(Native Method)
at at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
at at ch.qos.logback.core.recovery.ResilientFileOutputStream.<init>(ResilientFileOutputStream.java:28)
at at ch.qos.logback.core.FileAppender.openFile(FileAppender.java:149)
at at ch.qos.logback.core.FileAppender.start(FileAppender.java:108)
at at ch.qos.logback.core.joran.action.AppenderAction.end(AppenderAction.java:96)
at at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:317)
at at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:196)
at at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:182)
at at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62)
at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:149)
at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:135)
at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:99)
at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:49)
at at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75)
at at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:148)
at at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:85)
at at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
at at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128)
at at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:107)
at at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:295)
at at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269)
at at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:156)
at at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
at at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:657)
at at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:282)
at at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
at at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
at at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
at at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
at at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
at at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:958)
at at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1599)
at at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at at java.lang.Thread.run(Thread.java:744)
Can I create a log file only with its name?
And if so, where is the default location for the logback log file in Tomcat 7 server?
You want a relative path. Specify <file>./testFile3.log</file>
Check where this gets created by running once.
Note that this could be relative to the location used for launching the application.
I'm using log4j2 (2.0.2) in a servlet 3.0 web application, running in Tomcat 8.0.12. I'm trying to use the weblookup to get the web app context path to use as part of the log file name. (We run the same war file under several different contexts using properties to configure it).
The log4j2.xml file includes
<RollingFile name="Web" fileName="/srv/dnsnet/logs/web-${web:contextPath}.logfile" filePattern="/srv/dnsnet/logs/web-${web:contextPath}-%d{yyyy-MM-dd}-%i.log.gz" append="true" immediateFlush="false">
<PatternLayout>
<Pattern>%d %-5p [%25.25t] %40.40c{3.} %15X{sysid} %m%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy />
</Policies>
<DefaultRolloverStrategy max="8"/>
</RollingFile>
But the web:contextPath does not get resolved. I have got log4j-web-2.0.2.jar in my web app. I added some messages to the WebLookup class, and the problem is that the external context of the LoggerContext is null.
So I tried to see where the LoggerContext is created. The stack trace when the LoggerContext constructor is called is
at org.apache.logging.log4j.core.LoggerContext.<init>(LoggerContext.java:114)
at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218)
at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:113)
at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:80)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:82)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:37)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:269)
at org.apache.logging.log4j.jcl.LogFactoryImpl$PrivateManager.getContext(LogFactoryImpl.java:108)
at org.apache.logging.log4j.jcl.LogFactoryImpl.getLoggersMap(LogFactoryImpl.java:52)
at org.apache.logging.log4j.jcl.LogFactoryImpl.getInstance(LogFactoryImpl.java:43)
at org.apache.logging.log4j.jcl.LogFactoryImpl.getInstance(LogFactoryImpl.java:75)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:685)
at org.apache.myfaces.webapp.AbstractMyFacesListener.<clinit>(AbstractMyFacesListener.java:34)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at java.lang.Class.newInstance(Class.java:433)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:151)
at org.apache.catalina.core.ApplicationContext.addListener(ApplicationContext.java:1231)
at org.apache.catalina.core.ApplicationContextFacade.addListener(ApplicationContextFacade.java:647)
at org.apache.jasper.servlet.JasperInitializer.onStartup(JasperInitializer.java:110)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5164)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:581)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1686)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745
But the ClassLoaderContextSelector always passes null for the external context. So it looks as though I'm missing something.
Can anyone suggest what I'm doing wrong, or missing? Do I have to specify a different ContextSelector?
You may have found a bug in log4j. I suspect it is the combination of Commons Logging and the WebLookup that does not work. Can you verify if this is the case (check if the WebLookup works if your application uses the log4j 2 API instead of Commons Logging) and file a bug report in the log4j2 Jira issue tracker?
I request a test link https://terran.gamebox.com/facebook/issueOrder.jhtml?amount=5&gameId=1&serverId=1&role=role
I can see the message in page
but the exception did not show in catalina.out
This is my configure file
<bean id="exceptionResolver" class="com.gamebox.HandlerException">
HandlerException implements HandlerExceptionResolver
I must point that I can get the other controller's exception such as null pointer exception
I guess it's a spring internal exception, but I need capture all exception in catalina.out file.
I create a #Service dependence in a #Controller, then delete the #Service's class file.
When I started the tomcat, everything is OK, I request this controller, I got the exception message, but the catalina.out show nothing. The tomcat ran in Run mode.
I paste the response message, because this mvc's action will fix next day with this bug, but I will trace nothing in my platform when I use a ajax with mvc in future if it doesn't show in catalina.out and I will be defficult to find nothing.
I am sure it involved transactionManager
java.lang.ClassNotFoundException: com.gamebox.service.FacebookPayOrderService
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
java.lang.Class.getDeclaredFields0(Native Method)
java.lang.Class.privateGetDeclaredFields(Class.java:2300)
java.lang.Class.getDeclaredFields(Class.java:1745)
org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:374)
org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(PersistenceAnnotationBeanPostProcessor.java:322)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:846)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:498)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1117)
org.springframework.web.method.HandlerMethod.createWithResolvedBean(HandlerMethod.java:220)
org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:240)
org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:56)
org.springframework.web.servlet.handler.AbstractHandlerMapping.getHandler(AbstractHandlerMapping.java:298)
org.springframework.web.servlet.DispatcherServlet.getHandler(DispatcherServlet.java:1091)
org.springframework.web.servlet.DispatcherServlet.getHandler(DispatcherServlet.java:1076)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:896)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
com.planetj.servlet.filter.compression.CompressingFilter.doFilter(CompressingFilter.java:270)
com.gamebox.filter.SiteStatusFilter.doFilterInternal(SiteStatusFilter.java:51)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
All system out/error will go to catalina.out by default. Don't use System.out.println, use a logging API and configure your logger to write to the console.
If you are using something like logback, in your application just consider it to write to console:
http://logback.qos.ch/manual/configuration.html
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="debug">
<appender-ref ref="STDOUT" />
</root>
</configuration>
to tame spring messages, you can remove commons-logging and use slf4j to route spring into the same logging. See this article
http://www.codingpedia.org/ama/how-to-log-in-spring-with-slf4j-and-logback/
That should help improve visibility and give you your goal of getting everything into catalina.out.
Finally, I find the solution and I am very satisfy.
Only one changed, edit the TOMCAT_HOME/conf/logging.properties file then locate this line:
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.FileHandler
Append , java.util.logging.ConsoleHandler to this line.
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
All exceptions will be write to catalina.out file.^_^
I'm trying to setup log4j on my web app. Web server is Tomcat 7.
I'm getting the following exception:
log4j:ERROR Could not instantiate class [org.apache.log4j.varia.LevelMatchFilter ].
java.lang.ClassNotFoundException: org.apache.log4j.varia.LevelMatchFilter
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at org.apache.log4j.helpers.Loader.loadClass(Loader.java:198)
at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:326)
at org.apache.log4j.PropertyConfigurator.parseAppenderFilters(PropertyConfigurator.java:881)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:812)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:735)
at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:615)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:502)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:547)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:483)
at org.apache.log4j.LogManager.<clinit>(LogManager.java:127)
at org.apache.log4j.Logger.getLogger(Logger.java:104)
at org.apache.commons.logging.impl.Log4JLogger.getLogger(Log4JLogger.java:262)
at org.apache.commons.logging.impl.Log4JLogger.<init>(Log4JLogger.java:108)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.apache.commons.logging.impl.LogFactoryImpl.createLogFromClass(LogFactoryImpl.java:1025)
at org.apache.commons.logging.impl.LogFactoryImpl.discoverLogImplementation(LogFactoryImpl.java:844)
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:541)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:292)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:269)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:657)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:269)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:649)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1585)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
I put log4j.properties in the WEB-INF/classes directory as many SO users suggested in other answers to other questions.
I put slf4j-api-1.7.5.jar, slf4j-log4j12-1.7.5.jar, log4j-1.2.16.jar in the WEB-INF/lib directory.
My properties file is the following:
log4j.rootLogger = INFO,infoAppender,errAppender
log4j.appender.infoAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.infoAppender.File= D://logs//info//info.log
log4j.appender.infoAppender.DatePattern='_'dd-MM-yyyy
log4j.appender.infoAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.infoAppender.layout.conversionPattern=%d{dd-MM-yyyy HH:mm:ss} %5p %m%n
log4j.appender.infoAppender.filter.infoFilter=org.apache.log4j.varia.LevelMatchFilter
log4j.appender.infoAppender.filter.infoFilter.LevelToMatch=INFO
log4j.appender.infoAppender.filter.infoFilter.AcceptOnMatch=true
log4j.appender.infoAppender.filter.2=org.apache.log4j.varia.DenyAllFilter
log4j.appender.errAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.errAppender.File= D://logs//error/err.log
log4j.appender.errAppender.DatePattern='_'dd-MM-yyyy
log4j.appender.errAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.errAppender.layout.conversionPattern=%d{dd-MM-yyyy HH:mm:ss} %5p %m%n
log4j.appender.errAppender.filter.errFilter=org.apache.log4j.varia.LevelMatchFilter
log4j.appender.errAppender.filter.errFilter.LevelToMatch=ERROR
log4j.appender.errAppender.filter.errFilter.AcceptOnMatch=true
log4j.appender.errAppender.filter.2=org.apache.log4j.varia.DenyAllFilter
I personally think that problem is in classpath-like issues but all .jar files and .properties file are in the correct place. At least, it's correct according to many related posts that I found.
i met this question too, finally i find the root lies in log4j.properties file. you have extra space in your properties file. just like your exception points out: log4j:ERROR Could not instantiate class [org.apache.log4j.varia.LevelMatchFilter ]
no extra space expected after LevelMatchFilter.
Here is mine
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.filter.a=org.apache.log4j.varia.LevelMatchFilter
log4j.appender.stdout.filter.a.LevelToMatch=INFO
log4j.appender.stdout.filter.b=org.apache.log4j.varia.DenyAllFilter
OK, I found solution. Use log4j.xml instead of log4j.properties.
Hm, looks strange. I know that only xml supports filters. But I also read in some SO answer that log4j.properties file supports filters for 1.2.16 version. Anyway I recommend use xml.