Name: nt126004 Date: 11/12/2002
FULL PRODUCT VERSION :
java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21)
Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
In order to share the same session within the web
application that is manges the JNLP file and reach Java
client started from Java WebStart it is necessary to use
URL rewriting to pass the session ID within JNLP file.
Unfortunately Webstart treats those url's with the
different sessionid as a different JNLP files and create a
different shortcuts for them.
Here is the log file for single Web Start application call.
127.0.0.1 - - [24/Oct/2002:14:19:57 -
0400] "GET /webstarttest HTTP/1.1" 200 629 "-" "Mozilla/4.0
(compatible; MSIE 6.0; Windows NT 5.0)"
127.0.0.1 - - [24/Oct/2002:14:20:00 -
0400] "HEAD /webstarttest;jsessionid=a-Essb4fWse6 HTTP/1.1"
200 629 "-" "javaws-1.2/b22"
127.0.0.1 - - [24/Oct/2002:14:20:00 -
0400] "GET /webstarttest;jsessionid=a-Essb4fWse6 HTTP/1.1"
200 629 "-" "javaws-1.2/b22"
127.0.0.1 - - [24/Oct/2002:14:20:00 -
0400] "HEAD /webstarttest;jsessionid=a-Essb4fWse6 HTTP/1.1"
200 0 "-" "javaws-1.2/b22"
127.0.0.1 - - [24/Oct/2002:14:20:00 -0400] "HEAD /test.jar
HTTP/1.1" 200 0 "-" "javaws-1.2/b22"
127.0.0.1 - - [24/Oct/2002:14:20:01 -
0400] "GET /webstarttest;jsessionid=a-Essb4fWse6?testObject
HTTP/1.1" 200 7 "-" "Java1.3.1_04"
As you can see, the first GET request is came from web
browser. Then WebStart check the HEADers of JNLP file and
downloads it by next GET request (because last modified
time is set to the session creation time). Then it checks
the headers once again, check and download required
resources such as test.jar and last call is came from Java
application that is retrieving given resource.
It does not help to use cookies for session id because they
are lost once web browser calls web start with the
downloaded JNLP file.
Anyway, I got it working by adding ";jsessionid=...." to the end of the
JNLP URL. Otherwise Webstart will call web application to check if JNLP is
up to date in the different session context and basically grab a wrong JNLP
file, as I show in my original posting. There is a server log file and you
can see all 3 clients connecting to the same web application context (web
browser, webstart and then java application). If you like, I can send you
a complete WAR file, which you can deploy on Tomcat server and try by
yourself.
The problem with my workaround is that Web start treats the same URL
with just different sessionid as a different URL and creates a new shortcut for
each of them (basically for every second run of the application).
My suggestion is to compare shortcut's URL's after stripping off the
sessionid parameter from the end of JNLP file name.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Install the TestJNL servlet and test.jar with the
Test.class inside
2. Call the TestJNL servlet by using web browser -
http://localhost:8080/webstarttest
3. Restart a web browser and call TestJNL servlet once
again.
EXPECTED VERSUS ACTUAL BEHAVIOR :
Web Start should recognise jsessionid in the JNLP URL and
ignore it in the JNLP URL.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
As you can see in Java Web Start manager application, a new shortcut is created
for every new session.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
JNLP servlet
---------------
import java.io.*;
import java.net.*;
import javax.swing.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class TestJNLP extends HttpServlet {
static final String ATTR_NAME = "testObject";
static final String ATTR_VALUE = "test2";
public void doGet( HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
HttpSession session = request.getSession();
String sid = session.getId();
String name = request.getRequestURL().toString();
URL baseURL = new URL( name);
String file2 = baseURL.getFile()+";jsessionid="+sid;
String file3 = name+";jsessionid="+sid+"?"+ATTR_NAME;
String context = new URL( baseURL, "/").toString();
response.setDateHeader( "Last-modified", session.getCreationTime());
if( request.getQueryString()!=null && request.getQueryString().length()>0) {
PrintWriter out = response.getWriter();
out.println( session.getAttribute( ATTR_NAME));
} else {
session.setAttribute( ATTR_NAME, ATTR_VALUE);
response.setContentType( "application/x-java-jnlp-file");
PrintWriter out = response.getWriter();
out.println( "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"+
"<jnlp codebase=\""+context+"\"\n"+
" href=\""+file2+"\" spec=\"1.0\">\n"+
" <information>\n"+
" <title>Test</title>\n"+
" <vendor>Test Corp</vendor>\n"+
" <homepage href=\""+context+"\"/>\n"+
" <description>Test</description>\n"+
" </information>\n"+
" <!--\n"+
" <security>\n"+
" <all-permissions/>\n"+
" </security>\n"+
" -->\n"+
" <resources>\n"+
" <j2se version=\"1.3+ 1.4+\"/>\n"+
" <jar href=\"test.jar\"/>\n"+
" </resources>\n"+
" <application-desc main-class=\"Test\">\n"+
" <argument>"+file3+"</argument>\n"+
" </application-desc>\n"+
"</jnlp>");
}
}
}
---------------
Deployment descriptor for JNLP servlet
---------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>TestJNLP</servlet-name>
<servlet-class>TestJNLP</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestJNLP</servlet-name>
<url-pattern>/webstarttest</url-pattern>
</servlet-mapping>
<mime-mapping extension='jnlp' mime-type='application/x-java-jnlp-file' />
<mime-mapping extension='jar' mime-type='application/x-java-archive' />
</web-app>
---------------
Test application for JNLP Deployment (should be deployed within test.jar)
---------------
import java.io.*;
import java.net.*;
import javax.swing.*;
public class Test {
public static void main( String[] args) throws Exception {
InputStream is = new URL( args[0]).openStream();
String message = new BufferedReader( new InputStreamReader( is)).readLine();
JOptionPane.showMessageDialog( null, message);
System.exit( 0);
}
}
---------------
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
The given code is working, but it creates a new shortcut on
a client for every new seccion.
(Review ID: 166201)
======================================================================
- duplicates
-
JDK-4880785 Dynamic argument/parameter lists for offline-allowed JNLP files
- Closed
-
JDK-4828762 WebStart should accept any legal URL for the JNLP descriptor
- Closed
- relates to
-
JDK-4546392 Should be able to pass a QueryString into WebStart.
- Resolved
-
JDK-7011540 Javaws should ignore sessionid and parameters in the url and treat as same application when caching
- Closed