we are trying to use the docx4j library within a struts web-application. We use the binary docx4j files, not the source code. IDE is Eclipse Indigo. If we try to run the "ImportForeignPart.java" sample as a java application everything works fine. However, if we try to to implement some functionality form that class within the struts project, the whole web project compiles and starts, but has this error outoput:
- Code: Select all
Jan 27, 2012 12:02:27 PM org.apache.catalina.core.AprLifecycleListener init
Information: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.7.0_02\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jdk1.7.0_02/jre/bin/server;C:/Program Files/Java/jdk1.7.0_02/jre/bin;C:/Program Files/Java/jdk1.7.0_02/jre/lib/amd64;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;c:\Program Files\Hewlett-Packard\Drive Encryption\;C:\Program Files (x86)\Common Files\Acronis\SnapAPI\;C:\Program Files\Java\jdk1.7.0_02\jre\bin;C:\Program Files\MySQL\MySQL Server 5.5\bin;C:\Program Files\eclipse;;.
Jan 27, 2012 12:02:27 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
Warnung: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:CoSys' did not find a matching property.
Jan 27, 2012 12:02:27 PM org.apache.coyote.AbstractProtocol init
Information: Initializing ProtocolHandler ["http-bio-8080"]
Jan 27, 2012 12:02:27 PM org.apache.coyote.AbstractProtocol init
Information: Initializing ProtocolHandler ["ajp-bio-8009"]
Jan 27, 2012 12:02:27 PM org.apache.catalina.startup.Catalina load
Information: Initialization processed in 555 ms
Jan 27, 2012 12:02:27 PM org.apache.catalina.core.StandardService startInternal
Information: Starting service Catalina
Jan 27, 2012 12:02:27 PM org.apache.catalina.core.StandardEngine startInternal
Information: Starting Servlet Engine: Apache Tomcat/7.0.23
Jan 27, 2012 12:02:28 PM org.apache.tiles.impl.BasicTilesContainer init
Information: Initializing Tiles2 container. . .
Jan 27, 2012 12:02:28 PM org.apache.tiles.impl.BasicTilesContainer initializeDefinitionsFactory
Information: Tiles2 container initialization complete.
Jan 27, 2012 12:02:28 PM org.apache.tiles.access.TilesAccess setContainer
Information: Publishing TilesContext for context: org.apache.catalina.core.ApplicationContextFacade
Jan 27, 2012 12:02:28 PM org.displaytag.filter.ResponseOverrideFilter init
Information: Filter initialized. Response buffering is enabled
Jan 27, 2012 12:02:28 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
Information: Parsing configuration file [struts-default.xml]
Jan 27, 2012 12:02:28 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
Information: Parsing configuration file [struts-plugin.xml]
Jan 27, 2012 12:02:28 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
Information: Parsing configuration file [struts.xml]
Jan 27, 2012 12:02:28 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
Information: Loading global messages from MessageResources
Jan 27, 2012 12:02:29 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
Schwerwiegend: Unable to read class [com.empirica.cosys.database.testing.CreateWordprocessingMLDocument]
Could not load org/docx4j/samples/AbstractSample.class - [unknown location]
at com.opensymphony.xwork2.util.finder.ClassFinder.readClassDef(ClassFinder.java:769)
at com.opensymphony.xwork2.util.finder.ClassFinder.access$400(ClassFinder.java:48)
at com.opensymphony.xwork2.util.finder.ClassFinder$InfoBuildingVisitor.extractSuperInterfaces(ClassFinder.java:814)
at com.opensymphony.xwork2.util.finder.ClassFinder$InfoBuildingVisitor.visit(ClassFinder.java:801)
at org.objectweb.asm.xwork.ClassReader.accept(Unknown Source)
at org.objectweb.asm.xwork.ClassReader.accept(Unknown Source)
at com.opensymphony.xwork2.util.finder.ClassFinder.readClassDef(ClassFinder.java:764)
at com.opensymphony.xwork2.util.finder.ClassFinder.<init>(ClassFinder.java:149)
at org.apache.struts2.convention.PackageBasedActionConfigBuilder.findActions(PackageBasedActionConfigBuilder.java:352)
at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.java:317)
at org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:53)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:204)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:374)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:418)
at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:190)
at com.empirica.cosys.database.actionDispatcherFilter.Struts2Dispatcher.init(Struts2Dispatcher.java:16)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:277)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:258)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:382)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:103)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4624)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5281)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1525)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1515)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
The class in question looks like this:
- Code: Select all
package com.empirica.cosys.database.wordProcessor;
import java.io.FileInputStream;
import java.io.InputStream;
import org.docx4j.openpackaging.Base;
import org.docx4j.openpackaging.contenttype.ContentTypeManager;
import org.docx4j.openpackaging.exceptions.InvalidFormatException;
import org.docx4j.openpackaging.io.Load;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.docx4j.openpackaging.parts.Part;
import com.empirica.cosys.database.vo.UserData;
/* This is a Class for generating Word Documents out of given Database Data*/
public class CoSysWordProcessor {
private UserData givenData;
public CoSysWordProcessor(UserData givenData){
this.setGivenData(givenData);
}
public String processWord() {
if (givenData == null) return "error";
//Testputput
System.out.println(givenData.getFirstName() + " " + givenData.getSurName());
System.out.println( "Creating package..");
try {
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
System.out.println( "Package created");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return "error";
}
return "success";
}
/**
* @return the givenData
*/
public UserData getGivenData() {
return givenData;
}
/**
* @param givenData the givenData to set
*/
public void setGivenData(UserData givenData) {
this.givenData = givenData;
}
}
and this line, when called, causes a crash:
- Code: Select all
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
what is going wrong? Are we missing some classpath definition or sth like that? We added all jars and dependencies in the project properties. I am able to provide you with any further information.
Thank you in advance!