0

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 (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 IdcClassLoader when using . Since fop uses it's own custom classloader. Does have the same issue?


Manifest.hda (component listing)

component
LowesMassMetadataUpdater/LowesMassMetadataUpdater.hda
componentExtra
LowesMassMetadataUpdater/readme.md
componentClasses
LowesMassMetadataUpdater/classes/
componentLib
LowesMassMetadataUpdater/lib/
Raystorm
  • 6,180
  • 4
  • 35
  • 62
  • Why are you using quite an old version of Apache POI? What happens when you upgrade to the latest version? – Gagravarr Jul 27 '16 at 13:17
  • I'm still running in Java 6. Does Poi 3.14 / 3.15 support Java 6? – Raystorm Jul 27 '16 at 18:41
  • 1
    Hey! I'm the co-worker that had trouble with the IdcClassLoader. IIRC the issue was with how plugins were loaded by getResource method of the classloader. The 'findResource' of the base class and IdcClassLoader is to return a blank enumeration. 'findResource' of the default UrlClassLoader (which is what FOP expects) searches the entire classpath for said resource. I think this case may be caused by something else. – Aaron Romine Jul 27 '16 at 19:41
  • 1
    @Raystorm POI 3.11-3.15 all work fine with Java 6. No decisions taken yet on bumping up to Java 7, so likely 3.16+ should be fine too once those exist! – Gagravarr Jul 27 '16 at 22:06

5 Answers5

1

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.

Aram Paronikyan
  • 1,598
  • 17
  • 22
  • That was a helpful suggestion, it actually threw a new error. `java.lang.LinkageError: Class org/xml/sax/EntityResolver violates loader constraints` Looks like there is some internal conflict I need to track down. – Raystorm Jul 27 '16 at 16:08
  • It seems that the SAX version where the EntityResolver is introduced, requires java 7 as a minimum. I might be wrong though – Aram Paronikyan Jul 27 '16 at 19:53
  • The reference to the class of the EntityResolver will throw the linkage error due to the NoClassDefFound. It was there when the class was compiled, but not at runtime, so both errors are expected. The difference here is the static reference to the class causes a LinkageError. – Aaron Romine Jul 27 '16 at 20:09
  • @AaronRomine The static log line actually logs a location for the EntityResolver class. It's the next where I call Apache POI. `OPCPackage.open(fileName);` that causes the `LinkageError` to be thrown. The log actually contains: `EntityResolver.class Location: file:/home/oracle/Oracle/Middleware/user_projects/domains/base_domain/ucm/cs/custom/LowesMassMetadataUpdater/lib/xml-apis-1.0.b2.jar` Which is the expected location for the class. – Raystorm Jul 27 '16 at 20:24
  • 2
    Interesting. It's definitely a dependency problem then. 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. – Aaron Romine Jul 27 '16 at 20:43
  • @AaronRomine removing that dependency worked. I'm now making progress against new and different errors. – Raystorm Jul 28 '16 at 18:52
0

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?

Community
  • 1
  • 1
Tobias Otto
  • 1,634
  • 13
  • 20
  • I have `xml-apis-1.0.b2.jar` on my classpath and bundled in my *lib* folder. It also provides the `org.xml.sax.EntityResolver` class. – Raystorm Jul 27 '16 at 12:59
  • OK. I see that `xml-apis-1.0.b2.jar` is also fine. Sorry, but than it must be something different. What is that 'intradoc' in the stacktrace? ` at intradoc.loader.IdcClassLoader.defineClass(IdcClassLoader.java:639)` – Tobias Otto Jul 27 '16 at 13:06
  • Intradoc is an Oracle wrapper that comes with its class loader, and most probably does its bad job with the protection domain of user class libraries. The same tool might prefer some other (<2.0.1) version of SAX, that overrides the users SAX library. – Aram Paronikyan Jul 27 '16 at 13:25
0
  1. Your classpath should be separated by semi-colons (not colons).
  2. Do you have an InstallID set in the Build Settings of your component?

Here is an example of a component .hda file.

Jonathan Hult
  • 1,351
  • 2
  • 13
  • 19
  • 1
    in a normal Java classpath it's **;** on Windows and **:** on Linux/Unix. My WCC install is running under **Oracle Linux.** is an *HDA classpath* different? And yes an InstallID is set. – Raystorm Jul 27 '16 at 16:05
  • I've only ever seen ; in use but : might work. Try both and see if that helps. Have you ensured the lib folder is added to the component (either as a componentLib or as a componentExtra)? – Jonathan Hult Jul 27 '16 at 16:16
  • 1
    This is entirely dependent on the platform's PATH_SEPARATOR value. I believe WCC component class paths get fixed up before resolution either way though. Threw me off the first time I saw it as well, but it works the same either way. – Aaron Romine Jul 27 '16 at 20:10
0

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.

Aaron Romine
  • 1,539
  • 1
  • 9
  • 8
0

Try disabling the ReportPublisher component. It appears to have the same libraries in it.

Jonathan Hult
  • 1,351
  • 2
  • 13
  • 19