[英]java.io.FileNotFoundException: /target/test.log
Greetings all I am using Apache Camel and Apache CXF in this example:大家好,我在这个例子中使用了 Apache Camel 和 Apache CXF:
http://camel.apache.org/better-jms-transport-for-cxf-webservice-using-apache-camel.data/cxfcamelexample.zip http://camel.apache.org/better-jms-transport-for-cxf-webservice-using-apache-camel.data/cxfcamelexample.zip
I followed the readme and when tried to run the client & server classes i got this exception:我遵循自述文件,当尝试运行客户端和服务器类时,出现此异常:
log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: /target/test.log (No such file or directory)
at java.io.FileOutputStream.openAppend(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:177)
at java.io.FileOutputStream.<init>(FileOutputStream.java:102)
at org.apache.log4j.FileAppender.setFile(FileAppender.java:289)
at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:163)
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:256)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:132)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:96)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:654)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:612)
at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:509)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:415)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:441)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:470)
at org.apache.log4j.LogManager.<clinit>(LogManager.java:122)
at org.apache.log4j.Logger.getLogger(Logger.java:104)
at org.apache.commons.logging.impl.Log4JLogger.getLogger(Log4JLogger.java:283)
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:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.apache.commons.logging.impl.LogFactoryImpl.createLogFromClass(LogFactoryImpl.java:1040)
at org.apache.commons.logging.impl.LogFactoryImpl.discoverLogImplementation(LogFactoryImpl.java:838)
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:601)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:333)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:307)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:645)
at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:146)
at org.springframework.context.support.AbstractRefreshableApplicationContext.<init>(AbstractRefreshableApplicationContext.java:84)
at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.<init>(AbstractRefreshableConfigApplicationContext.java:59)
at org.springframework.context.support.AbstractXmlApplicationContext.<init>(AbstractXmlApplicationContext.java:58)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:136)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
at com.example.customerservice.impl.CustomerServiceClient.main(CustomerServiceClient.java:34)
so any ideas, how to solve this exception ?所以有什么想法,如何解决这个异常?
Do you have a /target directory at root?根目录下有 /target 目录吗? If not, try creating one.
如果没有,请尝试创建一个。 The logger is expecting to be able to create a file in that directory, and if it doesn't exist there's a problem.
记录器希望能够在该目录中创建一个文件,如果它不存在,则存在问题。
If you are starting up a broker, it is possible to have that issue.如果您正在启动经纪人,则可能会遇到该问题。
I found a bug report in ActiveMQ bug tracking site related with this issue.我在 ActiveMQ 错误跟踪站点中发现了与此问题相关的错误报告。
Activeio test package inclusion and logging properties: https://issues.apache.org/jira/browse/AMQ-1132 Activeio 测试包包含和日志属性: https ://issues.apache.org/jira/browse/AMQ-1132
I excluded org.apache.activemq:activeio-core to remove test-jar from dependencies and resolved this issue.我排除了org.apache.activemq:activeio-core以从依赖项中删除test-jar并解决了这个问题。 That might help you too.
这也可能对你有帮助。
Hey I had this issue again, and I would like to reply with what I did which is exactly what @lemiorhan suggested.嘿,我又遇到了这个问题,我想回答我所做的,这正是 @lemiorhan 建议的。 I'll improve upon his answer by giving sample code.
我将通过提供示例代码来改进他的回答。 Simply add this after tag in org.apache.activemq dependency.
只需在 org.apache.activemq 依赖项中的标签后添加这个。
<exclusions>
<exclusion>
<groupId>org.apache.activemq</groupId>
<artifactId>activeio-core</artifactId>
</exclusion>
</exclusions>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.