Jasper fighting with JBoss - java

Hi I am trying to use Jasper (4.0.2) reports with JBoss 6 using an XML file as data source. However, there is a fair amount of over lap of required library JARs and as I can't exclude the JBoss libs I have excluded any conflicting Jasper JARs. When I run the program on its own all is well however when I re-introduce the JBoss libs I get this when trying to execute anything Jasper related:
Exception in thread "main" java.lang.NoClassDefFoundError: org/jboss/logmanager/Logger$AttachmentKey
at org.slf4j.impl.Slf4jLoggerFactory.<clinit>(Slf4jLoggerFactory.java:31)
at org.slf4j.impl.StaticLoggerBinder.getLoggerFactory(StaticLoggerBinder.java:33)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:240)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:208)
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155)
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:131)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:645)
at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.<clinit>(JRXmlDigesterFactory.java:180)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:205)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:170)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:154)
at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:111)
at com.ehive.report.ejb3.RenderReportBean.execute(RenderReportBean.java:56)
at com.ehive.report.ejb3.RenderReportBean.main(RenderReportBean.java:46)
Caused by: java.lang.ClassNotFoundException: org.jboss.logmanager.Logger$AttachmentKey
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 14 more
The Log4j library it seems to be complaining about is the same version in both Jboss and Jasper so I am confused by the exception.
Can anyone tell me is this a general compatibility problem or is there a safe way to include all required libraries without the conflict?

I am doing the same as you are using
*common-annotations,commons-beanutils-1.7.0,commons-collections-3.2.1,commons-digester-1.8,commons-logging-1.1.1jasper-compiler-jdt-5.5.23,jasperreports-3.7.2,slf4j-api-1.5.10,xmlbeans-2.3.0* and other jar in JSF + spring web app succesfully !

I had a similar issue (although not the same) with my Jasper reports. It wouldn't even compile because of class conflicts with weblogic jars. My solution was to compile the jasper jrxml files using a separate ant target which had a separate classpath defined. Once the jrxml was compiled into jasper files, I didn't have any trouble running it within the app server though.

You could repackages the classes that conflict namely log4j and Jasper w/ something like jar jar links(???). This of course will mean you have two copies of log4j albeit with different package names and a custom jasper. However once done things should just work unless there are hardcoded strings in code that refer to the original package names in log4j. Hopefully this wont be a problem :)

So the issue was with the inclusion of both the jasperreports-4.0.2.jar and jasperreports-javaflow-4.0.2.jar files. Once the "javaflow" JAR was removed all deployed smoothly.

Related

Caused By: java.lang.ClassNotFoundException: oracle.security.jps.runtime.AppSecurityContext not found by SampleAuthPlugin [1]

Background: I am trying to add some code to a custom Oracle OAM plugin. The new code I am adding is to try to access what Oracle calls the "Identity Context". I got some test code example from https://docs.oracle.com/cd/E27559_01/admin.1112/e27239/id_context.htm#AIAAG7296, but had to include two additional jars IdentityContext.jar and jps-api.jar (for AppSecurityContext) and I put those files into the WebLogic Domain/lib directory on my managed servers then bounced the managed servers.
After that, I am still get a ClassNotFoundException but it looks lie a little different than I am used to:
Caused By: java.lang.ClassNotFoundException: oracle.security.jps.runtime.AppSecurityContext not found by SampleAuthPlugin [1]
So I don't understand the error since the two JARs I added have the AppSecurityContext class and the associated inner class classes, so I'm assuming that the "different" exception is telling me something (BTW, SampleAuthPlugin is my custom plugin, which has the code to access the Identity context).
I am kind of guessing that something (maybe the Oracle OAM plugin infrastructure ) is not using the normal WebLogic classpath, and so even though I put the JARs into the DOMAIN/lib, the SampleAuthPlugin is causing something to look for the AppSecurityContext class in a JAR in some different directory??
Thanks,
Jim
EDIT: Here a more extensive stacktrace - it looks like the SampleAuthPlugin IS using it's own (or a different/special) classloader)?
Caused By: java.lang.ClassNotFoundException: oracle.security.jps.runtime.AppSecurityContext not found by SampleAuthPlugin [1]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1550)
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:77)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1988)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sample.SampleAuthPlugin$1.run(SampleAuthPlugin.java:606)
at java.security.AccessController.doPrivileged(Native Method)
at sample.SampleAuthPlugin.getIDContext(SampleAuthPlugin.java:605)
at sample.SampleAuthPlugin.ListContext(SampleAuthPlugin.java:584)
at sample.SampleAuthPlugin.process(SampleAuthPlugin.java:406)
At least for my situation, the following worked:
In my plugin JAR, I added the following in the META-INF/MANIFEST.MF:
Bundle-Classpath: .,jps-ee.jar, etc.
Then, I put the jps-ee.jar into the root of the plugin jar.
FYI, I built my plugin jar using Netbeans and for the 2nd step, I put the jps-ee.jar under the in the Netbeans project.

Oracle WCC NoClassDefFoundError: org/xml/sax/EntityResolver when running Apache POI in Custom Component

I'm writing a custom component for Oracle WCC to read in and process metadata updates from an Excel file.
However, when my Component tries to read the file with apache-poi (version: 3.11) I get the following exception:
!csUserEventMessage,weblogic,localhost:16200!$!csUnableToExecMethod,runTheMassUpdate!syJavaExceptionWrapper,java.lang.NoClassDefFoundError: org/xml/sax/EntityResolver
intradoc.common.ServiceException: !csUnableToExecMethod,runTheMassUpdate
*ScriptStack LOWES_MMU_SERVICE
3:runTheMassUpdate,**no captured values**
at intradoc.server.ServiceRequestImplementor.buildServiceException(ServiceRequestImplementor.java:2176)
at intradoc.server.Service.buildServiceException(Service.java:2404)
at intradoc.server.Service.createServiceExceptionEx(Service.java:2398)
at intradoc.server.Service.createServiceException(Service.java:2393)
at intradoc.server.Service.doCodeEx(Service.java:673)
at intradoc.server.Service.doCode(Service.java:594)
at intradoc.server.ServiceRequestImplementor.doAction(ServiceRequestImplementor.java:1693)
at intradoc.server.Service.doAction(Service.java:566)
/* Lines removed for brevity */
Caused by: java.lang.NoClassDefFoundError: org/xml/sax/EntityResolver
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at intradoc.loader.IdcClassLoader.defineClass(IdcClassLoader.java:639)
at intradoc.loader.IdcClassLoader.findClass(IdcClassLoader.java:794)
at intradoc.loader.IdcClassLoader.loadClass(IdcClassLoader.java:677)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at intradoc.loader.IdcClassLoader.defineClass(IdcClassLoader.java:639)
at intradoc.loader.IdcClassLoader.findClass(IdcClassLoader.java:794)
at intradoc.loader.IdcClassLoader.loadClass(IdcClassLoader.java:677)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.apache.poi.util.SAXHelper.<clinit>(SAXHelper.java:53)
at org.apache.poi.util.DocumentHelper.newDocumentBuilder(DocumentHelper.java:45)
at org.apache.poi.util.DocumentHelper.<clinit>(DocumentHelper.java:100)
at org.apache.poi.openxml4j.opc.internal.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:376)
at org.apache.poi.openxml4j.opc.internal.ContentTypeManager.<init>(ContentTypeManager.java:102)
at org.apache.poi.openxml4j.opc.internal.ZipContentTypeManager.<init>(ZipContentTypeManager.java:54)
at org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:192)
at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:673)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:226)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:186)
at com.lowes.content.edam.massMetaDataUpdate.file.impl.ExcelFileParser.readInputFile(ExcelFileParser.java:162)
I've added the library files to my components classpath in the hda file.
classpath=$COMPONENT_DIR/classes/:$COMPONENT_DIR/lib/poi-ooxml-3.11.jar:$COMPONENT_DIR/lib/stax-api-1.0.1.jar:$COMPONENT_DIR/lib/xmlbeans-2.3.0.jar:$COMPONENT_DIR/lib/httpcore-4.4.1.jar:$COMPONENT_DIR/lib/jna-4.1.0.jar:$COMPONENT_DIR/lib/guava-11.0.jar:$COMPONENT_DIR/lib/httpmime-4.4.1.jar:$COMPONENT_DIR/lib/javax.servlet-api-3.1.0.jar:$COMPONENT_DIR/lib/xml-apis-1.0.b2.jar:$COMPONENT_DIR/lib/poi-3.11.jar:$COMPONENT_DIR/lib/dom4j-1.6.1.jar:$COMPONENT_DIR/lib/owasp-java-html-sanitizer-1.1.jar:$COMPONENT_DIR/lib/ooxml-schemas-1.1.jar:$COMPONENT_DIR/lib/poi-ooxml-schemas-3.11.jar:$COMPONENT_DIR/lib/jsr173-1.0.jar:$COMPONENT_DIR/lib/jna-platform-4.1.0.jar:$COMPONENT_DIR/lib/httpclient-4.4.1.jar:$COMPONENT_DIR/lib/jsr305-2.0.1.jar
classpathorder=0
libpath=$COMPONENT_DIR/lib
libpathorder=0
Note: the missing class should be being provided by xml-apis-1.0.b2.jar which is a maven dependency, and included in the component Classpath, and copied into the lib folder.
So why am I getting the exception?
Why Can't the server find org.xml.sax.EntityResolver?
further question
I hope I'm not sending this down the wrong rabbit hole but a former co-worker ran into an issue with the oracle-ucm IdcClassLoader when using apache-fop. Since fop uses it's own custom classloader. Does apache-poi have the same issue?
Manifest.hda (component listing)
component
LowesMassMetadataUpdater/LowesMassMetadataUpdater.hda
componentExtra
LowesMassMetadataUpdater/readme.md
componentClasses
LowesMassMetadataUpdater/classes/
componentLib
LowesMassMetadataUpdater/lib/
Try to find the Jar file that is being used by the system. There might be a dependency conflict. You can use the following check in your com.lowes.content.edam.massMetaDataUpdate.file.impl.ExcelFileParser class:
System.out.println(EntityResolver.class.getProtectionDomain().getCodeSource().getLocation());
This will locate the owner Jar file of the class. Your SAX is most probably being loaded from an older (or newer?) library, where the EntityResolver is still (or already) absent.
Check your manifest.hda and make sure the 'Component Name'/libs is added as a componentExtra or componentLib otherwise those libs libraries won't be deployed to the content server's filesystem on component install (and hence the classes won't be resolved at runtime). You can check this assumption if you peer into the filesystem of the user_project's WCC instance in question.
The classloader probably has classes from one SAX implementation already loaded. Try removing the xml-apis-1.0.b2.jar from your classpath completely. I'd wager there's already a competing SAX implementation in the classpath that is compatible.
I searched for the class org.xml.sax.EntityResolver in http://search.maven.org
and could see that the missing class is in sax-2.0.1.jar
Please download the jar and add it to your classpath.
http://search.maven.org/#search|ga|1|fc%3A%22org.xml.sax.EntityResolver%22
Please also read the question: Why am I getting a NoClassDefFoundError in Java?
Your classpath should be separated by semi-colons (not colons).
Do you have an InstallID set in the Build Settings of your
component?
Here is an example of a component .hda file.
Try disabling the ReportPublisher component. It appears to have the same libraries in it.

WebSphere and Axis 1.4 - NoClassDefFoundError

in my application I have to call a webService using axis-1.4 libraries.
With axis-1.4.jar inside my application I get the following error:
Exception data: java.lang.NoClassDefFoundError: org.apache.axis.message.SOAPEnvelope (initialization failure)
This means (I think) that my jar conflicts with other libs in server (anyway I'm using Parent_Last class loading)
If I try to remove axis-1.4.jar from my ear, I get the following:
java.lang.ClassNotFoundException: org.apache.axis.soap.SOAPConstants
Does anyone knows which library is in conflict with axis-1.4.jar?
Thanks
You can easily find it yourself looking in RAD (if you have it) which JAR contains that classes. You can also try creating a shared library and third option: Extracting the classes you need from the library.

Caused By: java.lang.NoClassDefFoundError: org/apache/log4j/Logger

I've got an interesting problem in which the org.apache.log4j.Logger class is not found during runtime. I'm trying to get authorized and that is where it's failing:
OAuthAuthorizer oauthAuthorizer = new OAuthAuthorizer(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, SAML_PROVIDER_ID, userId);
I'm using JDeveloper 11.1.1.6. Here is what I know:
I've looked in my UI.war/WEB-INF/lib directory and I see the log4j-1.2.17.jar there.
The class complaining about it is org.opensaml.xml.XMLConfigurator
Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Logger
at org.opensaml.xml.XMLConfigurator.<clinit>(XMLConfigurator.java:60)
at org.opensaml.DefaultBootstrap.initializeXMLTooling(DefaultBootstrap.java:195)
at org.opensaml.DefaultBootstrap.bootstrap(DefaultBootstrap.java:91)
at com.intuit.ipp.aggcat.util.SAML2AssertionGenerator.getSAMLBuilder(SAML2AssertionGenerator.java:156)
at com.intuit.ipp.aggcat.util.SAML2AssertionGenerator.createSubject(SAML2AssertionGenerator.java:187)
at com.intuit.ipp.aggcat.util.SAML2AssertionGenerator.buildAssertion(SAML2AssertionGenerator.java:114)
at com.intuit.ipp.aggcat.util.SAML2AssertionGenerator.generateSignedAssertion(SAML2AssertionGenerator.java:83)
at com.intuit.ipp.aggcat.util.SamlUtil.createSignedSAMLPayload(SamlUtil.java:156)
at com.intuit.ipp.aggcat.util.OAuthUtil.getOAuthTokens(OAuthUtil.java:60)
at com.intuit.ipp.aggcat.core.OAuthAuthorizer.<init>(OAuthAuthorizer.java:85)
at com.incomemax.view.intuit.WebUtil.getAggCatService(WebUtil.java:91)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:305)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:246)
... 64 more
I decomplied XMLConfigurator and oddly it doesn't import org.apache.log4j.Logger It uses org.slf4j.Logger which is also in my jars directory (slf4j-api-1.7.5.jar). Also interesting is that line 60 (see stack trace) is a blank line in my decompile.
Of course if I add Logger.xxxxx during design time, it finds it just fine.
I'm using the code/jars directly from the sample java code, but imported into my existing application.
I've been scouring the web for answers and I believe I've checked all the areas I can think of. I also referenced this very good page: http://myarch.com/classnotfound/
Given authorization is step 1 in using the Intuit Developer API, I'm kinda stuck.
Adding output from #jhadesdev suggestion:
All versions of log4j Logger:
zip:C:/Users/Chris/AppData/Roaming/JDeveloper/system11.1.1.6.38.61.92/DefaultDomain/servers/DefaultServer/tmp/_WL_user/j2ee-app/lt5l71/war/WEB-INF/lib/log4j-1.2.17.jar!/org/apache/log4j/Logger.class
All versions of log4j visible from the classloader of the OAuthAuthorizer class:
zip:C:/Users/Chris/AppData/Roaming/JDeveloper/system11.1.1.6.38.61.92/DefaultDomain/servers/DefaultServer/tmp/_WL_user/j2ee-app/lt5l71/war/WEB-INF/lib/log4j-1.2.17.jar!/org/apache/log4j/Logger.class
All versions of XMLConfigurator:
jar:file:/C:/Oracle/Middleware11116/modules/com.bea.core.bea.opensaml2_1.0.0.0_6-1-0-0.jar!/org/opensaml/xml/XMLConfigurator.class
zip:C:/Users/Chris/AppData/Roaming/JDeveloper/system11.1.1.6.38.61.92/DefaultDomain/servers/DefaultServer/tmp/_WL_user/j2ee-app/lt5l71/war/WEB-INF/lib/ipp-java-aggcat-v1-devkit-1.0.2.jar!/org/opensaml/xml/XMLConfigurator.class
zip:C:/Users/Chris/AppData/Roaming/JDeveloper/system11.1.1.6.38.61.92/DefaultDomain/servers/DefaultServer/tmp/_WL_user/j2ee-app/lt5l71/war/WEB-INF/lib/xmltooling-1.3.1.jar!/org/opensaml/xml/XMLConfigurator.class
All versions of XMLConfigurator visible from the class loader of the OAuthAuthorizer class:
jar:file:/C:/Oracle/Middleware11116/modules/com.bea.core.bea.opensaml2_1.0.0.0_6-1-0-0.jar!/org/opensaml/xml/XMLConfigurator.class
zip:C:/Users/Chris/AppData/Roaming/JDeveloper/system11.1.1.6.38.61.92/DefaultDomain/servers/DefaultServer/tmp/_WL_user/j2ee-app/lt5l71/war/WEB-INF/lib/ipp-java-aggcat-v1-devkit-1.0.2.jar!/org/opensaml/xml/XMLConfigurator.class
zip:C:/Users/Chris/AppData/Roaming/JDeveloper/system11.1.1.6.38.61.92/DefaultDomain/servers/DefaultServer/tmp/_WL_user/j2ee-app/lt5l71/war/WEB-INF/lib/xmltooling-1.3.1.jar!/org/opensaml/xml/XMLConfigurator.class
I'm still working on interpreting the results.
During runtime your application is unable to find the jar.
Taken from this answer by Jared:
It is important to keep two different exceptions straight in our head
in this case:
java.lang.ClassNotFoundException This an Exception, it indicates that the
class was not found on the classpath. This indicates that we were
trying to load the class definition, and the class did not exist on
the classpath.
java.lang.NoClassDefFoundError This is Error, it indicates that the JVM
looked in its internal class definition data structure for the
definition of a class and did not find it. This is different than
saying that it could not be loaded from the classpath. Usually this
indicates that we previously attempted to load a class from the
classpath, but it failed for some reason - now we're trying again,
but we're not even going to try to load it, because we failed
loading it earlier. The earlier failure could be a
ClassNotFoundException or an ExceptionInInitializerError (indicating
a failure in the static initialization block) or any number of other
problems. The point is, a NoClassDefFoundError is not necessarily a
classpath problem.
for similarities and differences
You can use the following maven dependency in your pom file. Otherwise, you can download the following two jars from net and add it to your build path.
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.4</version>
</dependency>
This is copied from my working project. First make sure it is working in your project. Then you can change the versions to use any other(versions) compatible jars.
For AggCat, you can refer the POM file of the sample java application.
https://github.com/IntuitDeveloperRelations/IPP_Sample_Code/blob/master/CustomerAccountData/Java/AggCatSampleApplication/pom.xml
Thanks
Check in Deployment Assembly,
I have the same error, when i generate the war file with the "maven clean install" way and deploy manualy, it works fine, but when i use the runtime enviroment (eclipse) the problems come.
The solution for me (for eclipse IDE) go to: "proyect properties" --> "Deployment Assembly" --> "Add" --> "the jar you need", in my case java "build path entries".
Maybe can help a litle!
With the suggestions #jhadesdev and the explanations from others, I've found the issue here.
After adding the code to see what was visible to the various class loaders I found this:
All versions of log4j Logger:
zip:<snip>war/WEB-INF/lib/log4j-1.2.17.jar!/org/apache/log4j/Logger.class
All versions of log4j visible from the classloader of the OAuthAuthorizer class:
zip:<snip>war/WEB-INF/lib/log4j-1.2.17.jar!/org/apache/log4j/Logger.class
All versions of XMLConfigurator:
jar:<snip>com.bea.core.bea.opensaml2_1.0.0.0_6-1-0-0.jar!/org/opensaml/xml/XMLConfigurator.class
zip:<snip>war/WEB-INF/lib/ipp-java-aggcat-v1-devkit-1.0.2.jar!/org/opensaml/xml/XMLConfigurator.class
zip:<snip>war/WEB-INF/lib/xmltooling-1.3.1.jar!/org/opensaml/xml/XMLConfigurator.class
All versions of XMLConfigurator visible from the classloader of the OAuthAuthorizer class:
jar:<snip>com.bea.core.bea.opensaml2_1.0.0.0_6-1-0-0.jar!/org/opensaml/xml/XMLConfigurator.class
zip:<snip>war/WEB-INF/lib/ipp-java-aggcat-v1-devkit-1.0.2.jar!/org/opensaml/xml/XMLConfigurator.class
zip:<snip>war/WEB-INF/lib/xmltooling-1.3.1.jar!/org/opensaml/xml/XMLConfigurator.class
I noticed that another version of XMLConfigurator was possibly getting picked up.
I decompiled that class and found this at line 60 (where the error was in the original stack trace) private static final Logger log = Logger.getLogger(XMLConfigurator.class); and that class was importing from org.apache.log4j.Logger!
So it was this class that was being loaded and used. My fix was to rename the jar file that contained this file as I can't find where I explicitly or indirectly load it. Which may pose a problem when I actually deploy.
Thanks for all help and the much needed lesson on class loading.
Based on the stacktrace, an intuit class com.intuit.ipp.aggcat.util.SAML2AssertionGenerator needs a saml jar on the classpath.
A saml class org.opensaml.xml.XMLConfigurator needs on it's turn log4j, which is inside the WAR but cannot find it.
One explanation for this is that the class XMLConfigurator that needs log4j was found not inside the WAR but on a downstream classloader. could a saml jar be missing from the WAR?
The class XMLConfigurator that needs log4j cannot find it at the level of the classloader that loaded it, and the log4j version on the WAR is not visible on that particular classloader.
In order to troubleshoot this, a way is to add this before the oauth call:
System.out.println("all versions of log4j Logger: " + getClass().getClassLoader().getResources("org/apache/log4j/Logger.class") );
System.out.println("all versions of XMLConfigurator: " + getClass().getClassLoader().getResources("org/opensaml/xml/XMLConfigurator.class") );
System.out.println("all versions of XMLConfigurator visible from the classloader of the OAuthAuthorizer class: " + OAuthAuthorizer.class.getClassLoader().getResources("org/opensaml/xml/XMLConfigurator.class") );
System.out.println("all versions of log4j visible from the classloader of the OAuthAuthorizer class: " + OAuthAuthorizer.class.getClassloader().getResources("org/apache/log4j/Logger.class") );
Also if you are using Java 7, have a look at jHades, it's a tool I made to help troubleshooting these type of problems.
In order to see what is going on, could you post the results of the classpath queries above, for which container is this happening, tomcat, jetty? It would be better to put the full stacktrace with all the caused by's in pastebin, just in case.
Had the same problem, it was indeed caused by weblogic stupidly using its own opensaml implementation. To solve it, you have to tell it to load classes from WEB-INF/lib for this package in weblogic.xml:
<prefer-application-packages>
<package-name>org.opensaml.*</package-name>
</prefer-application-packages>
maybe <prefer-web-inf-classes>true</prefer-web-inf-classes> would work too.
java.lang.ClassNotFoundException is indicate that class is not found in class path.
it could be the version of log4j is not compatible.
check for different log4j version.
I had the same issue, for me this fixed the issue:
right click on the project ->maven -> update project
Add compile 'org.apache.logging.log4j:log4j-1.2-api:2.17.1' and then it will automatically work
In my case, the error was due to some dependencies using log4j v 1.x that I removed from the classpath. So I introduced the log4j-1.2-api to bridge v 1.x to 2.x as recommended in the Apache Migration guide:
After introducing this dependency in my build.gradle, the error disappeared :
implementation 'org.apache.logging.log4j:log4j-1.2-api:2.17.+!!'
Following works for me everytime I face the problem
rightclick on project(say abc-war)-> properties -> Deployment assembly->add->java build path entries->Maven dependencies.

Unable to run java application (as exec JAR) by including Mail dependency jar files

I am building a java application as executable jar. To compile and build application I am using ANT build.
Application ran properly still I didn't included 'Mail' dependency jar files.
As per requirement I have used Java Mail API to send email notification.
To do this I have added following Mail dependency jar files:
mail-1.4.jar
activation.jar
Once I included these dependencies in my ANT build and ran the application it throws following exception:
Exception in thread "main" java.lang.SecurityException: no manifiest section for signature file entry javax/activation/MimeType.class
at sun.security.util.SignatureFileVerifier.verifySection(SignatureFileVerifier.java:380)
at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:231)
at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:176)
at java.util.jar.JarVerifier.processEntry(JarVerifier.java:245)
at java.util.jar.JarVerifier.update(JarVerifier.java:199)
at java.util.jar.JarFile.initializeVerifier(JarFile.java:323)
at java.util.jar.JarFile.getInputStream(JarFile.java:388)
at sun.misc.JarIndex.getJarIndex(JarIndex.java:120)
at sun.misc.URLClassPath$JarLoader$1.run(URLClassPath.java:608)
at java.security.AccessController.doPrivileged(Native Method)
at sun.misc.URLClassPath$JarLoader.ensureOpen(URLClassPath.java:599)
at sun.misc.URLClassPath$JarLoader.<init>(URLClassPath.java:583)
at sun.misc.URLClassPath$3.run(URLClassPath.java:333)
at java.security.AccessController.doPrivileged(Native Method)
at sun.misc.URLClassPath.getLoader(URLClassPath.java:322)
at sun.misc.URLClassPath.getLoader(URLClassPath.java:299)
at sun.misc.URLClassPath.getResource(URLClassPath.java:168)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
sysvineMM04:MamaBear arun_kumar$
Experts Please help me to solve this error.
I assume you're packing all the class files into a single 'uberjar'?
The problem is that the activation library is a signed jar; it includes digital signatures of the class files in its manifest. When you packed the uberjar, you lost those.
The right way to deal with this is to not pack everything into one jar. Leave every library in its own packaging, and distribute them together.
However, if you want to keep using an uberjar, you should be able to fix this by copying the signatures from the activation jar's manifest into the uberjar's manifest. I don't know if there is Ant support for this, i'm afraid.

Categories