Question

We are using a third party tool (Snowbound docViewer) which is expected to execute application's class file which is passed to the tool as a parameter. But this tool is not able to find the class passed to it only when we do run-app, it works with the war file. However same works when war is deployed to standalone tomcat server. May be class loader used to execute tool is different from our application.

I am trying to load the class like

 File file = Locator.getClassSource(DocumentContentHandler)
 def classLoader = BootStrap.class.classLoader.rootLoader
 String path = Locator.fileToURL(file)
 classLoader.addURL(new URL(path +'com/mycompany/snowbound/DocumentContentHandler.class'));

Url value generated is :

"file:/Users/amitjain/projects/mycompany/target/classes/com/mycompany/snowbound/DocumentContentHandler.class" 

The exception I get is

java.lang.ClassNotFoundException: com.mycompany.snowbound.DocumentContentHandler
at org.codehaus.groovy.tools.RootLoader.findClass(RootLoader.java:175)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:147)
at org.codehaus.groovy.grails.cli.support.GrailsRootLoader.loadClass(GrailsRootLoader.java:51)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at com.snowbound.clientcontentserver.RetrievalProcessorConfigurator.initContentClass(RetrievalProcessorConfigurator.java:977)

Even when I do the following I get class not found exception.

Class.forName('com.mycompany.snowbound.DocumentContentHandler', true, BootStrap.class.classLoader.parent)

What can I do here? Thanks,

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top