2

I am trying to deploy my applet using JNLP. I have tried using Eclipse Run Jetty Run plugin and it worked okay. But now with deployment at a real web server I am really stuck.

My jnlp file sketch is like this (I hava edited some names).

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" href="MyApplet.jnlp">
    <information>
        <title>MyApplet</title>
        <vendor>Me</vendor>
        <offline-allowed/>
    </information>
    <security>
        <j2ee-application-client-permissions/>
    </security>
    <resources>
        <!-- Application Resources -->
        <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
        <jar href="applet.jar" part="true" main="true"/>
        <jar href="log4j-1.2.16.jar" part="true"/>
        <jar href="slf4j-api-1.6.1.jar" part="true"/>
        <jar href="slf4j-log4j12-1.6.1.jar" part="true"/>
    </resources>
    <!--  Generate values dynamically -->
    <applet-desc main-class="org.project.applet.AppletMain" name="MyApplet" width="1600" height="860"/>
</jnlp>

I keep libraries in the same folder with applet.jar.

About manifest file in applet.jar I am not sure, I have tried many options, like specifying libraries, or just . Currently it is like below in Ant script

Java applet jnlp + libraries

<manifest>
    <attribute name="Class-Path" value="."/>
    <attribute name="Rsrc-Class-Path" value="./"/>
</manifest>

All jars are signed and this is what I get from console log:

basic: Applet loaded.
basic: Applet resized and added to parent container
basic: PERF: AppletExecutionRunnable - applet.init() BEGIN ; jvmLaunch dt 134206 us, pluginInit dt 7621660339 us, TotalTime: 7621794545 us
network: Cache entry not found [url: http://mydomain.com/play/, version: null]
network: Cache entry not found [url: http://mydomain.com/play/org/apache/log4j/Logger.class, version: null]
network: Connecting http://mydomain.com/play/org/apache/log4j/Logger.class with proxy=DIRECT
network: Connecting http://mydomain.com/play/org/apache/log4j/Logger.class with cookie "PHPSESSID=fe5gv8p4hp013r6i9p5aqjska5"
network: Connecting http://mydomain.com:80/ with proxy=DIRECT
network: Connecting http://mydomain.com/play/org/apache/log4j/Logger.class with cookie "PHPSESSID=fe5gv8p4hp013r6i9p5aqjska5"
basic: JNLP2ClassLoader.findClass: org.apache.log4j.Logger: try again ..
network: Cache entry not found [url: http://mydomain.com/play/org/apache/log4j/Logger.class, version: null]
network: Connecting http://mydomain.com/play/org/apache/log4j/Logger.class with proxy=DIRECT
network: Connecting http://mydomain.com/play/org/apache/log4j/Logger.class with cookie "PHPSESSID=fe5gv8p4hp013r6i9p5aqjska5"
basic: Dialog type is not candidate for embedding
basic: JNLP2ClassLoader.getPermissions() ..
network: Cache entry not found [url: http://mydomain.com/play/org/apache/log4j/Logger.class, version: null]
security: JAVAWS AppPolicy Permission requested for: http://mydomain.com/play/org/apache/log4j/Logger.class
basic: JNLP2ClassLoader.getPermissions() X
java.lang.ClassFormatError: Incompatible magic value 1130458734 in class file org/apache/log4j/Logger
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.defineClassHelper(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.access$100(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader$2.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.plugin2.applet.Plugin2ClassLoader.findClassHelper(Unknown Source)
    at sun.plugin2.applet.JNLP2ClassLoader.findClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at org.project.applet.AppletMain.init(AppletMain.java:32)
    at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.init(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
security: Reset deny session certificate store

Line 32 is

Logger.getRootLogger().setLevel(Level.OFF);

it is first class in applet which should be loaded from external library.

All jars, htmls and jnlps are in http://mydomain.com/play/ and I access applet http://mydomain.com/play/applet.html

From Incompatible magic value 1008813135 I have learned that 1130458734 means Cann and I really get Cannot find block '__global__' if access http://mydomain.com/play/org/apache/log4j/Logger.class.

But I don't understand why searching a class in jar fails, and why it tries to access http://mydomain.com/play/org/apache/log4j/Logger.class which never exist on the server.

EDIT:

My html file somewhere from Oracle tutorials:

<html>
<head>
    <title>MyApplet</title>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <script src="http://www.java.com/js/deployJava.js"></script>
</head>
<body>
    <script>
        var attributes = {code:'org.project.applet.AppletMain', width:1600, height:860} ;
        var parameters = {jnlp_href: 'MyApplet.jnlp'} ;
        deployJava.runApplet(attributes, parameters, '1.6');
    </script>
</body>
</html>
Community
  • 1
  • 1
Nikolay Kuznetsov
  • 9,467
  • 12
  • 55
  • 101
  • I assume the URL in the class path of applet and since the web server returns a message rather than some HTTP File Not Found status code it thinks it has a class it can use. – Peter Lawrey Feb 02 '13 at 09:52
  • *"I don't understand .. why it tries to access http://mydomain.com/play/org/apache/log4j/Logger.class"* See [this answer](http://stackoverflow.com/a/13756665/418556) for the solution to that part. – Andrew Thompson Feb 02 '13 at 10:16
  • Please report back the result of changing the `codebase_lookup` parameter. This conundrum actually seems more complex than just setting a parameter. – Andrew Thompson Feb 02 '13 at 13:01
  • @AndrewThompson, I don't quite get where to put it. In jnlp-file in `applet-desc` tag? – Nikolay Kuznetsov Feb 02 '13 at 13:03
  • My 'eyeball analysis' suggests it should be exactly where it is. OTOH I developed [JaNeLA](http://pscode.org/janela/) because whereas it has '20/20' vision in relation to validity, my grasp of the same is around '5/5'. ;) – Andrew Thompson Feb 02 '13 at 13:09
  • @AndrewThompson, I am using JaNeLa and it is very useful. But it does not report any problem, everything is green. For [JNLP File Syntax](http://docs.oracle.com/javase/6/docs/technotes/guides/javaws/developersguide/syntax.html) there is nothing about `codebase_lookup` – Nikolay Kuznetsov Feb 02 '13 at 13:22
  • @PeterLawrey, now I get your point. But why it starts searching a file, not inside jar? What would be your suggestion? – Nikolay Kuznetsov Feb 02 '13 at 13:28
  • *"But why it starts searching a file, not inside jar?"* because it first encounters the `applet` element and before JWS is ever invoked, we need to navigate the 'applet minefield'. That is why i Suggested using the `codebase_lookup` param. to simplify at least that part. To be honest, I expected to see a new and more useful exception appear after you'd fixed that. Is there (a new and more useful exception)? – Andrew Thompson Feb 02 '13 at 13:33
  • @AndrewThompson, there is no `applet` element. I am using html-file recommended by Oracle. See my edit, please. I really don't know where to put `codebase_lookup`. – Nikolay Kuznetsov Feb 02 '13 at 13:38
  • Huh... Don't know where I got the whole 'applet' idea from. I'll mull it over some more. See if I cam make any **on-topic** comments. (new) .. Oh yeah, it was from ` – Andrew Thompson Feb 02 '13 at 13:39
  • 1
    @PeterLawrey, configuring web-server to respond with 404 seems to solve this issue. I still have couple of more, but would post it in separate questions. If you want I can accept your answer if you post one. – Nikolay Kuznetsov Feb 03 '13 at 13:56
  • @NikolayKuznetsov In your case, I would post your comment as an answer and accept it ;) – Peter Lawrey Feb 03 '13 at 17:39
  • @PeterLawrey, I have done it. Please, see if you have comment any on the next question in the answer. – Nikolay Kuznetsov Feb 04 '13 at 05:09

1 Answers1

0

Peter Lawrey:

I assume the URL in the class path of applet and since the web server returns a message rather than some HTTP File Not Found status code it thinks it has a class it can use.

That was a good guess! The webserver didn't not return 404 error in header for any non found resource, it was returning only some text. So Java interpreted it as if resource was found and was failing trying to load it as Java class.

Nikolay Kuznetsov
  • 9,467
  • 12
  • 55
  • 101