1
votes

I need to run an applet into a Plone application. I've developed the applet that runs fine in a test html page on my localhost, but since I'm a Plone/python/zope noob (java developer here) I can't find the solution. Can anybody help?

Here is the code I'm using.

I created a folder named "java" under the folder "browser", at the same level as "resource"; I registered this new folder in the /browser/configure.zcml file as following:

<browser:resourceDirectory
    name="java"
    directory="java"/>

I put all of my applet files in that folder (the jar itself, the jnlp, the required libraries). If I enter this in the Firefox address bar

http://localhost:8091/Scia/++resource++java/GestioneOneri.jar

I can successfully download the jar file, so it's been registered correctly and I can access it.

The applet needs a parameter (the user currently logged in) so I pass the value into the variable "user".

My page.pt file:

<script tal:define="utenteplone request/AUTHENTICATED_USER" tal:content="string:var user='${utenteplone/getId}'"></script>
<script>
  var attributes = {code:'geotel.gui.Login.class', archive:'portal_url/++resource++java/GestioneOneri.jar, portal_url/++resource++java/mysql-connector-java-5.1.20-bin.jar, portal_url/++resource++java/poi-3.8-20120326.jar, portal_url/++resource++java/forms-1.3.0.jar', width:1024, height:700};
  var parameters = {jnlp_href:'portal_url/++resource++java/gestioneoneri.jnlp', nomeUtente:user};
  var version = '1.6';
  deployJava.runApplet(attributes, parameters, version);
</script>
<noscript>
  No java plugin!
</noscript>

My jnlp:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp href="gestioneoneri.jnlp">
 <information>
   <title>Gestione Oneri Urbanistici</title>
   <vendor>Geotel soc. coop.</vendor>
   <offline-allowed />
 </information>
 <resources>
   <j2se version ="1.6+" initial-heap-size="1000m" max-heap-size="1500m"
  href="http://java.sun.com/products/autodl/j2se" />
   <jar href="portal_url/++resource++java/GestioneOneri.jar" main="true" />
   <jar href="portal_url/++resource++java/mysql-connector-java-5.1.20-bin.jar"/>
   <jar href="portal_url/++resource++java/poi-3.8-20120326.jar"/>
   <jar href="portal_url/++resource++java/forms-1.3.0.jar"/>  
 </resources>
 <applet-desc
     name="Gestione Oneri Urbanistici"
     main-class="geotel.gui.Login"
     width="1024"
     height="700"/>
 </jnlp>

The error Firefox gives me is the following:

ExitException[ 3]com.sun.deploy.net.FailedDownloadException: Impossibile caricare la risorsa: http://localhost:8091/Scia/sportello-unico-edilizia/archivio-pratiche-edilizie/permesso_di_costruire.2012-10-24.5148962026/portal_url/++resource++java/portal_url/++resource++java/GestioneOneri.jar
at sun.plugin2.applet.JNLP2Manager.downloadResources(Unknown Source)
at sun.plugin2.applet.JNLP2Manager.prepareLaunchFile(Unknown Source)
at sun.plugin2.applet.JNLP2Manager.loadJarFiles(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

The path is all wrong: it should be

http://localhost:8091/Scia/++resource++java/GestioneOneri.jar

but I don't know where to put any kind of correction (and WHAT correction to use).

Thanks in advance!

1

1 Answers

1
votes
jnlp_href:'portal_url/++resource++java/gestioneoneri.jnlp'

Together with:

<jnlp href="gestioneoneri.jnlp">

(A JNLP element with no code base) ..will ensure the code base defaults to:

portal_url/++resource++java/

So:

<jar href="portal_url/++resource++java/GestioneOneri.jar" main="true" />

Should be:

<jar href="GestioneOneri.jar" main="true" />

(etc.)