Webstart unable to find the Bea licence file
Hi All,
We are using an web application with weblogic server and webstart. We are currently trying to convert the application from T3 to T3s protocol. For this we require the license.bea file to be set in the client side class path.
When i place this license.bea in the download directory of the webstart (where all signed the jar's and .jnlp file is downloaded) and launch the .jnlp file,it works.But when the .jnlp file is called throug the application it fails to locate the license file. error message:
<<Missing license file for: WebLogic Platform 8.1>>
The .jnlp file is as below :
<?xml version="1.0" encoding="UTF-8"?>
<jnlp codebase="http://dbnexus.int.risk.db.com:80/webstart/" href="launch.jnlp" spec="1.0+">
<information>
<vendor>GRT</vendor>
<homepage href="index.html"/>
<description kind="short">Client for dbNexus reference data management system</description>
<description kind="one-line">dbNexus client</description>
<description kind="tooltip">dbNexus client</description>
<title>dbNexus Client ( INT )</title>
</information>
<security>
<all-permissions/>
</security>
<property name="bea.home" value=".\"/>
<property name="weblogic.security.SSL.ignoreHostnameVerification" value="true"/>
<property name="weblogic.security.SSL.trustedCAKeyStore" value=".\DAPTrust.jks"/>
<property name="weblogic.security.SSL.trustedCAKeyStorePassPhrase" value="trustpassword"/>
<resources>
<j2se initial-heap-size="512M" max-heap-size="1024M" version="1.4+"/>
<jar download="eager" href="dbnApplet.jar"/>
<jar download="eager" href="xmlParserAPIs.jar"/>
<jar download="eager" href="xercesImpl.jar"/>
<jar download="eager" href="log4j-1.2.3.jar"/>
<jar download="eager" href="utils.jar"/>
<jar download="eager" href="weblogic.jar"/>
<jar download="eager" href="dbnexus-ejb-compiled.jar"/>
<jar download="eager" href="wlcipher.jar"/>
</resources>
<application-desc main-class="dbnexus.client.applet.appletwrapper.MainFrame">
<argument>http://dbnexus.int.risk.db.com:80/webstart//dbnexus.properties</argument>
</application-desc>
</jnlp>
In the above code i have specified the Bea.home as .\ so that it picks up the license from the same directory. We do not want to place the file at other place and hard code the path in the code as the path might differ in different systems where the application will be downloaded.
Is there any way by which we can achive the above. Is it possible to place the .bea file inside any jar and access it from the same. Please advice.
Thaks in advance....
Regards,
Ravi
[2998 byte] By [
Raj-ka] at [2007-11-27 6:08:10]

# 1
Whewn running in Java Web Start, the JNLPClassLoader (which loads all the resources specified for the application) does not consider ClassPath, since it is a web-centris instead of a file-centric ClassLoader.
If the Bea code assumes the license can be found by the ContextClassLoader, or the invoking codes classLoader, then all you have to do is include the file in the top level of any of the jars of the application.
If, however, it assumes the license can be found on the classpath by the SystemClassLoader, you would have to read the license with ClassLoader.getResourceAsStream("license.bea");, and then write it out to somewhere on the classpath (such as the extension dir of the jre).
/Andy
# 2
As suggested by Andy I have included the following Code :
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
java.net.URL BeaHome = MainFrame.class.getClassLoader().getResource("license.bea");
System.setProperty("bea.home",BeaHome.getPath().toString());
The above code gives me the directory path as :
c:/Documents%20and%20Settings/All%20Users/Application%20Data/JavaCache/http/Ddbnexus.int.risk.db.com/P80/DMwebstart/RMwlcipher.jar!/license.bea
This path is correct but still the appliaction is unable to find the licence file. Is it because of the spaces (%20) in the path ? How can i resove this. I tried putting the path in " '" but does not work.
Thanks & regards,
Ravi
Raj-ka at 2007-7-12 17:10:11 >

# 3
The problem is,the appliaction is not able to find the license file from within the .Jar.
If is set the property as :
-Dbea.home="c:/Documents and Settings/All Users/Application Data/JavaCache/http/Ddbnexus.int.risk.db.com/P80/DMwebstart/" and it works
But if i giv the path of the jar file it does not :
-Dbea.home="c:/Documents and Settings/All Users/Application Data/JavaCache/http/Ddbnexus.int.risk.db.com/P80/DMwebstart/RMwlcipher.jar!/license.bea"
How can i make the licence file insidethe .jar file readable by the application ?
Or is there any way by which i can download the .bea file to the webstart catch(I.e the download directory). I am able to download the .jar using
<resources>
<jar href="wlcipher.jar" download="eager"/>
</resources>
Please advice.........
Ravi
Raj-ka at 2007-7-12 17:10:11 >

# 4
> The problem is,the appliaction is not able to find
> the license file from within the .Jar.
>
> is set the property as :
> Dbea.home="c:/Documents and Settings/All
> Users/Application
> Data/JavaCache/http/Ddbnexus.int.risk.db.com/P80/DMweb
> start/" and it works
> But if i giv the path of the jar file it does not :
> -Dbea.home="c:/Documents and Settings/All
> Users/Application
> Data/JavaCache/http/Ddbnexus.int.risk.db.com/P80/DMweb
> start/RMwlcipher.jar!/license.bea"
>
> How can i make the licence file insidethe .jar file
> readable by the application ?
>
> Or is there any way by which i can download the .bea
> file to the webstart catch(I.e the download
> directory). I am able to download the .jar using
>
> <resources>
> <jar href="wlcipher.jar" download="eager"/>
> </resources>
>
>
> Please advice.........
>
> Ravi
> The problem is,the appliaction is not able to find
> the license file from within the .Jar.
>
That is because there is no such "file" on the client machine.
c:/Documents and Settings/.../DMwebstart/RMwlcipher.jar!/license.bea"
is not a path at all. (notice the "!" between the jar and the file in it.)
After you call getResource you have a valid url to the file, but URL.getPath() will not return a "path" that can be used by the file system.
You have to open a URLConnection to that URL and read the stream that is the file contents, and store it as a file somewhere on the filesystem.
(Instead of getResource(), you can just use getResourceAsStream())
/Andy
# 5
Hi Andy Thanks for your suggestion.
I have read the contents as a stream and written it as a file in the clients download path. It is working.
Is there a way by which i can avoid the "%20" instead of spaces and the "file:" preceding the path returned by URL.getPath() .
file:/C:/Documents%20and%20Settings/All%20Users/dbnexus/INT/wlcipher.jar!/license.bea
i want the above as
C:/Documents and Settings/All Users/dbnexus/INT/wlcipher.jar!/license.bea
presently i have replaced the %20 with spaces(Hard coded). I might get into trouble of user's change the path with some other special character in it.
Raj-ka at 2007-7-12 17:10:11 >

# 6
> file:/C:/Documents%20and%20Settings/All%20Users/dbnexus/INT/wlcipher.jar!/license.bea
>
> i want the above as
>
> C:/Documents and Settings/All Users/dbnexus/INT/wlcipher.jar!/license.bea
URL url = this.getClass().getResource("license.bea");
URI uri = url.toURI();
File file = new File(uri);
String filename = file.toString();
# 7
Hi Andrew,toURI() method is not present in URL class. But I was able to get the result by :URI uri = new URI(url.toString);String FinalPath = uri.getPath();Thanks for your help.
Raj-ka at 2007-7-12 17:10:11 >
