You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Walend, David" <Da...@hms.harvard.edu> on 2015/05/05 22:30:37 UTC

typesafe-config reference.conf file not found in a .jar in WEB_INF/lib

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 .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


The typesafe config developers suggested a class loader problem. Typesafe
config¹s logging reports that it is using the
org.apache.catalina.loader.StandardClassLoader when it finds the
reference.conf in WEB_INF/classes.


Specifically, I'm using a spray-based servlet, and tomcat isn't picking up
the spray.servlet.boot-class . However, all the spray jars are in that
same lib directory, on the classpath, and complaining about the missing
property. 

Did I just miss a key piece of the documentation? Is there some extra step
I need to do to help the WebappClassLoader find the reference.conf?

Thanks,

Dave


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


Re: typesafe-config reference.conf file not found in a .jar in WEB_INF/lib

Posted by "Walend, David" <Da...@hms.harvard.edu>.
On 5/6/15, 10:37 AM, "Konstantin Kolinko" <kn...@gmail.com> wrote:

>Do you have "directory entries" in your jar file?
>
>E.g.  "%JAVA_HOME%\bin\jar" -tf catalina.jar   lists directories:
>
>META-INF/
>META-INF/MANIFEST.MF
>org/
>org/apache/
>org/apache/catalina/
>org/apache/catalina/authenticator/

Thanks for the reply Konstantin. I do have directory entries listed.

I haven¹t found a way to not have them via maven, but found we were using
an old version of maven¹s jar plugin (2.4). I switched to 2.6, but that
didn¹t help.

David


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


Re: typesafe-config reference.conf file not found in a .jar in WEB_INF/lib

Posted by Konstantin Kolinko <kn...@gmail.com>.
2015-05-06 17:22 GMT+03:00 Walend, David <Da...@hms.harvard.edu>:
>>
>>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.

Do you have "directory entries" in your jar file?

E.g.  "%JAVA_HOME%\bin\jar" -tf catalina.jar   lists directories:

META-INF/
META-INF/MANIFEST.MF
org/
org/apache/
org/apache/catalina/
org/apache/catalina/authenticator/

Usually there exists an option to jar tool whether to create those
directory entries.


Best regards,
Konstantin Kolinko

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


Re: typesafe-config reference.conf file not found in a .jar in WEB_INF/lib

Posted by "Walend, David" <Da...@hms.harvard.edu>.
Chris,

Thanks for the reply. Response interlaced:

On 5/5/15, 4:35 PM, "Christopher Schultz" <ch...@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


Re: typesafe-config reference.conf file not found in a .jar in WEB_INF/lib

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

David,

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 .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?

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?

Which exact version of Tomcat are you using?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJVSSmFAAoJEBzwKT+lPKRYbAgP/iYZZy5TxEB/hO+3BYUnJMBr
BOAp/hODsGRd3zd7exoBN204Yvd19TpFSLTkgFvHWitmeST4B0k0KAHm0IJCKXpy
HuqcBJmG81eCKgSOQuP5MCDvQavDzBKoFE6vYKRQAwFLQRoWy9TM4kqT/VU/cUd1
dxQW2D4bpm2yOl1BnorKzfunb6XDRDKtN9o+3bkUyjm13A+tbFPjsNJKA7aMFCjt
QMJspBXBk90hfwXyGAgvs4tX7wP15MNq0ZdsdkdZmjmBrLR1ZQcMO2s4ldhaTUPX
YVp6ZP+JN6m2mYhmnLxq4elLno4tNTNKPv3E9oxVEwLYpWJANmIY+l5c5VcYBTnG
LexXBmz1a84aZg2yjGLNN4b/eVw8QQAOftu7arecVOCwnIVThcN9QyT4BxoJOCGD
ySZFcfuBIL1IuWyZ/RY2k0gHvSj+xKW6Sd+EyaYuciQYI12gdWzAS9K2vfCNgrl/
1oX/Yk0hUG6AO2ClOHRVEr4LfQNFDMvL0Ta1GRbbr1/Y0LAHEP2Mt+isWioOZ93v
yULGursHp7EolbRd2FAZSe7C6/i9fmABR88jOrdvaSL5/pcdteL8INy13iHXAqyE
YE2IiIjDwQPNbw6+cH9jHlGJ0OpPFwaO4rmHhNu8DuBiNGABEyimP6sf3pj4cGfQ
t9XwE7qxX3Sym9Puj1PU
=u45b
-----END PGP SIGNATURE-----

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