2015-03-13 56 views
1

我想使用Struts2 jfreechart插件 - 使用Maven項目。 在Maven依賴關係中,我能夠看到jfree-chart jar文件。父包未定義:jfreechart默認[未知位置]

我需要使用單獨的包嗎?

任何人都可以幫忙嗎?

獲得以下錯誤:

SEVERE: Dispatcher initialization failed 
Unable to load configuration. - [unknown location] 
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70) 
    at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:967) 
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:435) 
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:479) 
    at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74) 
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57) 
    at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279) 
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260) 
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105) 
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4828) 
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5508) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:262) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 
    at java.lang.Thread.run(Thread.java:745) 
Caused by: Parent package is not defined: jfreechart-default - [unknown location] 
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.buildPackageContext(XmlConfigurationProvider.java:674) 
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:523) 
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:295) 
    at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:112) 
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:264) 
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67) 
    ... 17 more 

struts.xml

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE struts PUBLIC 
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" 
    "http://struts.apache.org/dtds/struts-2.0.dtd"> 
<struts> 

    <constant name="struts.devMode" value="true"></constant> 


    <package name="basicstruts2" extends="struts-default, jfreechart-default"> 
     <action name="index"> 
      <result>/index.jsp</result> 
     </action> 

     <action name="getchart" class="com.struts.charts.actions.ChartAction" 
      method="execute"> 
      <result name="success" type="chart"> 
       <param name="width">400</param> 
       <param name="height">300</param> 
      </result> 
     </action> 
    </package> 



</struts> 

回答

1

struts.xml你已經使用了需要struts2-jfreechart-plugin-x.x.x.jar是在類路徑中的代碼。這個插件有struts-plugin.xml,其中jfreechart-default包被定義。如果您的包裹延伸jfreechart-default,則需要this

<package name="basicstruts2" extends="struts-default, jfreechart-default"> 
+0

非常感謝Roman.Earlier我只添加了jfreechart神器。添加struts2-jfreechart-plugin工件依賴關係後 - 完美工作。 – 2015-03-14 09:43:51