我正在尝试使用jasper配置Struts 2。我用一个小例子尝试了这个但是我得到了一个错误,我花了两天时间就无法恢复它。我已经提到了错误日志和我使用过的其他代码示例。
Unable to load configuration. - [unknown location]
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:429)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:471)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:273)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:254)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:372)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:98)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4562)
at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5240)
at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5235)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: Parent package is not defined: jasperreports-default - [unknown location]
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.buildPackageContext(XmlConfigurationProvider.java:660)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:508)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:290)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:112)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:239)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
... 16 more
Jan 28, 2015 7:36:54 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter struts2
Unable to load configuration. - [unknown location]
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:483)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:273)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:254)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:372)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:98)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4562)
at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5240)
at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5235)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: Unable to load configuration. - [unknown location]
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:429)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:471)
... 14 more
Caused by: Parent package is not defined: jasperreports-default - [unknown location]
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.buildPackageContext(XmlConfigurationProvider.java:660)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:508)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:290)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:112)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:239)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
struts.xml中
<action name="TestReportExportSupport!*" class="TestReportExportSupport">
<result name="success" type="jasper">
<param name="location">our_compiled_template.jasper</param>
<param name="dataSource">myList</param>
<param name="format">PDF</param>
</result>
</action>
</package>
</struts>
动作类 公共类JasperAction扩展了ActionSupport {
/** List to use as our JasperReports dataSource. */
private List<Person> myList;
public String execute() throws Exception {
// Create some imaginary persons.
Person p1 = new Person(new Long(1), "Patrick", "Lightbuddie");
Person p2 = new Person(new Long(2), "Jason", "Carrora");
Person p3 = new Person(new Long(3), "Alexandru", "Papesco");
Person p4 = new Person(new Long(4), "Jay", "Boss");
// Store people in our dataSource list (normally they would come from a database).
myList = new ArrayList<Person>();
myList.add(p1);
myList.add(p2);
myList.add(p3);
myList.add(p4);
// Normally we would provide a pre-compiled .jrxml file
// or check to make sure we don't compile on every request.
try {
JasperCompileManager.compileReportToFile(
"S2_WEBAPP/jasper/our_jasper_template.jrxml",
"S2_WEBAPP/jasper/our_compiled_template.jasper");
} catch (Exception e) {
e.printStackTrace();
return ERROR;
}
return SUCCESS;
}
public List<Person> getMyList() {
return myList;
}
}
使用的罐子 1. jasperreports-1.2.5.jar 2. itext-1.3.jar 3. jdt-compiler.jar
任何人都可以帮我解决这个问题。我试了2天......在互联网上给出了很多解决方案。
答案 0 :(得分:1)
您好我在这里发现了这个问题。我包括了struts2-jasperreports-plugin-2.1.8.1.jar和jdt-compiler-3.1.1.jar。我错过了struts2-jasperreports-plugin-2.1.8.1.jar。 我还为服务器添加了-XX:PermSize = 256m -XX:MaxPermSize = 256m以提高perm空间(但这与上述问题无关)。
感谢戴夫的线索。