For starters, this question is not so much about programming in the NetBeans IDE as developing a NetBeans project (e.g. using the NetBeans Platform framework).
I am attempting to use the BeanUtils library to introspect my domain models and provide the properties to display in a property sheet. Sample code:
public class MyNode extends AbstractNode implements PropertyChangeListener {
private static final PropertyUtilsBean bean = new PropertyUtilsBean();
// snip
protected Sheet createSheet() {
Sheet sheet = Sheet.createDefault();
Sheet.Set set = Sheet.createPropertiesSet();
APIObject obj = getLookup().lookup (APIObject.class);
PropertyDescriptor[] descriptors = bean.getPropertyDescriptors(obj);
for (PropertyDescriptor d : descriptors) {
Method readMethod = d.getReadMethod();
Method writeMethod = d.getWriteMethod();
Class valueType = d.getClass();
Property p = new PropertySupport.Reflection(obj, valueType, readMethod, writeMethod);
set.put(p);
}
sheet.put(set);
return sheet;
}
I have created a wrapper module around commons-beanutils-1.8.3.jar, and added a dependency on the module in my module containing the above code. Everything compiles fine. When I attempt to run the program and open the property sheet view (i.e.. the above code actually gets run), I get the following error:
java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:330)
at java.lang.ClassLoader.loadClass(ClassLoader.java:254)
at org.netbeans.ProxyClassLoader.loadClass(ProxyClassLoader.java:259)
Caused: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory starting from ModuleCL#64e48e45[org.apache.commons.beanutils] with possible defining loaders [ModuleCL#75da931b[org.netbeans.libs.commons_logging]] and declared parents []
at org.netbeans.ProxyClassLoader.loadClass(ProxyClassLoader.java:261)
at java.lang.ClassLoader.loadClass(ClassLoader.java:254)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:399)
Caused: java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.apache.commons.beanutils.PropertyUtilsBean.<init>(PropertyUtilsBean.java:132)
at org.myorg.myeditor.MyNode.<clinit>(MyNode.java:35)
at org.myorg.myeditor.MyEditor.<init>(MyEditor.java:33)
at org.myorg.myeditor.OpenEditorAction.actionPerformed(OpenEditorAction.java:13)
at org.openide.awt.AlwaysEnabledAction$1.run(AlwaysEnabledAction.java:139)
at org.netbeans.modules.openide.util.ActionsBridge.implPerformAction(ActionsBridge.java:83)
at org.netbeans.modules.openide.util.ActionsBridge.doPerformAction(ActionsBridge.java:67)
at org.openide.awt.AlwaysEnabledAction.actionPerformed(AlwaysEnabledAction.java:142)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.AbstractButton.doClick(AbstractButton.java:389)
at com.apple.laf.ScreenMenuItem.actionPerformed(ScreenMenuItem.java:95)
at java.awt.MenuItem.processActionEvent(MenuItem.java:627)
at java.awt.MenuItem.processEvent(MenuItem.java:586)
at java.awt.MenuComponent.dispatchEventImpl(MenuComponent.java:317)
at java.awt.MenuComponent.dispatchEvent(MenuComponent.java:305)
[catch] at java.awt.EventQueue.dispatchEvent(EventQueue.java:638)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:125)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
I understand that beanutils is using the commons-logging component. I have tried adding the commons-logging component in two different ways (creating a wrapper library around the commons-logging library, and putting a dependency on the Commons Logging Integration library).
Neither solves the problem.
I noticed that the same problem occurs with other wrapped libraries; if they themselves have external dependencies, the ClassNotFoundExceptions propagate like mad, even if I've wrapped the jars of the libraries they require and added them as dependencies to the original wrapped library module.
Pictorially:
alt text http://files.droplr.com/files/18876491/IwG2.NetBeans%20Project%20problem.png
I'm at my wits end here. I noticed similar problems while googling:
Is there a known bug on NB Module dependency
Same issue I'm facing but when wrapping a different jar
NetBeans stance on this - none of the 3 apply to me.
None conclusively help me.
Thank you,
Nick
EDIT: I managed to get the example with beanutils to compile by adding dependencies to commons-logging and commons-collections to the beanutils library wrapper. But my problem remains in other instances.
I rebuilt the jars, rewrapped them, and that fixed the ClassPathNotFound exceptions.
Caused: java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.apache.commons.beanutils.PropertyUtilsBean.<init>(PropertyUtilsBean.java:132)
This error basically hints that the Commons Logging needs to be in the same classpath as Commons Beanutils. I am not sure what you mean with creating a wrapper module and why you would like to do it, but normally you just drop the libraries (the JAR files) in a project folder which is covered by the project's buildpath (aka classpath), or to manually add the JAR files to the project's buildpath.
Related
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.
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.
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.
I have a Java webservice running in Tomcat 6 which accepts JSON input. I am trying to use Jackson ObjectMapper to parse the input json. But when initializing the ObjectMapper object I am getting this error
16:08:13,616 ERROR [[jersey]] Servlet.service() for servlet jersey threw exception
java.lang.VerifyError: Cannot inherit from final class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2733)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1124)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1612)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
at com.test.project.offline.ws.WsApiResource.updateData(WsApiResource.java:169)
.......
At line 169 I have this ObjectMapper mapper = new ObjectMapper();
When calling com.test.project.offline.ws.WsApiResource.updateData() method locally in a unit test it works without any error.
Kindly help me in fixing this. I am using Jackson 1.8.4 and tomcat 6.
UPDATE: Fixed the issue. Problem was a different version of jackson in the dependency tree. Excluding it fixed the problem.
I also had the same issue with Apache Lucene. I had lucene-core-3.6.0.jar and lucene-core-3.5.0.jar in my /WEB-INF/lib folder. Removing one or the other also fixed my problem. It must be a versioning issue.
I had the same issue with Apache Solr, and it was resolved by deleting my ~/.m2 cache.
This issue was also caused by specifying the wrong version of a dependency in my pom.xml file, where another package was automatically downloading another version.
Maven really should have some sort of conflicting versions of dependency resolution scheme...
The same for me - my ejb3 application uses jackson-all-1.9.4 - and my glassfish container (v2.1) contains a lib/jackson-asl-0.9.4.jar:
java.lang.VerifyError: Cannot inherit from final class
Now, I have replaced jackson-all with gson.
Thanks,
Danny
Neil has a great answer to this question. However, aside from your M2 cache, check if you're a complete DUMMY like I WAS and ensure your POM doesn't include two packages where the same Final class is declared. Google API's are notorious for cross including classes in their API Jars. Ensure you delete EVERYTHING you don't need!
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.