没有设置属性路径 - 查看类路径

时间:2011-08-05 14:46:09

标签: java spring maven properties

无论出于何种原因,我的项目已经决定它找不到我的transaction.properties文件。它位于: src/main/resource

然而,它会在target/classes/

中查看

该文件还存在错误(见下文)

这些似乎都源于我无法访问的代码的init中的整体,这总是很有趣。

任何人都知道如何克服整体:

Using init file: /target/classes/transactions.properties
com.atomikos.icatch.SysException: Error in init: Error during checkpointing
    at com.atomikos.icatch.imp.TransactionServiceImp.init(TransactionServiceImp.java:728)

编辑:

错误主要指向atomikos路径。我会说实话,我完全不知道幕后发生了什么。它相当融化。这两个文件是相同的,所以它使用哪个文件并不重要,但我可以查看第一个错误行参考。

 public synchronized void init ( Properties properties ) throws SysException
{
    Stack errors = new Stack ();
    this.properties_ = properties;

    try {
        recoverymanager_.init ();
    } catch ( LogException le ) {
        errors.push ( le );
        throw new SysException ( "Error in init: " + le.getMessage (),
                errors );
    }
    recoverCoordinators ();

    //initialized is now set in recover()
    //initialized_ = true;

    shuttingDown_ = false;
    control_ = new LogControlImp ( this );
    // call recovery already, to make sure that the
    // RMI participants can start inquiring and replay

    recover ();
    notifyListeners ( true, false );
}

完整错误打印输出:

    Using init file: /target/classes/transactions.properties
com.atomikos.icatch.SysException: Error in init: Error during checkpointing
    at com.atomikos.icatch.imp.TransactionServiceImp.init(TransactionServiceImp.java:728)
    at com.atomikos.icatch.imp.BaseTransactionManager.init(BaseTransactionManager.java:217)
    at com.atomikos.icatch.standalone.StandAloneTransactionManager.init(StandAloneTransactionManager.java:104)
    at com.atomikos.icatch.standalone.UserTransactionServiceImp.init(UserTransactionServiceImp.java:307)
    at com.atomikos.icatch.config.UserTransactionServiceImp.init(UserTransactionServiceImp.java:413)
    at com.atomikos.icatch.jta.UserTransactionManager.checkSetup(UserTransactionManager.java:90)
    at com.atomikos.icatch.jta.UserTransactionManager.init(UserTransactionManager.java:140)
    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.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1544)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1485)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
    at com.citi.eq.mo.dcc.server.Main.main(Main.java:32)
Nested exception is: 
com.atomikos.persistence.LogException: Error during checkpointing
    at com.atomikos.persistence.imp.FileLogStream.writeCheckpoint(FileLogStream.java:229)
    at com.atomikos.persistence.imp.StreamObjectLog.init(StreamObjectLog.java:185)
    at com.atomikos.persistence.imp.StateRecoveryManagerImp.init(StateRecoveryManagerImp.java:71)
    at com.atomikos.icatch.imp.TransactionServiceImp.init(TransactionServiceImp.java:725)
    at com.atomikos.icatch.imp.BaseTransactionManager.init(BaseTransactionManager.java:217)
    at com.atomikos.icatch.standalone.StandAloneTransactionManager.init(StandAloneTransactionManager.java:104)
    at com.atomikos.icatch.standalone.UserTransactionServiceImp.init(UserTransactionServiceImp.java:307)
    at com.atomikos.icatch.config.UserTransactionServiceImp.init(UserTransactionServiceImp.java:413)
    at com.atomikos.icatch.jta.UserTransactionManager.checkSetup(UserTransactionManager.java:90)
    at com.atomikos.icatch.jta.UserTransactionManager.init(UserTransactionManager.java:140)
    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.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1544)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1485)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
    at com.citi.eq.mo.dcc.server.Main.main(Main.java:32)
08/05/2011 14:55:59.998 [main] [] [INFO ] [o.s.b.f.s.DefaultListableBeanFactory] Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@164dbd5: defining beans [gfiPropertyConfigurerCommon,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,ZtsListenerContainer,ztsMessageListener,dccMessageHandler,dccToRioPublisher,rioJmsTemplate,dccMessageTransformer,ztsFixtoRioTransformer,dateManager,ztsDropCopyConverterContextFactory,ZtsBlockListenerContainer,ztsblockdropCopyConverterContextFactory,ZasListenerContainer,zasMessageListener,zastoRIOMessageTransformer,zasDropCopyConverterContextFactory,ztsToDccJndiTemplate,ztsQcf,ztsBlockToDccJndiTemplate,ztsBlockQcf,zasToDccJndiTemplate,zasQcf,rioJndiTemplate,rioTcf,rioDestinationResolver,URO.ZTSTRADES.1_Producer,mbeanServer,jmxExporter,rules-execution-server-engine,rio-object,trade-validator-context,trade-validator,validation-rules-helper,javaxTransactionManager,javaxUserTransaction,springPlatformTransactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,org.springframework.scheduling.annotation.internalAsyncAnnotationProcessor,org.springframework.scheduling.annotation.internalScheduledAnnotationProcessor]; root of factory hierarchy
08/05/2011 14:56:00.013 [main] [] [INFO ] [o.s.jmx.export.MBeanExporter] Unregistering JMX-exposed beans on shutdown
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'javaxTransactionManager' defined in class path resource [eq-mo-dcc-server-context.xml]: Invocation of init method failed; nested exception is com.atomikos.icatch.SysException: Error in init(): Error in init: Error during checkpointing
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
    at com.citi.eq.mo.dcc.server.Main.main(Main.java:32)
Caused by: com.atomikos.icatch.SysException: Error in init(): Error in init: Error during checkpointing
    at com.atomikos.icatch.standalone.UserTransactionServiceImp.init(UserTransactionServiceImp.java:374)
    at com.atomikos.icatch.config.UserTransactionServiceImp.init(UserTransactionServiceImp.java:413)
    at com.atomikos.icatch.jta.UserTransactionManager.checkSetup(UserTransactionManager.java:90)
    at com.atomikos.icatch.jta.UserTransactionManager.init(UserTransactionManager.java:140)
    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.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1544)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1485)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
    ... 12 more
Caused by: com.atomikos.icatch.SysException: Error in init: Error during checkpointing
    at com.atomikos.icatch.imp.TransactionServiceImp.init(TransactionServiceImp.java:728)
    at com.atomikos.icatch.imp.BaseTransactionManager.init(BaseTransactionManager.java:217)
    at com.atomikos.icatch.standalone.StandAloneTransactionManager.init(StandAloneTransactionManager.java:104)
    at com.atomikos.icatch.standalone.UserTransactionServiceImp.init(UserTransactionServiceImp.java:307)
    ... 22 more

4 个答案:

答案 0 :(得分:1)

你正在使用Maven吗?当Maven打包一个项目时,它会将src / main / resource中的文件复制到目标/类。这样就可以在类路径上获得资源。您的transaction.properties不存在这一事实表明您在构建或运行应用程序时遇到问题。

这是一个什么样的项目,一个网络应用程序?你是如何建造它的?

如果它是一个Web应用程序,您是通过eclipse运行它的问题,还是在将.war部署到服务器后出现问题?

答案 1 :(得分:1)

src / main / resources不在类路径上,因此查找目标/类是正确的做法。应用程序不应该注意您的源的组织方式。引用文件的正确Spring方式是classpath:/transactions.properties,它将在测试期间查看文件系统,并在部署时查看应用程序Jar内部。

坦率地说:我认为这不是你的问题。您发布的所有错误消息均未显示有关未找到该文件的任何信息。我认为错误是别的。

答案 2 :(得分:1)

我有相同的“com.atomikos.icatch.SysException:初始化错误:检查点错误” - 我意识到它试图写入文件,但无法做到。然后我以管理员身份运行IDE,问题神奇地消失了。

答案 3 :(得分:0)

您遇到的实际错误是“com.atomikos.icatch.SysException:init中的错误:检查点期间出错”

当您的应用程序(反过来Atomikos)尝试写入文件(日志文件)但它已被使用或这是其他文件相关问题时,会发生此错误。示例:如果这是java应用程序,则实例可能已在运行,并且您再次运行它。由于Atomnikos在每次日志记录后都没有关闭对象输出流,因此它将保持打开状态。因此,如果其他实例尝试在同一个日志文件上写入,则会出现此错误!

仅供参考 - 我遇到了同样的错误,这就是问题所在。如果不是这种情况,请告诉我您使用的是哪种Atomikos版本,以及在此异常之前是否有以下日志行。这里path是日志文件的实际路径。

FileLogStream - 开始读取logfile tmlog12.log

FileLogStream - 完成日志文件的读取

FileLogStream - 日志文件已关闭:\ tmlog12.log