[jbossts-issues] [JBoss JIRA] Commented: (JBTM-775) Property files within jars not being detected

Andrew Dinn (JIRA) jira-events at lists.jboss.org
Tue Aug 17 11:12:51 EDT 2010


    [ https://jira.jboss.org/browse/JBTM-775?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12545411#action_12545411 ] 

Andrew Dinn commented on JBTM-775:
----------------------------------

You say "Maybe the JBoss TS code should be improved to locate property files within jars? ". Actually, the code does normally find the property files in a jar -- at least it will quite happily do so when it is located in one of the TS jars.

The problem is almost certainly to do with where the file lies in your classpath. FileLocator.locateFile tries to load the file as a real file either with an absolute path or relative to user.dir user.home or java.home. After that it tries to find the  file using Thread.currentThread().getContextClassLoader().getResource(). So, you need to put the properties file in a jar where the TS code will be able to see it.

> Property files within jars not being detected
> ---------------------------------------------
>
>                 Key: JBTM-775
>                 URL: https://jira.jboss.org/browse/JBTM-775
>             Project: JBoss Transaction Manager
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>    Affects Versions: 4.9.0
>            Reporter: Galder Zamarreno
>
> We, Infinispan, has added a jbossts-properties.xml to src/test/resources to make it easier for developers to enable debug logging for JBoss TS code.
> Now, when the test jar is filled, this file is included, but any client code using this jar can't startup and instead throws errors like this:
> Caused by: java.lang.ExceptionInInitializerError
> 	at com.arjuna.ats.jta.TransactionManager.transactionManager(TransactionManager.java:97)
> 	at com.arjuna.ats.jta.TransactionManager.transactionManager(TransactionManager.java:76)
> 	... 65 more
> Caused by: java.lang.RuntimeException: java.lang.RuntimeException: invalid property file file:/home/sanne/.m2/repository/org/infinispan/infinispan-core/4.1.0-SNAPSHOT/infinispan-core-4.1.0-SNAPSHOT-tests.jar!/jbossts-properties.xml
> 	at com.arjuna.common.internal.util.propertyservice.BeanPopulator.getSingletonInstance(BeanPopulator.java:52)
> 	at com.arjuna.common.internal.util.logging.commonPropertyManager.getLoggingEnvironmentBean(commonPropertyManager.java:39)
> 	at com.arjuna.common.util.logging.LogFactory.setupLogSystem(LogFactory.java:146)
> 	at com.arjuna.common.util.logging.LogFactory.getLogNoi18n(LogFactory.java:107)
> 	at com.arjuna.ats.jta.logging.jtaLogger.<clinit>(jtaLogger.java:54)
> 	... 67 more
> Caused by: java.lang.RuntimeException: invalid property file file:/home/sanne/.m2/repository/org/infinispan/infinispan-core/4.1.0-SNAPSHOT/infinispan-core-4.1.0-SNAPSHOT-tests.jar!/jbossts-properties.xml
> 	at com.arjuna.common.util.propertyservice.PropertiesFactory.getPropertiesFromFile(PropertiesFactory.java:79)
> 	at com.arjuna.common.util.propertyservice.PropertiesFactory.initDefaultProperties(PropertiesFactory.java:187)
> 	at com.arjuna.common.util.propertyservice.PropertiesFactory.getDefaultProperties(PropertiesFactory.java:57)
> 	at com.arjuna.common.internal.util.propertyservice.BeanPopulator.getSingletonInstance(BeanPopulator.java:49)
> 	... 71 more
> 2010-08-17 11:48:49,656 INFO  [TransactionManagerFactory] (main) failed looking up TransactionManager, will not use transactions
> 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.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup.getTransactionManager(JBossStandaloneJTAManagerLookup.java:54)
> 	at org.infinispan.factories.TransactionManagerFactory.construct(TransactionManagerFactory.java:55)
> 	at org.infinispan.factories.AbstractComponentRegistry.getOrCreateComponent(AbstractComponentRegistry.java:306)
> 	at org.infinispan.factories.AbstractComponentRegistry.invokeInjectionMethod(AbstractComponentRegistry.java:244)
> 	at org.infinispan.factories.AbstractComponentRegistry$Component.injectDependencies(AbstractComponentRegistry.java:803)
> 	at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:219)
> 	at org.infinispan.factories.ComponentRegistry.registerComponent(ComponentRegistry.java:118)
> 	at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:186)
> 	at org.infinispan.factories.AbstractComponentRegistry.getOrCreateComponent(AbstractComponentRegistry.java:314)
> 	at org.infinispan.factories.AbstractComponentRegistry.invokeInjectionMethod(AbstractComponentRegistry.java:244)
> 	at org.infinispan.factories.AbstractComponentRegistry$Component.injectDependencies(AbstractComponentRegistry.java:803)
> 	at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:219)
> 	at org.infinispan.factories.ComponentRegistry.registerComponent(ComponentRegistry.java:118)
> 	at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:186)
> 	at org.infinispan.factories.InterceptorChainFactory.createInterceptor(InterceptorChainFactory.java:50)
> 	at org.infinispan.factories.InterceptorChainFactory.buildInterceptorChain(InterceptorChainFactory.java:67)
> 	at org.infinispan.factories.InterceptorChainFactory.construct(InterceptorChainFactory.java:192)
> 	at org.infinispan.factories.AbstractComponentRegistry.getOrCreateComponent(AbstractComponentRegistry.java:306)
> 	at org.infinispan.factories.AbstractComponentRegistry.invokeInjectionMethod(AbstractComponentRegistry.java:244)
> 	at org.infinispan.factories.AbstractComponentRegistry$Component.injectDependencies(AbstractComponentRegistry.java:803)
> 	at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:219)
> 	at org.infinispan.factories.ComponentRegistry.registerComponent(ComponentRegistry.java:118)
> 	at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:186)
> 	at org.infinispan.factories.AbstractComponentRegistry.getOrCreateComponent(AbstractComponentRegistry.java:314)
> 	at org.infinispan.factories.AbstractComponentRegistry.invokeInjectionMethod(AbstractComponentRegistry.java:244)
> 	at org.infinispan.factories.AbstractComponentRegistry$Component.injectDependencies(AbstractComponentRegistry.java:803)
> 	at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:219)
> 	at org.infinispan.factories.ComponentRegistry.registerComponent(ComponentRegistry.java:118)
> 	at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:186)
> 	at org.infinispan.factories.AbstractComponentRegistry.getOrCreateComponent(AbstractComponentRegistry.java:314)
> 	at org.infinispan.factories.AbstractComponentRegistry.invokeInjectionMethod(AbstractComponentRegistry.java:244)
> 	at org.infinispan.factories.AbstractComponentRegistry$Component.injectDependencies(AbstractComponentRegistry.java:803)
> 	at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:219)
> 	at org.infinispan.factories.ComponentRegistry.registerComponent(ComponentRegistry.java:118)
> 	at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:186)
> 	at org.infinispan.factories.AbstractComponentRegistry.getOrCreateComponent(AbstractComponentRegistry.java:314)
> 	at org.infinispan.factories.AbstractComponentRegistry.invokeInjectionMethod(AbstractComponentRegistry.java:244)
> 	at org.infinispan.factories.AbstractComponentRegistry$Component.injectDependencies(AbstractComponentRegistry.java:803)
> 	at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:219)
> 	at org.infinispan.factories.ComponentRegistry.registerComponent(ComponentRegistry.java:118)
> 	at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:186)
> 	at org.infinispan.factories.AbstractComponentRegistry.getOrCreateComponent(AbstractComponentRegistry.java:314)
> 	at org.infinispan.factories.AbstractComponentRegistry.invokeInjectionMethod(AbstractComponentRegistry.java:244)
> 	at org.infinispan.factories.AbstractComponentRegistry$Component.injectDependencies(AbstractComponentRegistry.java:803)
> 	at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:219)
> 	at org.infinispan.factories.ComponentRegistry.registerComponent(ComponentRegistry.java:118)
> 	at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:186)
> 	at org.infinispan.factories.AbstractComponentRegistry.getOrCreateComponent(AbstractComponentRegistry.java:314)
> 	at org.infinispan.factories.AbstractComponentRegistry.invokeInjectionMethod(AbstractComponentRegistry.java:244)
> 	at org.infinispan.factories.AbstractComponentRegistry$Component.injectDependencies(AbstractComponentRegistry.java:803)
> 	at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:219)
> 	at org.infinispan.factories.ComponentRegistry.registerComponent(ComponentRegistry.java:118)
> 	at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:186)
> 	at org.infinispan.factories.InternalCacheFactory.bootstrap(InternalCacheFactory.java:90)
> 	at org.infinispan.factories.InternalCacheFactory.createAndWire(InternalCacheFactory.java:77)
> 	at org.infinispan.factories.InternalCacheFactory.createCache(InternalCacheFactory.java:58)
> 	at org.infinispan.manager.DefaultCacheManager.createCache(DefaultCacheManager.java:445)
> 	at org.infinispan.manager.DefaultCacheManager.getCache(DefaultCacheManager.java:411)
> Even though the properties file is within the JAR and the contents of the jar and xml have been verified, the following code does not like it:
>             filepath = FileLocator.locateFile(propertyFileName);
>             File propertyFile = new File(filepath);
>             if(!propertyFile.exists() || !propertyFile.isFile()) {
>                 throw new RuntimeException("invalid property file "+filepath);
>             }
> Maybe the JBoss TS code should be improved to locate property files within jars?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jbossts-issues mailing list