laxman954 / granule

Automatically exported from code.google.com/p/granule
0 stars 0 forks source link

Non-exploded deployment leads to NPE #21

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. Deploy jsp-demo-1.0.9.war in Tomcat 7.0.x (verified in 7.0.39) using a 
context descriptor jsp-demo.xml:
<Context docBase="C:\temp\jsp-demo-1.0.9.war">  
</Context>
2. Place the context descriptor in <tomcat>\conf\Catalina\localhost
3. Start Tomcat
Tomcat will now deploy the application in non-exploded.
4. Open http://localhost:8080/jsp-demo. Click on the first Hello World link.

What is the expected output? What do you see instead?
Expected to show the hello world output.
Seeing a stack trace:
org.apache.jasper.JasperException: javax.servlet.ServletException: 
javax.servlet.jsp.JspTagException: java.lang.NullPointerException
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:585)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
root cause

javax.servlet.ServletException: javax.servlet.jsp.JspTagException: 
java.lang.NullPointerException
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:908)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:841)
    org.apache.jsp.samples.hello_002dclosure_jsp._jspService(hello_002dclosure_jsp.java:92)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
root cause

java.lang.NullPointerException
    java.io.File.<init>(File.java:222)
    com.granule.CompressTagHandler.processChunk(CompressTagHandler.java:289)
    com.granule.CompressTagHandler.handleTag(CompressTagHandler.java:198)
    com.granule.CompressTag.doAfterBody(CompressTag.java:66)
    org.apache.jsp.samples.hello_002dclosure_jsp._jspx_meth_g_005fcompress_005f0(hello_002dclosure_jsp.java:119)
    org.apache.jsp.samples.hello_002dclosure_jsp._jspService(hello_002dclosure_jsp.java:73)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

What version of the product are you using? On what operating system?
1.0.9, Windows 7, Tomcat 7.0.39

Please provide any additional information below.
The problem is that the code relies on 
request.getSession().getServletContext().getRealPath(path);
to get a file handle to each file.
But in a non-exploded deployment, getRealPath(..) will always return null.
Discussion about this behaviour here:
http://stackoverflow.com/questions/536228/why-does-getrealpath-return-null-when-
deployed-with-a-war-file

Original issue reported on code.google.com by mattias....@gmail.com on 23 Apr 2013 at 6:45

GoogleCodeExporter commented 8 years ago
any resolution for this issue?

Original comment by mwang30...@gmail.com on 7 Nov 2014 at 4:38