I am working on a grails project and I have put a .jar file in the lib directory of the project.
I keep getting a runtime exception for ClassNotFoundException in one of my java files that I am using in the grails project.
I have a method defined as such:
void printValues(org.docx4j.wml.ParaRPr rpr){
}
and I have and import section that looks like
import org.docx4j.openpackaging.exceptions.Docx4JException;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;
import org.docx4j.wml.Body;
import org.docx4j.wml.Style;
This is what is throwing th开发者_StackOverflow中文版e exception.
However, if I change my method to be like
void printValues(org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart rpr){
}
I get no runtime exception.
What could possibly be going on here? I have verified that the docx4j.jar file contains ParaRPr, and it does. I have verified that those classes are public,and they are. Also, I have tried different classes from the org.docx4j.wml directory, and some give me the exception, and some dont. How is this even possible?
Here is the full stacktrace:
2010-09-15 12:37:00,198 [http-8080-1] ERROR errors.GrailsExceptionResolver - org.docx4j.wml.ParaRPr
java.lang.ClassNotFoundException: org.docx4j.wml.ParaRPr
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 java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getDeclaredMethods(Class.java:1791)
at java.security.AccessController.doPrivileged(Native Method)
at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46)
at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33)
at javatest.ResumeController$_closure4.doCall(ResumeController.groovy:47)
at javatest.ResumeController$_closure4.doCall(ResumeController.groovy)
at java.lang.Thread.run(Thread.java:619)
[groovyc] Compiling 1 source file to C:\dev\JavaTest\target\classes
Here is the output of jar -tf on the jar file - showing the ParaRPr class in there
$ jar -tf docx4j-nightly-20100914.jar | grep Para
org/docx4j/dml/CTTextParagraph.class
org/docx4j/dml/CTTextParagraphProperties.class
org/docx4j/dml/diagram/CTParameter.class
org/docx4j/dml/diagram/STParameterId.class
org/docx4j/math/CTOMathPara.class
org/docx4j/math/CTOMathParaPr.class
org/docx4j/model/properties/paragraph/AbstractParagraphProperty.class
org/docx4j/wml/CTParaRPrOriginal.class
org/docx4j/wml/ParaRPr.class
org/docx4j/wml/ParaRPrChange.class
org/pptx4j/pml/CTTLBuildParagraph.class
org/pptx4j/pml/CTTLTimeNodeParallel.class
org/pptx4j/pml/STTLParaBuildType.class
org/xlsx4j/sml/CTParameter.class
org/xlsx4j/sml/CTParameters.class
org/xlsx4j/sml/STParameterType.class
docx4j has a number of dependencies as described here: http://dev.plutext.org/trac/docx4j/wiki/Docx4jDependencies
It looks like ParaRPr implements Child which is in org.jvnet.jaxb2_commons I believe your runtime environment is missing the jar that has Child
Yould could be missing a jar on which docx4j.jar depends.
精彩评论