使用 jasper 报告配置 struts2
Configuring struts2 with jasper reports
我正在尝试使用 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.call(StandardContext.java:5240)
at org.apache.catalina.core.StandardContext.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.call(StandardContext.java:5240)
at org.apache.catalina.core.StandardContext.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>
动作class
public class 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 天……互联网上提供了很多解决方案。
您好,我在这里发现了问题。我包含了 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 space(但这与上述问题无关)。
感谢戴夫提供线索。
我正在尝试使用 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.call(StandardContext.java:5240)
at org.apache.catalina.core.StandardContext.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.call(StandardContext.java:5240)
at org.apache.catalina.core.StandardContext.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>
动作class public class 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 天……互联网上提供了很多解决方案。
您好,我在这里发现了问题。我包含了 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 space(但这与上述问题无关)。
感谢戴夫提供线索。