1

我是 jasper 的新手,我正在使用 ireport 4.5,我使用 ireport 创建了一个报告,我想使用 html 格式的 rest、jsp 调用该报告。但我的代码显示“未找到报告”。
我附上了我的代码

            //set up the server path

                        String serverURL = "http://your.domain.here/jasperserver/";
        //report path               
String reportName = "path to report here";
                        String reportFormat = "HTML";//report format

                        HttpClient client = new HttpClient();

                        // Setting Login URL in a POST method
                        String loginURL = serverURL+"rest/login";
                        PostMethod postMethod = new PostMethod(loginURL);

                        // Set authentication parameters
                        postMethod.addParameter("j_username", "user-here");
                        postMethod.addParameter("j_password", "password-here");

                        // Send POST with login request
                        int statusCode = client.executeMethod(postMethod);

                        //  Check correct login process
                        if (statusCode != HttpStatus.SC_OK) {
                            System.out.println("Login failed: " + postMethod.getStatusLine());
                            return;
                        }

                        // Settting resource URL in a GET method to get descriptor      
                        String resourceURL = serverURL+"rest/resource/"+reportName;
                        GetMethod getMethod = new GetMethod(resourceURL);

                        // Send GET request for descriptor
                        statusCode = client.executeMethod(getMethod);

                        //  Check correct descriptor process
                        if (statusCode != HttpStatus.SC_OK) {
                            System.out.println("Descriptor failed: "getMethod.getStatusLine());
                        }

                        // Get the response body as String
                        String descriptorSource = getMethod.getResponseBodyAsString();

                        //Transform descriptor from String into XML Document
                        Document descriptorXML = stringToDom(descriptorSource);

                        >>Use this method if you need to send parameters to the report
                        // These are added to the XML Document
                        //addParameter(descriptorXML, "personID", "1244");

                        String reportURL            =serverURL+"rest/report/"+reportName+"RUN_OUTPUT_FORMAT="+reportFormat;
                        PutMethod putMethod = new PutMethod(reportURL);

                        // Setting the request Body. The descriptor XML Document is transform to String and add to the request body.
                        putMethod.setRequestBody(domToString(descriptorXML));

                        // Send PUT request to execute the report.
                        statusCode = client.executeMethod(putMethod);

                        //  Check correct report process
                        if (statusCode != 201) {
                            System.out.println("Report failed: " + putMethod.getStatusLine());
                        }

                        // Get the response body
                        String reportSource = putMethod.getResponseBodyAsString();

                        // Transform report information into XML Document. 
                        Document reportXML = stringToDom(reportSource);

                        // Extrac from XML Document the report's UUID
                        NodeList nodes = reportXML.getElementsByTagName("uuid");
                        String reportUuid = nodes.item(0).getTextContent();

                        // Setting GET request to download the report
                        String reportFileURL = serverURL+"rest/report/"+reportUuid+"?file=report";
                        GetMethod getMethodFile = new GetMethod( reportFileURL );

                        //Send GET request to download the report
                        statusCode = client.executeMethod(getMethodFile);

                        //  Check correct report process
                        if (statusCode != 200) {
                            System.out.println("Downlaod failed: " + putMethod.getStatusLine());
                        }

                        // Getting the report body
                        InputStream is = getMethodFile.getResponseBodyAsStream();
                        BufferedInputStream bis = new BufferedInputStream( is );

                        String datastr = null;
                        StringBuffer sb = new StringBuffer();
                        byte[] bytes = new byte[ 8192 ];

                        int count = bis.read( bytes );
                        while( count != -1 && count <= 8192 ){
                            out.print(new String(bytes, 0, count));
                            count = bis.read( bytes );
                        }
                        bis.close();

                %>

        please help me to find out the error 

我的异常跟踪是

Failed to initialize component [Connector[HTTP/1.1-7067]]
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:106)
    at org.apache.catalina.core.StandardService.initInternal(StandardService.java:559)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
    at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:781)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
    at org.apache.catalina.startup.Catalina.load(Catalina.java:573)
    at org.apache.catalina.startup.Catalina.load(Catalina.java:596)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:281)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:449)
Caused by: org.apache.catalina.LifecycleException: Protocol handler initialization failed
    at org.apache.catalina.connector.Connector.initInternal(Connector.java:911)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
    ... 12 more
Caused by: java.io.FileNotFoundException: C:\Users\Sayan_Nag\.keystore (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)

    thanks in advance
4

0 回答 0