tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Walend, David" <David_Wal...@hms.harvard.edu>
Subject Re: typesafe-config reference.conf file not found in a .jar in WEB_INF/lib
Date Wed, 06 May 2015 14:22:32 GMT
Chris,

Thanks for the reply. Response interlaced:

On 5/5/15, 4:35 PM, "Christopher Schultz" <chris@christopherschultz.net>
wrote:

> Which exact version of Tomcat are you using?

Server version:        Apache Tomcat/7.0.59


>On 5/5/15 4:30 PM, Walend, David wrote:
>> typesafe config's loader isn't picking up my subproject's
>> reference.conf from within a .jar file inside a .war file's
>> WEB_INF/lib/ .
>> 
>> typesafe config finds the reference.conf in the .jar file outside of
>>tomcat. It works
>> fine from the .war file's WEB_INF/classes (my hacky fix).
>> 
>> Typesafe config is finding the reference.conf files in other .jar
>> files, like
>> 
>> Loading config from URL
>> jar:file:/opt/shrine/tomcat/webapps/shrine/WEB-INF/lib/akka-actor_2.11
>- -2.3.
>>
>> 
>8.jar!/reference.conf from class loader WebappClassLoader
>
>So your WAR file looks like this:
>
>/WEB-INF
>/WEB-INF/lib
>/WEB-INF/lib/akka-actor.2.11-2.3.8.jar
>(plus other stuff)
>
>Then, akka-actor.2.11-2.8.8.jar contains:
>
>/reference.conf
>(plus other stuff)
>
>Do I have that right?

Exactly so. 

My custom .jar follows the same pattern with its own reference.conf. It
finds the four reference.conf files from akka and spray, but not mine.

I don¹t think the problem is one reference.conf masking another because
typesafe config reports finding four of them:

0> grep reference /opt/shrine/tomcat/logs/localhost.2015-05-05.log

Loading config from URL
jar:file:/opt/shrine/tomcat/webapps/shrine/WEB-INF/lib/akka-actor_2.11-2.3.
8.jar!/reference.conf from class loader WebappClassLoader
Loading config from URL
jar:file:/opt/shrine/tomcat/webapps/shrine/WEB-INF/lib/spray-can_2.11-1.3.2
.jar!/reference.conf from class loader WebappClassLoader
Loading config from URL
jar:file:/opt/shrine/tomcat/webapps/shrine/WEB-INF/lib/spray-io_2.11-1.3.2.
jar!/reference.conf from class loader WebappClassLoader
Loading config from URL
jar:file:/opt/shrine/tomcat/webapps/shrine/WEB-INF/lib/spray-util_2.11-1.3.
2.jar!/reference.conf from class loader WebappClassLoader

I¹m out of ideas to run down.

>Is the URL you have above being used directly from within the web
>application itself? That is, do you have complete control over the
>URL, or is it built dynamically or something like that?

I think I can get control over the class loader it uses, but am using
typesafe config¹s ConfigFactory.load(³custom") method currently. In the
type safe config code, it eventually gets reference.conf from a call to

loader.getResources(resource) where resource is ³resource.conf² .


>From ~line 227 of 
https://github.com/typesafehub/config/blob/master/config/src/main/java/com/
typesafe/config/impl/Parseable.java

        @Override
        protected AbstractConfigObject rawParseValue(ConfigOrigin origin,
                ConfigParseOptions finalOptions) throws IOException {
            ClassLoader loader = finalOptions.getClassLoader();
            if (loader == null)
                throw new ConfigException.BugOrBroken(
                        "null class loader; pass in a class loader or use
Thread.currentThread().setContextClassLoader()");
            Enumeration<URL> e = loader.getResources(resource);
            if (!e.hasMoreElements()) {
                if (ConfigImpl.traceLoadsEnabled())
                    trace("Loading config from class loader " + loader
                            + " but there were no resources called " +
resource);
                throw new IOException("resource not found on classpath: "
+ resource);
            }
            AbstractConfigObject merged = SimpleConfigObject.empty(origin);
            while (e.hasMoreElements()) {
                URL url = e.nextElement();

                if (ConfigImpl.traceLoadsEnabled())
                    trace("Loading config from URL " +
url.toExternalForm() + " from class loader "
                            + loader);

                ConfigOrigin elementOrigin = ((SimpleConfigOrigin)
origin).addURL(url);

                AbstractConfigValue v;

                // it's tempting to use ParseableURL here but it would be
wrong
                // because the wrong relativeTo() would be used for
includes.
                InputStream stream = url.openStream();


Thanks again,

David


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message