Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Serverside NullPointerException in PdfExport.java:33

    I tested the pdf export with smartclient gwt 3.0 release and with a daily build (SC_SNAPSHOT-2011-12-27/PowerEdition Deployment). In both cases I got the following exception on the server side:

    Code:
    java.lang.NullPointerException
    	at com.isomorphic.contentexport.PdfExport.getPdfObject(PdfExport.java:33)
    	...
    I tested the export with the following code:

    Code:
            DSRequest req = new DSRequest();
            Label label = new Label("Test");
            RPCManager.exportContent(label, req);
    Here is the full output of the application server logs:

    Code:
    [WARN] 404 - GET /testapp/sc/DataSourceLoader?dataSource=%20worldDSExport (127.0.0.1) 1414 bytes
       Request headers
          Accept: application/javascript, */*;q=0.8
          Referer: http://127.0.0.1:8888/testapp.html?gwt.codesvr=127.0.0.1:9997
          Accept-Language: de-DE
          User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
          Accept-Encoding: gzip, deflate
          Host: 127.0.0.1:8888
          Connection: Keep-Alive
          Cookie: JSESSIONID=ow54g0lwhexs; GLog=%7B%0D%20%20%20%20left%3A1110%2C%20%0D%20%20%20%20top%3A344%2C%20%0D%20%20%20%20width%3A862%2C%20%0D%20%20%20%20height%3A844%2C%20%0D%20%20%20%20priorityDefaults%3A%7B%0D%20%20%20%20%20%20%20%20Log%3A4%0D%20%20%20%20%7D%2C%20%0D%20%20%20%20defaultPriority%3A3%2C%20%0D%20%20%20%20trackRPC%3Anull%0D%7D
       Response headers
          Content-Type: text/html; charset=iso-8859-1
          Content-Length: 1414
    === 2011-12-28 11:20:17,374 [l0-6] INFO  RequestContext - URL: '/testapp/sc/IDACall', User-Agent: 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)': MSIE with Accept-Encoding header, ready for compressed JS
    === 2011-12-28 11:20:17,390 [l0-6] DEBUG XML - Parsed XML from (in memory stream): 0ms
    === 2011-12-28 11:20:17,391 [l0-6] DEBUG XML - Parsed XML from /home/dev/smartclient/target\webapp\testapp\sc\system\schema\builtinTypes.xml: 1ms
    === 2011-12-28 11:20:17,391 [l0-6] INFO  PoolManager - SmartClient pooling disabled for 'simpleTypes' objects
    === 2011-12-28 11:20:17,469 [l0-6] DEBUG XML - Parsed XML from /home/dev/smartclient/target\webapp\testapp\sc\system\schema\List.ds.xml: 0ms
    === 2011-12-28 11:20:17,469 [l0-6] DEBUG XML - Parsed XML from /home/dev/smartclient/target\webapp\testapp\sc\system\schema\DataSource.ds.xml: 0ms
    === 2011-12-28 11:20:17,500 [l0-6] DEBUG RPCManager - Processing 1 requests.
    === 2011-12-28 11:20:17,502 [l0-6] DEBUG RPCManager - Request #1 (RPCRequest) data: {
        appID:"isc_builtin",
        className:"builtin",
        methodName:"getPdfObject",
        arguments:[
            "<div ><table cellspacing='0' cellpadding='0'  width='100%'><tbody><tr><td class='normal' align='left' valign='center'>Test</td></tr></tbody></table></div>",
            {
                dirDefaultSkin:"http://127.0.0.1:8888/testapp/sc/skins/Enterprise/"
            }
        ],
        is_ISC_RPC_DMI:true
    }
    === 2011-12-28 11:20:17,502 [l0-6] INFO  IDACall - Performing 1 operation(s)
    === 2011-12-28 11:20:17,502 [l0-6] DEBUG XML - Parsed XML from jar:file://home/dev/smartclient/target/webapp/WEB-INF/lib/isomorphic-core-rpc-3.0.x-2011-12-27.jar!/isc_builtin.app.xml: 0ms
    === 2011-12-28 11:20:17,518 [l0-6] DEBUG XML - Parsed XML from /home/dev/smartclient/target\webapp\testapp\sc\system\schema\Application.ds.xml: 16ms
    === 2011-12-28 11:20:17,534 [l0-6] DEBUG XML - Parsed XML from /home/dev/smartclient/target\webapp\testapp\sc\system\schema\DataSourceField.ds.xml: 0ms
    === 2011-12-28 11:20:17,549 [l0-6] DEBUG XML - Parsed XML from /home/dev/smartclient/target\webapp\testapp\sc\system\schema\ServerObject.ds.xml: 0ms
    === 2011-12-28 11:20:17,549 [l0-6] DEBUG XML - Parsed XML from /home/dev/smartclient/target\webapp\testapp\sc\system\schema\Method.ds.xml: 0ms
    === 2011-12-28 11:20:17,565 [l0-6] DEBUG RPCDMI - appConfig: isc.Application.create({
        rpcBindings:[
            {
                ID:"builtin",
                className:"com.isomorphic.rpc.BuiltinRPC",
                visibleMethods:[
                    {
                        name:"downloadWSDL"
                    },
                    {
                        name:"downloadClientContent"
                    },
                    {
                        name:"downloadClientExport"
                    },
                    {
                        name:"xmlToJS"
                    },
                    {
                        name:"uploadProgressCheck"
                    },
                    {
                        name:"saveFile"
                    },
                    {
                        name:"appendToFile"
                    },
                    {
                        name:"loadFile"
                    },
                    {
                        name:"deleteFile"
                    },
                    {
                        name:"loadSharedXML"
                    },
                    {
                        name:"saveSharedXML"
                    },
                    {
                        name:"getAvailableScriptEngines"
                    },
                    {
                        name:"devConsoleEvalServerScript"
                    },
                    {
                        name:"evalJava"
                    },
                    {
                        name:"getLogNames"
                    },
                    {
                        name:"getLogEntries"
                    },
                    {
                        name:"getLogThresholds"
                    },
                    {
                        name:"setLogThreshold"
                    },
                    {
                        name:"getPdfObject"
                    }
                ]
            },
            {
                ID:"builtin_tools",
                className:"com.isomorphic.tools.BuiltinRPC",
                visibleMethods:[
                    {
                        name:"getDataSourceFromTable"
                    },
                    {
                        name:"getDataSourceJSONFromTable"
                    },
                    {
                        name:"getDataSourceFromHibernateMapping"
                    },
                    {
                        name:"getDataSourceJSONFromHibernateMapping"
                    },
                    {
                        name:"getTables"
                    },
                    {
                        name:"getFieldsFromTable"
                    },
                    {
                        name:"getBeanFields"
                    },
                    {
                        name:"getHibernateBeans"
                    },
                    {
                        name:"getDatabaseProductNameAndVersion"
                    },
                    {
                        name:"getDatabaseTableTypes"
                    },
                    {
                        name:"setAttributes"
                    },
                    {
                        name:"clearAttributes"
                    },
                    {
                        name:"getAttributes"
                    },
                    {
                        name:"getAttribute"
                    },
                    {
                        name:"getDataSourceConfigFromJavaClass"
                    },
                    {
                        args:"cName",
                        language:"groovy",
                        name:"getJavaSource",
                        script:"\n                    if (!com.isomorphic.auth.DevModeAuthFilter.devModeAuthorized(request)) throw new Exception(\"Not Authorized\");                    \n                    //import org.apache.bcel.Repository;\n\n                    try {\n                        return org.apache.bcel.Repository.lookupClass(cName).toString();\n                    } catch (Throwable e) {\n                        return \"Unable to reverse engineer class \"+cName+\": \"+e.getMessage();\n                    }\n                "
                    },
                    {
                        name:"loadDataSource"
                    },
                    {
                        name:"dsFromXML"
                    },
                    {
                        name:"dsConfigFromXML"
                    },
                    {
                        name:"getDefinedDataSources"
                    }
                ]
            },
            {
                ID:"builtin_adminconsole",
                className:"com.isomorphic.tools.AdminConsole",
                visibleMethods:[
                    {
                        name:"getDefinedDatabases"
                    },
                    {
                        name:"testDB"
                    },
                    {
                        name:"saveDBConfig"
                    },
                    {
                        name:"setDefaultDB"
                    },
                    {
                        name:"importDataSources"
                    },
                    {
                        name:"discoverJNDIDatabases"
                    }
                ]
            }
        ]
    })
    
    === 2011-12-28 11:20:17,580 [l0-6] DEBUG RPCDMI - Invocation threw exception
    java.lang.NullPointerException
    	at com.isomorphic.contentexport.PdfExport.getPdfObject(PdfExport.java:33)
    	at com.isomorphic.rpc.BuiltinRPC.getPdfObject(BuiltinRPC.java:820)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    	at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:950)
    	at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:803)
    	at com.isomorphic.rpc.RPCDMI.execute(RPCDMI.java:305)
    	at com.isomorphic.rpc.RPCDMI.execute(RPCDMI.java:66)
    	at com.isomorphic.rpc.RPCRequest.execute(RPCRequest.java:231)
    	at com.isomorphic.servlet.IDACall.handleRPCRequest(IDACall.java:245)
    	at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:152)
    	at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:121)
    	at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
    	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
    	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
    	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
    	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    	at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
    	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    	at org.mortbay.jetty.Server.handle(Server.java:324)
    	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
    	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
    	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
    	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
    	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
    	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
    	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
    === 2011-12-28 11:20:17,580 [l0-6] WARN  RequestContext - rpcRequest.execute() failed: 
    java.lang.NullPointerException
    	at com.isomorphic.contentexport.PdfExport.getPdfObject(PdfExport.java:33)
    	at com.isomorphic.rpc.BuiltinRPC.getPdfObject(BuiltinRPC.java:820)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    	at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:950)
    	at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:803)
    	at com.isomorphic.rpc.RPCDMI.execute(RPCDMI.java:305)
    	at com.isomorphic.rpc.RPCDMI.execute(RPCDMI.java:66)
    	at com.isomorphic.rpc.RPCRequest.execute(RPCRequest.java:231)
    	at com.isomorphic.servlet.IDACall.handleRPCRequest(IDACall.java:245)
    	at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:152)
    	at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:121)
    	at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
    	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
    	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
    	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
    	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    	at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
    	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    	at org.mortbay.jetty.Server.handle(Server.java:324)
    	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
    	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
    	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
    	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
    	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
    	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
    	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
    === 2011-12-28 11:20:17,580 [l0-6] DEBUG RPCManager - Content type for RPC transaction: text/html; charset=UTF-8

    #2
    What version is this? These line numbers don't exist in 3.x or seemingly in other versions. You may be using older .jar files due to a faulty install.

    Comment


      #3
      We're using the evaluation Enterprise Edition version "SC_SNAPSHOT-2012-01-20_v8.3d/EVAL Deployment 2012-01-20".

      It seems like there's a problem with the code in the method
      Code:
      com.isomorphic.contentexport.PdfExport.getPdfRenderer(String html, Map settings)
      when trying to find out where the skin and it's stylesheet is located:

      Code:
      StringBuffer htmlFinal = new StringBuffer();
      String skinName = settings.get("skinName").toString();
      String dirSkin = "";
      
      if (config.get("skin." + skinName + ".location") == null) {
          dirSkin = settings.get("dirDefaultSkin").toString();
          dirSkin = dirSkin.substring(dirSkin.indexOf("isomorphic"), dirSkin.length() - 1);
      } else {
        dirSkin = config.get("skin." + skinName + ".location").toString();
      }
      Initially we had the NullPointerException due to the fact that we didn't set the "skinName" attribute in the DSRequest from our client code.
      After fixing that we ran into another problem:
      If property
      Code:
      skin.[skinName].location
      isn't set the code demands that the "dirDefaultSkin" setting includes the string "isomorphic" which isn't the case in our setup (dirDefaultSkin = http://127.0.0.1:8888/advisor/sc/skins/Enterprise/)
      The row that caused another Exception:
      Code:
      dirSkin = dirSkin.substring(dirSkin.indexOf("isomorphic"), dirSkin.length() - 1);
      To work around that issue we hen we had to set the property
      Code:
      skin.[skinName].location
      to point out were our skin was located.
      BUT since the name of the skin is also used as the name of the stylesheet in the code above we had to set the skinName to "skin_styles" (the name of the stylesheet).

      This is very confusing for us and we're wondering if this is something that will be fixed/changed in the future or are we forced to accept this limitations?

      This is our example code to make the PDF export work:

      Code:
      DSRequest requestProperties = new DSRequest();
      requestProperties.setAttribute("skinName", "skin_styles");
      requestProperties.setAttribute("pdfName", "ExportPdfExample");
      
      Label label = new Label("Hello Smart GWT!");
      RPCManager.exportContent(label, requestProperties);
      and in server.properties:
      Code:
      skin.skin_styles.location: advisor/sc/skins/Enterprise

      Comment


        #4
        The reported problems were solved, now, you can test this functionality with the following example:
        Code:
        DSRequest requestProperties = new DSRequest();
        requestProperties.setSkinName("Enterprise");//here you can specify the selected skin. In other case, the skin will be the same as your project.
        requestProperties.setExportFilename("test1");//here you can specify the name of the PDF object. By default is "export"
        
        Label label = new Label("Hello Smart GWT");
        RPCManager.exportContent(label, requestProperties);
        If you want to use a custom skin from a custom location, you can use the property skin.{skinName}.location. For example:
        skin.Enterprise1.location: myLocation/skins/Enterprise1.

        Also, if you want to change the charset encoding for exportation, you can use the property contentExport.charset. For example:
        contentExport.charset: ISO-8859. By default this property is UTF-8.

        Both properties are in server.properties.

        These fixes will be available in 3.0p and 3.1d SmartGWT versions going forward.

        Comment

        Working...
        X