struts jasperreports插件和jasper结果类型的错误

时间:2013-01-28 23:54:02

标签: struts2 jasper-reports

我尝试使用struts2-jasperreports插件但输入的结果有错误:

  

Grave:Dispatcher初始化失败无法加载配置。    - com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:69)中的[unknown location]     在   org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:390)org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:437)     在   org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:193)     在   org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:264)     在   org.apache.catalina.core.ApplicationFilterConfig。(ApplicationFilterConfig.java:120)     在   org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4685)     在   org.apache.catalina.core.StandardContext.start(StandardContext.java:5377)     在com.sun.enterprise.web.WebModule.start(WebModule.java:498)at   org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)     在   org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)     在   org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)     在   com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2000)     在   com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1651)     在   com.sun.enterprise.web.WebApplication.start(WebApplication.java:109)     在org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)     在org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)     在   org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:294)     在   com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:462)     在   com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)     在   org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:382)     在   com.sun.enterprise.v3.admin.CommandRunnerImpl $ 1.execute(CommandRunnerImpl.java:355)     在   com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)     在   com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1064)     在   com.sun.enterprise.v3.admin.CommandRunnerImpl.access $ 1200(CommandRunnerImpl.java:96)     在   com.sun.enterprise.v3.admin.CommandRunnerImpl $ ExecutionContext.execute(CommandRunnerImpl.java:1244)     在   com.sun.enterprise.v3.admin.CommandRunnerImpl $ ExecutionContext.execute(CommandRunnerImpl.java:1232)     在   com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:459)     在   com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:209)     在   com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)     在   com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)     在   com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:238)     在   com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)     在   com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)     在   com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)     在   com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)     在   com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)     在   com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)     在   com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)     在   com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)     在   com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)     在   com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)     在com.sun.grizzly.ContextTask.run(ContextTask.java:71)at   com.sun.grizzly.util.AbstractThreadPool $ Worker.doWork(AbstractThreadPool.java:532)     在   com.sun.grizzly.util.AbstractThreadPool $ Worker.run(AbstractThreadPool.java:513)     在java.lang.Thread.run(Thread.java:722)引起:结果类型   [jasper],它在类[class]的Result注释中定义   Actions.GenerarReportesAction]或由文件扩展名确定   是动作的PackageConfig的默认结果类型,可以   不能找到为Struts / XWork包定义的结果类型   [Actions#convention-default#] - [unknown location] at   org.apache.struts2.convention.DefaultResultMapBuilder.createResultConfig(DefaultResultMapBuilder.java:438)     在   org.apache.struts2.convention.DefaultResultMapBuilder.createFromAnnotations(DefaultResultMapBuilder.java:410)     在   org.apache.struts2.convention.DefaultResultMapBuilder.build(DefaultResultMapBuilder.java:202)     在   org.apache.struts2.convention.PackageBasedActionConfigBuilder.createActionConfig(PackageBasedActionConfigBuilder.java:891)     在   org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildConfiguration(PackageBasedActionConfigBuilder.java:674)     在   org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.java:345)     在   org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:53)     在   com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:245)     在   com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)     ......还有45个

我用谷歌搜索了如何解决它,但没有,我认为配置正确,但也许有人可以看到我的错误,请帮帮我!!

我使用struts2 jasperreports和注释。我的struts.xml

 <package name="default" extends="struts-default, jasperreports-default">
            <result-types> 
           <result-type name="jasper" class="org.apache.struts2.views.jasperreports.JasperReportsResult" /> 
   </result-types>  
   </package>

操作文件

import com.opensymphony.xwork2.ActionSupport;

import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import net.sf.jasperreports.engine.JasperCompileManager;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;


public class GenerarReportesAction extends ActionSupport {
private Map<String,Object> params;
private int numsol;


       @Action(value = "imprimirVale", results = {
        @Result(name = "success", type="jasper", 
            params={"location","/Reportes/ValeAlmacen.jasper"," format", "PDF", "reportParameters","%{params}","documentName","vale_almacen.pdf"})})
    @Override
    public String execute() throws Exception {

        try {
            JasperCompileManager.compileReportToFile(
                    "Reportes/ValeAlmacen.jrxml",
                    "Reportes/ValeAlmacen.jasper");
            params = new HashMap<String,Object>();
            URL img = getClass().getClassLoader().getResource("../../img/IQFALOGO.jpg");
            params.put("img",img.toString() );

           params.put("numsol",numsol);

        } catch (Exception e) {
            e.printStackTrace();
            return ERROR;
        }

        return SUCCESS;
    }

}

1 个答案:

答案 0 :(得分:2)

这就是答案:

  

对类[类Actions.GenerarReportesAction]进行结果注释或由文件扩展名确定,或者是操作的PackageConfig的默认结果类型,无法找到为Struts / XWork包定义的结果类型[动作#惯例默认#]

要使用您自己的包(默认),您可以: