JDK-4632741 : NPE under WebLogic on JNLPDownloadServlet's .jnlp file-open attempt
  • Type: Bug
  • Component: deploy
  • Sub-Component: webstart
  • Affected Version: 1.0.1
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2002-02-04
  • Updated: 2003-01-21
  • Resolved: 2002-04-16
Related Reports
Duplicate :  
Description

Name: nt126004			Date: 02/04/2002


FULL PRODUCT VERSION :
J2EE 1.2

java version "1.3.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0_01)
Java HotSpot(TM) Client VM (build 1.3.0_01, mixed mode)

FULL OPERATING SYSTEM VERSION : Microsoft Windows 2000
[Version 5.00.2195], sp1


EXTRA RELEVANT SYSTEM CONFIGURATION :
Using BEA WebLogic 6.1 app server.

A DESCRIPTION OF THE PROBLEM :
When running on a BEA WebLogic 6.1 server,
JNLPDownloadServlet always just throws a
NullPointerException and doesn't return any .jnlp file
contents to the client.

Several threads in the WebStart forum mention this
problem.  Based on that and the popularity of WebLogic, it
seems like this is a commonly encountered problem.

If for some reason this problem can't be fixed, please
provide an alternate means for JNLPDownloadServlet to get
to the .jnlp file (e.g. allow file to be put in a .jar, and
its location to be specified via servlet parameter, and
read file as a resource?).

At a minimum, please catch the exception in
JNLPDownloadServlet and log a helpful message, and/or
include a note about a compatibility problem in the
README.  (When the source of a problem really turns out to
be the software being used, people often waste many hours
trying to figure out what they themselves are doing wrong
when things fail completely right from the start.)

This bug has a lot of similarities with bug 4474021 and may 
have similar root causes, but I think that they really are different bugs
for the following reasons:

(1)  4474021 describes the bug as specifically associated with the version
based protocol.
My bug occurs right from the start for JNLP files that have nothing to do
with the version based protocol.  (With my bug, the macro-substituted JNLP
file never makes it down to the client at all.)

(2)  The stack trace shown in 4474021 and the stack trace I get are very
different.

(3)  4474021 says that the source of the bug is in
com.sun.javaws.servlet.ResourceCatalog.scanDirectory.  For my bug, the
problem is in com.sun.javaws.servlet.DownloadRequest.<init>.

(4)  4474021 says that an exception also occurs on the Web Start client.
For mine, no exception occurs on the Web Start client.  (For mine, the Web
Start client never even starts up, since the servlet never sends the JNLP to
the client.)

I have two concerns:
(a) 4474021 might get fixed without my bug being fixed.
(b) Other people who experience my bug won't realize that 4474021 is the
'same' bug, and hence will waste lots of time trying to figure out other
reasons for the failure.  (I saw 4474021 early on in my search for a
solution, but was convinced that it didn't have anything to do with my
problem because its description was so different.)


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Deploy on WebLogic 6.1 the simplest possible web app
containing a .jnlp file, a web.xml file, and a lib with
jnlp-servlet.jar and the XML parser .jars.

2. Browse to the above .jnlp file.

3. Look in the WebLogic log file and see the NPE from
JnlpDownloadServlet.

EXPECTED VERSUS ACTUAL BEHAVIOR :
The results I expect are macro-substituted .jnlp file
contents returned to the browser, which should start up the
WebStart player.

Instead, the only thing that comes back to the browser is a
500 HTTP error saying that the server encountered an
internal error.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
The only thing in JnlpDownloadServlet's own log file is an 'Initializing'
message from each time it inits:
JnlpDownloadServlet(4): Initializing
JnlpDownloadServlet(4): Initializing
JnlpDownloadServlet(4): Initializing
JnlpDownloadServlet(4): Initializing

The WebLogic log file shows the servlet's NPE:
java.lang.NullPointerException
at java.io.File.<init>(File.java:181)
at com.sun.javaws.servlet.DownloadRequest.<init>(DownloadRequest.java:62)
at com.sun.javaws.servlet.JnlpDownloadServlet.handleRequest
(JnlpDownloadServlet.java:94)
at com.sun.javaws.servlet.JnlpDownloadServlet.doGet(JnlpDownloadServlet.java:86)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet
(ServletStubImpl.java:263)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet
(ServletStubImpl.java:200)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet
(WebAppServletContext.java:2390)
at weblogic.servlet.internal.ServletRequestImpl.execute
(ServletRequestImpl.java:1959)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)


This bug can be reproduced always.

---------- BEGIN SOURCE ----------
The problem isn't a function of the contents of the .jnlp file or the web.xml
file, since the same files work fine with BEA's work-around
JnlpDownloadServlet.  (And the servlet appears to fail before it even reads
anything out of the .jnlp file.)  But, if it will help, I can provide the
simple files I was using to test.
---------- END SOURCE ----------

CUSTOMER WORKAROUND :
Get the jnlp-servlet.jar file included with the BEA
WebLogic codesample package jnlpexamples1.jar. You can
download it from
http://developer.bea.com/code/sampleswls.jsp. (You will
need to do a free login to get to the page.)
(Review ID: 138243) 
======================================================================

Name: nt126004			Date: 03/15/2002


FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

Same behavoiur on both SUN JVM 1.3.1, 1.4.0 and Blackdown 1.3.1

FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]


ADDITIONAL OPERATING SYSTEMS :
Slackware Linux 8, kernel 2.4.16



A DESCRIPTION OF THE PROBLEM :
Using Web Start with either Weblogic 6.1 or JBoss 3-Tomcat-
4.0.1. I get the following exception

java.lang.NullPointerException
at java.io.File.<init>(File.java:181)
at com.sun.javaws.servlet.DownloadRequest.<init>
(DownloadRequest.java:62)
at com.sun.javaws.servlet.JnlpDownloadServlet.handleRequest
(JnlpDownloadServlet.java:94)
at com.sun.javaws.servlet.JnlpDownloadServlet.doGet
(JnlpDownloadServlet.java:86)
...

After some investigation it seems that the problem is
because of dependency on creating File objects using
getRealPath()

The problem manifests itself on several places but for
instance:
DownloadRequest Constructor:

if(_context != null && !_path.endsWith("/")) {
String s1 = _context.getRealPath(_path);
File file = new File(s1);
if(file != null && file.exists() && file.isDirectory())
_path += "/";
}
s1 is null so a nullpointer is thrown. Instead do something
like:
if (_context != null && !_path.endsWith("/")) {
String s1 = _context.getRealPath(_path);
if (s1 != null) {
File file = new File(s1);
if (file.exists() && file.isDirectory())
_path += "/";
}
}

But it is harder to fix on other places such as
ResourceCatalog.scanDirectory(String path)

File file = new File(_servletContext.getRealPath(s));

This will faile since getRealPath returns null resulting in
a nullpointer exception which will make it impossible to
download versioned jars.

The documentation for ServletContext says that getRealPath
will return null if the application is packaged in a war
file but this is strange since it worked fine for me for
running JBoss-2.4.0_Tomcat-3.2.3. Maybe this is new
behaviour for the 2.3 servlet spec?

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. create the mapping of /app/* to go through the
JnlpDowloadServlet in web.xml
2. Create a web page with a link to the jnlp file
3. Create a War file containing the jnlp-servlet and some
versioned jar files
4. Deploy the war file on Weblogic 6.1 or JBoss 3-
  Tomcat_4.01
5. Try invoking webstart by clicking the link

EXPECTED VERSUS ACTUAL BEHAVIOR :
Web start should start but instead a nullpointer is thrown
and the loading fails.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.NullPointerException
        at java.io.File.<init>(File.java:180)
        at com.sun.javaws.servlet.DownloadRequest.<init>
(DownloadRequest.java:55)
        at com.sun.javaws.servlet.JnlpDownloadServlet.handleRequest
(JnlpDownloadServlet.java:87)
        at com.sun.javaws.servlet.JnlpDownloadServlet.doGet
(JnlpDownloadServlet.java:79)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:247)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:243)
        at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:566)
        at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:472)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
        at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:190)
        at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:566)
        at org.apache.catalina.valves.CertificatesValve.invoke
(CertificatesValve.java:246)
        at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:564)
        at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:472)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
        at org.apache.catalina.core.StandardContext.invoke
(StandardContext.java:2343)
        at org.apache.catalina.core.StandardHostValve.invoke
(StandardHostValve.java:180)
        at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:566)
        at org.apache.catalina.valves.ErrorDispatcherValve.invoke
(ErrorDispatcherValve.java:170)
        at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:564)
        at org.apache.catalina.valves.ErrorReportValve.invoke
(ErrorReportValve.java:170)
        at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:564)
        at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:472)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
        at org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:174)
        at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:566)
        at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:472)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
        at org.apache.catalina.connector.http.HttpProcessor.process
(HttpProcessor.java:1012)
        at org.apache.catalina.connector.http.HttpProcessor.run
(HttpProcessor.java:1107)
        at java.lang.Thread.run(Thread.java:484)

This bug can be reproduced always.

---------- BEGIN SOURCE ----------
The error is in the jnlp-servlet.jar. Specifically DowloadRequest and
ResourceCatalog. Any application servlet container that returns null from
getRealPath() will display this problem.
---------- END SOURCE ----------
(Review ID: 144160)
======================================================================

Comments
WORK AROUND CUSTOMER WORKAROUND : Get the jnlp-servlet.jar file included with the BEA WebLogic codesample package jnlpexamples1.jar. You can download it from http://developer.bea.com/code/sampleswls.jsp. (You will need to do a free login to get to the page.)
31-08-2004

EVALUATION ServletContext.getRealPath is returning null under certain conditions. ###@###.### 2002-02-06 fixed by 4474021. ###@###.### 2002-04-16
06-02-2002