# Failed to upload java.lang.NullPointerException for normal file size

armagan
1 1

Hello everyone,

We used ZK 7.0.1 and java 7. Users can upload file on ZK web pages. Our development and test environment OK. But prod environment has following exception;

We checked file size but independent of file size this exception occur each time.

Probably ZK8 fix it. Is ZK8 compatible with Java 7 ? Thanks for help.

at org.zkoss.zk.au.http.AuUploader.service(AuUploader.java:115) at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:459) at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:494) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125 at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301) at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60) at com.i2i.prm.webapp.base.RequestLoggingFilter.doFilter(RequestLoggingFilter.java:36) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60) at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3748) at weblogic.servlet.internal.WebAppServletContext\$ServletInvocationAction.run(WebAppServletContext.java:3714) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2283) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2182) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1499) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:263) at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)

delete retag edit

Sort by » oldest newest most voted

MDuchemin
1743 1 5

Hi Armagan,

Looks like the stacktrace is here but the actual exception message has been lost when pasting. (although I would guess a possible NullPointerException?)

Also, Zk8 is compatible with Java 7.

armagan
1 1

Hi MDuchemin,

You're right, i lost when paste. I've been edited.

MDuchemin
1743 1 5

Hi Armagan,

Thanks for the updated info. Do you have source access for the AuUploader class? (should be available trough maven / in the download page) I'd recommend putting a breakpoint at org.zkoss.zk.au.http.AuUploader.service(AuUploader.java:115) and check for the variable that is returning a null value.

If this is a production / dev scenario, it might be that your prod server is behind a reverse proxy or a gateway which rewrites the requests and removes the wid / sid from the parameter strings. Without those, the uploader wouldn't find the upload id, which could cause a NPE when receiving the file. Not sure without confirming on your side though, so remote debugging is the easiest road to get more info.

armagan
1 1

Hi again MDuchemin,

Sorry for late response.

We have no grant for prod server, therefore i cant do remote debug.

But belong to AuUploader.class line (line 115 Object sinfo = size.get(key);) following;

  {
{
uuid = XMLs.encodeText(request.getParameter("wid"));
sid = XMLs.encodeText(request.getParameter("sid"));
desktop = ((WebAppCtrl)sess.getWebApp()).getDesktopCache(sess).getDesktop(XMLs.encodeText(request.getParameter("dtid")));

String key = uuid + '_' + sid;
Object sinfo = size.get(key);


desktop object has no attributes like "org.zkoss.zk.upload.size", therefore size object is null and throw NPE.

As you said; maybe prod server rewrites wid/sid from the parameters string, because other scenario there is no exception like this.

If as you say, so what can we do fix it? Only way is upgrade to ZK8 ?

MDuchemin
1743 1 5

Hi armagan,

If you find the reason why the desktop doesn't hold parameters there, you might find a solution. I'd recommend checking the desktop ID in a breakpoint of the main thread, and in this breakpoint. Perhaps the desktop is not retrieved properly due to server configuration (request parameters lost,session expiration policy, load-balancing or session transfer without the Serialization UI settings, etc). If the desktop ID is correct (same between main page and upload thread), then the question becomes why does the default parameter for max size disapear from the desktop attributes.

I'd recommend going back to the same breakpoint in the uploader thread, and going down the stack untill you find a class that lets you see the request. From there, try to get the request headers and parameters, to see if the server has received the expected info (desktop ID, upload data, etc) or if this data is changed or lost.

I'd always recommend trying out the latest versions, as there are always bug fixes and stability improvements, but I don't think there was any bug fix matching that description. Doesn't hurt to try, but I wouldn't necessarily bet on update fixing this issue.

You mentioned that you have a production and a test server, with this code working on test, but not on prod. I'd recommend searching for configuration differences between the 2 instances. If you can, I'd also recommend doing a direct test to the prod webserver directly (no pass-through, no reverse proxy, no gateways...) to see if the server itself is the cause of the lost info, or if this is a factor of the middleware.

[hide preview]