Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TomEE downloaded by buildpack has an incorrect jarsToSkip configuration #32

Closed
mgvinuesa opened this issue Mar 1, 2018 · 6 comments
Closed

Comments

@mgvinuesa
Copy link

Hi

Deploying applications that needs commons-codec I have had the following error:

01T11:33:32.40+0100 [App/0] OUT Caused by: java.lang.ClassNotFoundException: org.apache.commons.codec.binary.Base64
01T11:33:32.40+0100 [App/0] OUT      at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
01T11:33:32.40+0100 [App/0] OUT      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
01T11:33:32.40+0100 [App/0] OUT      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
01T11:33:32.40+0100 [App/0] OUT      at java.lang.Class.forName0(Native Method)
01T11:33:32.40+0100 [App/0] OUT      at java.lang.Class.forName(Class.java:348)
01T11:33:32.40+0100 [App/0] OUT      at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:152)
01T11:33:32.40+0100 [App/0] OUT      at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:83)
01T11:33:32.40+0100 [App/0] OUT      ... 53 more

But I have added the commons-codec in my lib folder. Checking the buildpack logs I have detected that the tomEE located in:

https://java-buildpack.cloudfoundry.org/tomee/tomee-7.0.4.tar.gz

it has (I think) a incorrect configuration in catalina.properties. If you check the property "jarsToSkip" you can check the jars that are provided by tomEE and they are not included in the JarScanner

tomcat.util.scan.StandardJarScanFilter.jarsToSkip=\
bootstrap.jar,commons-daemon.jar,tomcat-juli.jar,\
annotations-api.jar,el-api.jar,jsp-api.jar,servlet-api.jar,websocket-api.jar,\
jaspic-api.jar,\
catalina.jar,catalina-ant.jar,catalina-ha.jar,catalina-storeconfig.jar,\
catalina-tribes.jar,\
jasper.jar,jasper-el.jar,ecj-*.jar,\
tomcat-api.jar,tomcat-util.jar,tomcat-util-scan.jar,tomcat-coyote.jar,\
tomcat-dbcp.jar,tomcat-jni.jar,tomcat-websocket.jar,\
tomcat-i18n-en.jar,tomcat-i18n-es.jar,tomcat-i18n-fr.jar,tomcat-i18n-ja.jar,\
tomcat-juli-adapters.jar,catalina-jmx-remote.jar,catalina-ws.jar,\
tomcat-jdbc.jar,\
tools.jar,\
commons-beanutils*.jar,commons-codec*.jar,commons-collections*.jar,\
commons-dbcp*.jar,commons-digester*.jar,commons-fileupload*.jar,\
commons-httpclient*.jar,commons-io*.jar,commons-lang*.jar,commons-logging*.jar,\
commons-math*.jar,commons-pool*.jar,\
jstl.jar,taglibs-standard-spec-*.jar,\
geronimo-spec-jaxrpc*.jar,wsdl4j*.jar,\
ant.jar,ant-junit*.jar,aspectj*.jar,jmx.jar,h2*.jar,hibernate*.jar,httpclient*.jar,\
jmx-tools.jar,jta*.jar,log4j*.jar,mail*.jar,slf4j*.jar,\
xercesImpl.jar,xmlParserAPIs.jar,xml-apis.jar,\
junit.jar,junit-*.jar,hamcrest-*.jar,easymock-*.jar,cglib-*.jar,\
objenesis-*.jar,ant-launcher.jar,\
cobertura-*.jar,asm-*.jar,dom4j-*.jar,icu4j-*.jar,jaxen-*.jar,jdom-*.jar,\
jetty-*.jar,oro-*.jar,servlet-api-*.jar,tagsoup-*.jar,xmlParserAPIs-*.jar,\
xom-*.jar

But if you check the lib of this tomEE the commons-codec (and others) are not included

image

Currently I have had to delete this dependency but our applications that are planning to run on tomEE are hundreds. Maybe I can make a fork of the buildpack to change the tomEE but I would prefer use the official revision.

Thanks in advance.
Manuel.

@violetagg
Copy link
Member

Hello,

tomcat.util.scan.StandardJarScanFilter.jarsToSkip property is used to skip when scanning for pluggable features introduced by Servlet 3.0 specification and when scanning for tag libraries (TLDs).
http://tomcat.apache.org/tomcat-8.5-doc/config/systemprops.html#JAR_Scanning

So can you clarify this with your scenario. This property is not used to exclude jar files from the class path.

In your context.xml you can provide description for additional jar files which will be skipped/scanned. More information here:
http://tomcat.apache.org/tomcat-8.5-doc/config/jar-scan-filter.html

Regards,
Violeta

@mgvinuesa
Copy link
Author

mgvinuesa commented Mar 1, 2018

Sorry then by the misunderstanding... my scenario is quite simple and I didn't find explanation.

I have this EAR structure:

sample.ear
|____drivers
| |____driver.jar
|____war1-1.0.war
|____....
|____lib
  |____ commons-codec.jar
  |____ ....jar
  |____...
|____META-INF|
 |____application.xml

The tomEE loads perfectly all my classes located in "lib" folder except commons-codec, I get the reported error.

In fact If I put this class inside the WAR it works (I just check it) and in my local machine works properly in both situation. The full error log is:

01T11:33:32.40+0100 [App/0] OUT Caused by: java.lang.NoClassDefFoundError: org/apache/commons/codec/binary/Base64
01T11:33:32.40+0100 [App/0] OUT      at es.lacaixa.absis.arch.configman.utils.MultiPropertiesUtils.decrypted(MultiPropertiesUtils.java:799)
01T11:33:32.40+0100 [App/0] OUT      at es.lacaixa.absis.arch.configman.utils.MultiPropertiesUtils.decrypt(MultiPropertiesUtils.java:775)
01T11:33:32.40+0100 [App/0] OUT      at es.lacaixa.absis.arch.configman.utils.MultiPropertiesUtils.generateNodeTree(MultiPropertiesUtils.java:750)
01T11:33:32.40+0100 [App/0] OUT      at es.lacaixa.absis.arch.configman.utils.MultiPropertiesUtils.buildPropertiesTree(MultiPropertiesUtils.java:681)
01T11:33:32.40+0100 [App/0] OUT      at es.lacaixa.absis.arch.configman.utils.MultiPropertiesUtils.loadHashMultiplePropertiesFromPath(MultiPropertiesUtils.java:332)
01T11:33:32.40+0100 [App/0] OUT      at es.lacaixa.absis.arch.configman.arq.ArchPropsConfigManager.loadTree(ArchPropsConfigManager.java:153)
01T11:33:32.40+0100 [App/0] OUT      at es.lacaixa.absis.arch.configman.arq.ArchPropsConfigManager.load(ArchPropsConfigManager.java:124)
01T11:33:32.40+0100 [App/0] OUT      at es.lacaixa.absis.arch.configman.AbstractArchManager.loadManager(AbstractArchManager.java:133)
01T11:33:32.40+0100 [App/0] OUT      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
01T11:33:32.40+0100 [App/0] OUT      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
01T11:33:32.40+0100 [App/0] OUT      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
01T11:33:32.40+0100 [App/0] OUT      at java.lang.reflect.Method.invoke(Method.java:498)
01T11:33:32.40+0100 [App/0] OUT      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1700)
01T11:33:32.40+0100 [App/0] OUT      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1639)
01T11:33:32.40+0100 [App/0] OUT      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1568)
01T11:33:32.40+0100 [App/0] OUT      ... 38 more
01T11:33:32.40+0100 [App/0] OUT Caused by: java.lang.ClassNotFoundException: org.apache.commons.codec.binary.Base64
01T11:33:32.40+0100 [App/0] OUT      at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
01T11:33:32.40+0100 [App/0] OUT      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
01T11:33:32.40+0100 [App/0] OUT      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
01T11:33:32.40+0100 [App/0] OUT      at java.lang.Class.forName0(Native Method)
01T11:33:32.40+0100 [App/0] OUT      at java.lang.Class.forName(Class.java:348)
01T11:33:32.40+0100 [App/0] OUT      at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:152)
01T11:33:32.40+0100 [App/0] OUT      at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:83)
01T11:33:32.40+0100 [App/0] OUT      ... 53 more

The class MultiPropertiesUtils is located in the "lib" folder for example.

I just add a example in the #23 if you can try.

Regards.

@violetagg
Copy link
Member

Hi,

Please use the workaround (commons-codec in the WAR file) while we are waiting for a reply here
http://tomee-openejb.979440.n4.nabble.com/org-apache-commons-codec-filtered-by-the-classloader-but-not-provided-by-TomEE-WebProfile-td4683456.html

Regards,
Violeta

@mgvinuesa
Copy link
Author

I made it, thanks in advance by your support.

Regards,
Manuel.

@violetagg
Copy link
Member

@violetagg
Copy link
Member

Hi,

As per advice in the TomEE ticket above, one can use
cf set-env APP-NAME JAVA_OPTS '-Dopenejb.classloader.forced-load=org.apache.commons.codec'
The application is working as expected with this system property.

Regards,
Violeta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants