Jar file as RMI codebase

Please tell me I'm missing something:
I have an RMI server that works fine. All I want to do now is package it in a jar file...Sounded easy enough when I got started.
According to the RMI tutorial, the value of the codebase property can refer to
1. The URL of a directory in which the classes are organized in package-named sub-directories.
OR
2. The URL of a JAR file in which the classes are organized in package-named directories.
OR
3. A space-delimited string containing multiple instances of JAR files and/or directories that meet the criteria above.
Setting the codebase property on the commend line like this:
-Djava.rmi.server.codebase=file:/my_dir/my_jar_file.jar
gives an UnmarshalException with a nested ClassNotFoundException indicating that my Stub file is missing.
However, if I unpack the jar to the directory my_dir/classes and use
-Djava.rmi.server.codebase=file:/my_dir/classes/
then everything works fine... so I know there are no files missing from the jar file
Any ideas?
Thanks in advance,
Matt.

jquattro, thanks for the reply. Only problem is that I'm adding to a pre-existing jar file rather than creating a new one, so I don't want to change it other than adding the extra classes.
I found that it worked fine on a Windows box, so I tried a different jdk on unix, and found that it works fine if I use the jdk1.3 RMI registry - so it appears it might have been a bug in jdk1.2 on Unix.

Similar Messages

  • Reading from the Applet's JAR file.

    Is it possible to read a file stored in the jar file that the (unsigned) applet is being executed in? I have a line that goes like (in is just an InputStream):
    in = getClass().getResource( "/exercise.xml" ).openStream();
    and then, in another class, i do (bulider is an instance of javax.xml.parsers.DocumentBuilder, created from the DocumentBuilderFactory class):
    doc = builder.parse( in );
    but this always results in a security exception (works fine from the applet viewer). I tried specifying the full path to the .jar file as the codebase, but got the same results. I have not tested this from an actual web server, i am only opening the .html file directly in IE.
    Due to the nature of the application, it is not possible to host the file seperately on a webserver.
    It seems to me that there is no reason an applet shouldnt be allowed to load a file from the .jar it is executing in, could this simply be a problem of the file being local, and thus linked to from a file:// tag?
    Thanks for any help.
    Thomas Stephens

    Hi Guys
    I have figured out this problem. It's got to do with classloader.
    Applet uses a separate classloader. So using the static getSystemResource(),
    we never get contents from applet jar files. The following will work nicely.
    It is noted that you must loacate the applet classloader as in the first line
    and use the non-static method getResource();
    ObjectInJar obj = new ObjectInJar(); // create an object with a class in the jar file.
    ClassLoader cl = obj.getClass().getClassLoader();
    InputStream stream = cl.getResource("your_filepath_in_jar").openStream();
    Cheers.

  • How to convert a .jar file to a .sda

    Hi,
    I have a login module which is created in the form of .jar file. I was deploying this login module using the Deploy tool(deploy.bat).
    Now I am looking for deploying my login module using the SDM, which happens to be the recommended mode with NW04.
    I have two questions related to creation of SDA, for which I am looking for urgent help:
    1. How can I create a .sda file from the .jar file? I do not want to create the .sda file directly from the codebase as I already have the command line build process setup to create a jar file from the codebase
    2. How can step1 be accomplished from command line?
    Appreciate if someone can help me out. I searched at many places but could not find anything related to this conversion.
    Thanks,
    Vishal.

    Hi,
    Tools like zipgenius http://www.zipgenius.it/intweb/features.htm#Innovazione,  Private encryptor http://www.filesweb.com/private-encryptor/ and securefile http://www.devsolutions.net/htmlpages/securefile.html should help you further.
    Eddy

  • Iconic (gif) jar files

    Just curious, how does forms know the name of the jar file in the codebase directory to search when loading icon (gifs). Or does it search every jar file in that directory?
    thx,
    r.b.

    > how does forms know the name of the jar file in the
    codebase directory to search when loading icon (gifs).
    You add the jar file to the archive_jini parameter. The gif in the jar file has a path. (If there's no path, then it's just /.) Your serverApp file (registry.dat) has the path where the icons reside.
    So if your registry.dat file has, say, /myicons as the path, then your jar file, called appicons.jar contains the icons in the path /myicons.
    You specify appicons.jar in the archive_jini parameter. That way it gets downloaded to the client.
    Now the client has the jar, which has the icons. And client has the path. Voila!
    > and what happens when it doesn't find a specific gif
    in the jar file?
    Don't do that. :)
    Seriously, I don't know what happens. I suspect the Form runs fine but there's no image where the icon should be.
    You may get an error in the java console, I'm not sure.
    Regards
    Robin Zimmermann
    Forms Product Management

  • Can't start RMI server using JAR file

    I found it interesting that if I start my RMI server from
    a plain directory, everything goes fine.
    But if I jar all these necessary files into a jar file,
    and start my RMI server with command below
    java -jar server.jar
    UnmarshalException and ClassNotFoundException are
    thrown to indecate that my stub class can't be found
    (which I'm sure my stub class is in jar file)
    Why is jar file so special that it can't act like
    what it originally does when it hasn't been jared?
    or I really should take care of some configuration
    before I really can run a jar file?
    thanks

    To clarify few things...
    What I don't understand is that when I convert all my
    directories and class files properly into the jar file, they
    just can't work properly.
    I don't know if it's a problem of JAR file,
    or it's RMI that make this JAR file special?
    I'll simulate my JAR file structure that listed below,
    these structure works fine when they have'nt been
    converted into JAR file.
    META-INF/
    META-INF/MANIFEST.MF
    a/b/x1.class
    a/b/x2.class
    a/b/c/Y.class
    a/b/c/Y_Skel.class
    a/b/c/Y_Stub.class
    And when I use command "java -jar server.jar"
    to run my application, ClassNotFound exception
    is thrown to indecate my stub class is not found.
    Is there anything I can do to correct this?
    thanks

  • JAR files/codebase

    Sorry for the crosspost, but it's been a week & no one responded in the other forum.
    I've created a JAR file that has the following directories:
    applet\data
    applet\util
    applet\widgets
    applet\reports
    applet\maintenance
    applet\service
    When I view the JAR file via WinZip, the .class files appear as expected (with the directories intact).
    The JAR file (SSwifts.jar) is stored in the /classes folder on the web server. The OBJECT tag of the applet looks like this:
    <OBJECT classid="clsid:CAFEEFAC-0014-0001-0002-ABCDEFFEDCBA"
    width="190"
    height="90"
    align="middle"
    codebase="deploy/j2re-1_4_1_02-win.exe#Version=1,4,1,2">
    <PARAM NAME="code" VALUE="SwiftsApplet">
    <PARAM NAME="codebase" VALUE="classes/">
    <PARAM NAME="archive" VALUE="SSwifts.jar">
    <PARAM NAME="type" VALUE="application/x-java-applet;jpi-version=1.4.1_02">
    </OBJECT>
    However, when attempting to run the applet, the ClassNotFoundException error appears.
    As a test, I reccompiled the app, but moved the SwiftsApplet to the default package (which I understand is not good practice, but...). This seemed to correct the problem. However, I don't want to move everything to the default package.
    Is the problem in the codebase specification? What should it be? Is the problem the JAR creation? How should that be handled?
    Thanks for any help you can provide.
    Van Williams

    I think I just figured this out. The 'code' parm needed to include the path (package).
    Thanks,
    Van Williams

  • Trouble with RMI codebase

    Hi, i've created a file transfer application via RMI, it work very well, i can transfer file longer than 1 GB without any problem.
    But when i copy my project with all classes to another directory, it doesn't work. I'm sure that the trouble is in the VM options :
    "-Djava.rmi.server.codebase=file:E:\RMIFileTransfer\classes\ -Djava.security.policy=file:E:\RMIFileTransfer\policy\RMI.policy ", that points to the old directory. I don't want to change "E:\RMIFileTransfer\" in the VM options each time i move my project!!!
    How can be java.rmi.server.codebase and java.security.policy properties setted by an user input, or in the main( String args[] ) method? (sorry for my bad english...)

    (a) use a JAR file, not a directory system
    (b) the codebase setting has to have the same meaning throughout the system, i.e. to the server, the registry, and the client. Obviously a file: URL is not likely to comply, because every host has its own file system. Have a look into providing the JAR file via an HTTP service and using an http: URL.

  • RMI codebase confusion

    You'll have to excuse me if I am asking stupid questions, but I can't find the information I want in the documentation. I am working on an RMI client-server project with 3 jars client.jar, common.jar, server.jar. The common jar contains a Remote interface which the client looks up, and the server implements. The stub class is contained in the server jar (obviously).
    Currently our method of distribution is to distribute all 3 jars to the client machines - I want to avoid this as it is unnecessary. I would therefore like to set java.rmi.codebase property in the server so that clients can download the stub classes at run-time. OK.
    Our RMI app is being distributed on an internal network - suppose on the server machine (call it "ourserver.london.uk.ourco.com", the relevant Jar file would be at /usr/bin/my_app/jars/server.jar (or wherever).
    The clients lookup rmi://ourserver.london.uk.ourco.com:1099/MY_EXPORTED_REMOTE. Questions:
    1. Is this RMI "system" dependent on the server having an Http server?
    2. If it isn't, how do I define the codebase other than "http://..."?
    3. If it is (and the machine certainly does have an http server on it), how do I specify the codebase URL for the clients, given that the server is not "under" the http server (IYSWIM)?
    I'd be glad of answers to these (reasonably simple) questions.
    Chris

    First of all, I would arrange things a bit differently. In both of the cases below, we assume a http server, it's location is unimportent, but it has to be reachable from the the client. It could be the same host as the server, or a third machine.
    Option #1:
    client.jar -- All client class files, including all class files of remote interfaces called by the client.
    server.jar -- All server class files, including all stubs, and remote interfaces implemented and their implementations.
    server_dl.jar -- Just the stubs.
    The client host would contain just client.jar in the classpath.
    The server host would contain server.jar and server_dl.jar in its classpath
    server_dl.jar would also be placed on the http server and it's url would be the server's codebase.
    Option #2:
    client.jar -- All client class files, but none of the remote interfaces.
    server.jar -- All server class files, but none of the stubs and no remote interfaces.
    interfaces.jar -- The remote interfaces shared by client and server.
    server_dl.jar -- just the stubs.
    The client host would need client.jar and interfaces.jar in its classpath.
    The server host would need server.jar, interfaces.jar and server_dl.jar in its classpath.
    server_dl.jar would also be placed on the http server and it's url would be the server's codebase.
    Now to answer your questions.
    1. Is this RMI "system" dependent on the server having an Http server?If you want to have the client download the server stubs, then they have to be on an http server (I think a ftp url for the codebase may also work, but I have not tried it).
    2. If it isn't, how do I define the codebase other than "http://..."?
    You may be able to use a ftp url in which case the url would be "ftp://....."
    3. If it is (and the machine certainly does have an http server on it), how do I > specify the codebase URL for the clients, given that the server is not "under"
    the http server (IYSWIM)?The downloaded class files do not have to be on a http server that is on the same host as the RMI server. The RMI server's codebase can be any valid url (reachable from the clients) The only requirement is that the class files be reachable via the codebase. You do have to configure the client's network security so that it has permission to open connections to the codebase server.

  • What do jar files give me?

    I've been running my application under Eclipse and now I want to run it without the SDK. Thus I made a jar file and tried running with it. It didn't give me anything as I had to create my package structure in addition to the jar file, and I needed all the class files.
    I'm sure there must be a better way to do this (what I thought the jar would do for me), but I don't know what it is.
    Any suggestions?
    Thanks,
    Ilan

    OK, finally some progress. The JAR file sounds like EXACTLY what I need. Now just to know how to operate it correctly. (Thanks for the link to the documentation.)
    I'm not yet doing it correctly:
    G:\java>java -jar -cp . -Djava.security.policy=g:\java\rmi_security.policy -Djav
    a.rmi.server.codebase=file:/g:/java/readstudies.jar -Djava.rmi.server.hostname=h
    ome-ilan readstudies.jar
    Failed to load Main-Class manifest attribute from
    readstudies.jarIn order to see the contents of the Eclipse produced JAR, I changed its extension to zip and then WinZip shows me it has
    Manifest.mf
    StudiesEngine.class
    Query.class
    DicomFormat.class
    Previously my bat file was
    start c:\progra~1\java\jre1.6.0_01\bin\rmiregistry
    java -cp . -Djava.security.policy=g:\java\rmi_security.policy -Djava.rmi.server.codebase=file:/g:/java/readstudies.jar -Djava.rmi.server.hostname=home-ilan engine/StudiesEngineand I just wasn't using the JAR file. I had to add -jar and tell it to use readStudies.jar.
    What I don't understand is how I tell it to use engine/StudiesEngine? Is this what the error message is trying to tell me?
    Thanks,
    Ilan

  • How to authenticate a JWS Client download of jar files on a web server

    Here is a history of how i tried to implement the auth system:
    The resources(jar files) cannot be downloaded by any HTTP client from the server without some authentication method.
    As JWS is not reliable when using cookies (only 1.5 supports them, but with problems when in JNLP file i specify j2se version=older that 1.5) , i implemented another mecanism that works like this:
    1. 1.The template JNLP looks like this
    <?xml version="1.0" encoding="utf-8"?>
    <jnlp codebase="http://10.3.0.62/" href="mapped/#JWS_CODE#___#PLATFORM#___app2.2.jnlp">
        <information>
           bla bla
        </information>
        <security>
            <all-permissions/>
        </security>
        <resources>
            <j2se version="1.4"/>
            <jar href="http://10.3.0.62/mapped/gui.jar?jwsid=#JWS_CODE#" version="2.2"/>
            <jar href="http://10.3.0.62/mapped/data.jar?jwsid=#JWS_CODE#" version="2.2"/>
            <jar href="http://10.3.0.62/mapped/log4j.jar?jwsid=#JWS_CODE#"/>
        </resources>
        <application-desc main-class="com.bet.blues.gui.Application">
            <argument>-host</argument>
            <argument>ursus</argument>
            <argument>-port</argument>
            <argument>17771</argument>
        </application-desc>
    </jnlp>2. All resources found in /mapped/ directory are mapped to JWSServlet
    3. The users login to a site , clik on link , /mapped/app2.2.jnlp , the servlet checks if the session is active , gets the PLATFORM form browser request header , gets the JWSCODE for the logged user, replaces this in the template, and returns it to the client
    4.Now after the 1st download the JNLP file is opened by JWS Client , that checks for latest version , requesting the JNLP file again
    like this:
    GET http://10.3.0.62/mapped/f12ks21092___windows___app2.2.jnlp5.Now the servlet sees the the request has a JNLP file name with an ID and PLATFORM, and serves the JNLP as before
    6.The JWS Client will request for JAR Files
    GET http://10.3.0.62/mapped/gui.jar?jwscode=f12ks21092?version-id=2.2Note: that i have forced JWSID parameter in the URL, that's why the query string contains 2 "?"
    - forcing this is because the mapped/*.jar is redirected JnlpDownloadServlet that supports versions , diffs - i cannot use 'version' to put there the jswid param(e.g .../mapped/gui.jar version="fk12ks21092_2.2" because the JnlpDownloadServlet will not find this version , and if JWS Servlet will redirect to JnlpDownloadServlet with correct version param in request, the JWS Client will raise an exception because version responded is not right(JNLPDownloadServlet marks in response HTTP header the version of the jar so JWS CLient will chek it)
    JWS Client expects version 'fk12ks21092_ver2.2'; to correct this i should modify the JnlpDownloadServlet and i shouldnt
    THE PROBLEM :
    on older versions than 1.5 JWS Client raises an exception because it wants to create a temp file named
    " gui.jar?jwscode=f12ks21092" because it contains "?"
    Only with 1.5 that seems to parse the jar name until it meets "?" char :(
    Thats why i wanted to send an error to the client to upgrade to Java Web Start 1.5
    Now, maybe u have a solution to this problem...
    All i want is a solution to let JWS Client download jars only if the user is authenticated by some mecanism....and also support the versioning system.
    Also:
    Note that the jar names must preserve on the client JWS Cache dir ( i cannot use the same method to pass the JWSCODE when requesting the JARS as when requesting the JNLP).

    You need to look into JAAS

  • Jar file is not cached

    Hi,
    I have a problem in caching the jar file. When the browser was closed and then open again, it tries to load the jar file from the web server again. It seems the jar file is never cached in the Java-Plug in. Here is the code for the page:
    <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    width=80% height=70% hspace="10" vspace="10" align="middle"
    codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_4_2-windows-i586.cab"
    standby="Please wait...">
    <PARAM name="type" value="application/x-java-applet">
    <PARAM name="codebase" value="/">
    <PARAM name="cache_archive" value="w1.jar">
    <PARAM name="cache_option" value="Plugin">
    <PARAM name="code" value="Proteus.class">Web Motion Control Applet</OBJECT>
    Any idea?
    Thanks for the help!

    Have the same nasty issue here - beginning with 1.4.2 we see that the java plug-in add
    Cache-Control: no-cache
    Pragma: no-cache
    to the HTTP request when downloading the JAR file (also happen when JAR is already in local plug-in cache). Therefore the web server always sends a HTTP 200 with full content instead of a lightweight HTTP 304 Not Modified.
    See also: Bug: 4837340 comment from mwwsun
    Is there a way to disable the explicit "no-cache" request?
    Keep the byte.
    C�dric

  • How to execute a jar file in other machine?

    Hi all,
    I am working with java. and my machine is connected to LAN.I would like to execute a jar file in my machine from a remote machine that is also connected to LAN.how should i go about doing this.Help me if somebody have a solution as i am badly in need of this.
    Regards,
    Mohan

    Hi Mohan.tkm,
    If you want it to be done in pure Java and independently of the OS of both computers, you may build a RMI server that will launch your JAR by request of a remote RMI client.
    There's an example of RMI here .

  • Problems with signed JAR files in JWS/JRE6 environment.

    Hello All,
    I'm encountering a problem running our desktop application as a Java Web Start deployment in a JRE 6 environment. There were never any problems when running the same application as a JWS deployment in JRE 1.4, or 5, environments. There are also currently no problems in a JRE 6 environment when running the application as a standard desktop application.
    The problem which I am having has nothing to do with launching the application. But for good measure, I verified the JNLP file with JaNeLA. A couple things we out of order, which I addressed to make JaNeLA happy, but my problem still persists. Here is my JNLP file (anonymized to protect the innocent):
    TS: 2010-10-18 17:04:46
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp codebase="$$codebase" href="$$name">
         <information>
              <title>Acme Desktop</title>
              <vendor>Acme Corporation</vendor>
              <homepage href="http://www.acme.com/"/>
              <description>Acme Client for Acme Server</description>
              <description kind="tooltip">Acme Client for Acme Server</description>
              <icon href="desktop.gif"/>
              <offline-allowed/>
         </information>
         <security>
              <all-permissions/>
         </security>
         <resources>
              <j2se version="1.5+"/>
              <jar href="acmedesktop.jar" download="eager" version="8.00.01.00+"/>
              <jar href="lib/antlr-2.7.2.jar" download="eager" version="8.00.01.00+"/>
              <jar href="lib/backport-util-concurrent.jar" download="eager" version="8.00.01.00+"/>
              <jar href="lib/commons-codec-1.3.jar" download="eager" version="8.00.01.00+"/>
              <jar href="lib/commons-httpclient.jar" download="eager" version="8.00.01.00+"/>
              <jar href="lib/commons-logging.jar" download="eager" version="8.00.01.00+"/>
              <jar href="lib/acmeapi.jar" download="eager" version="8.00.01.00+"/>
              <jar href="lib/HelpJavaDT.jar" download="eager" version="8.00.01.00+"/>
              <jar href="lib/HelpJavaDT_es.jar" download="eager" version="8.00.01.00+"/>
              <jar href="lib/jacorb.jar" download="eager" version="8.00.01.00+"/>
              <jar href="lib/Multivalent.jar" download="eager" version="8.00.01.00+"/>
              <jar href="lib/slf4j-api-1.5.6.jar" download="eager" version="8.00.01.00+"/>
              <jar href="lib/slf4j-jdk14-1.5.6.jar" download="eager" version="8.00.01.00+"/>
              <jar href="lib/snow.jar" download="lazy" version="8.00.01.00+"/>
              <jar href="lib/AcmeTMClient.jar" download="eager" version="8.00.01.00+"/>
              <jar href="lib/xercesImpl.jar" download="eager" version="8.00.01.00+"/>
              <jar href="lib/xml-apis.jar" download="eager" version="8.00.01.00+"/>
              <extension name="installer" href="desktopInstaller.jnlp" />
              <extension name="Java Help" href="help.jnlp"/>
              <property name="java.library.path" value="./lib"/>
              <property name="admin" value="false"/>
              <property name="webstart" value="true"/>          
              <!-- The following two lines are for SSO implementation only
              <property name="urladdress" value="http://localhost:8080/AcmeDesktop/servlet/AcmeServlet"/>
              <property name="cookiespec" value="RFC2109"/>
              -->          
         </resources>
         <resources os="Windows">
              <nativelib href="lib/jniWin32.jar" version="8.00.01.00+"/>
         </resources>
         <application-desc main-class="desktop"/>     
    </jnlp>-----
    When running as a JWS deployment, on JRE 6, the application will be functioning normally for a little while, and then suddenly the following exception is thrown, and the current operation fails because the class in question cannot be accessed:
    java.lang.SecurityException: class "acmeapi.communication.CDocImpl"'s signer information does not match signer information of other classes in the same package
         at java.lang.ClassLoader.checkCerts(ClassLoader.java:807)
         at java.lang.ClassLoader.preDefineClass(ClassLoader.java:488)
         at java.lang.ClassLoader.defineClassCond(ClassLoader.java:626)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
         at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
         at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
         at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
         at com.sun.jnlp.JNLPClassLoader.findClass(JNLPClassLoader.java:288)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
         at acmeapi.common.CDoc.getAnnotationsInfo(CDoc.java:493)
         at acmedesktop.communication.CCommunicationManager.privateGetAnnotations(CCommunicationManager.java:1976)
         at acmedesktop.communication.CCommunicationManager.getAnnotations(CCommunicationManager.java:1828)
         at acmedesktop.annotations.CViewAnnotations.getAnnotations(CViewAnnotations.java:826)
         at acmedesktop.annotations.CViewAnnotations.createView(CViewAnnotations.java:583)
         at acmedesktop.annotations.CViewAnnotations.setData(CViewAnnotations.java:736)
         at acmedesktop.annotations.CViewAnnotations.init(CViewAnnotations.java:205)
         at acmedesktop.hitspanel.CHitsPanel.viewAnnotations(CHitsPanel.java:281)
         at acmedesktop.hitspanel.CHitsTab$3.mousePressed(CHitsTab.java:316)
         at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:263)
         at java.awt.Component.processMouseEvent(Component.java:6260)
         at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
         at java.awt.Component.processEvent(Component.java:6028)
         at java.awt.Container.processEvent(Container.java:2041)
         at java.awt.Component.dispatchEventImpl(Component.java:4630)
         at java.awt.Container.dispatchEventImpl(Container.java:2099)
         at java.awt.Component.dispatchEvent(Component.java:4460)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4235)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
         at java.awt.Container.dispatchEventImpl(Container.java:2085)
         at java.awt.Window.dispatchEventImpl(Window.java:2478)
         at java.awt.Component.dispatchEvent(Component.java:4460)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
         at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
         at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)-----
    The classes of our desktop product are contained within the 'acmedesktop' and 'acmeapi' packages. It requires access to the hard drive of the workstation, and therefore, all jar files included with the application are signed using the following ANT task when compiled:
    <signjar keystore="resources/codesigning/keystore.pfx" storetype="pkcs12" storepass="myPassword" alias="myAlias">
         <fileset dir="${jws_dist}/app" includes="*.jar"/>
         <fileset dir="${jws_dist}/app/lib" includes="*.jar" excludes="jhall__V${dt_version}.jar"/>
    </signjar>-----
    Therefore, all classes, within all jar files, are signed with the same certificate (with the exception of the JavaHelp libraries, which are already signed by Sun - but the class in question attempting to be loaded here is not contained within the JavaHelp jar file anyway). So, the point being, that the exception message stating that the "signer information of the acmeapi.communication.CDocImpl class doesn't match the signer information of other classes in the same package", is simply not correct. All classes within that jar file were signed using the same certificate.
    I downloaded the JRE 6 source from dev.java.net and picked through this issue with a debugger. The ClassLoader.checkCerts() method compares the certificate used to sign the current class which is attempting to be loaded, with the certificates which signed all other previously loaded classes within the same package. If they don't match, the exception above is thrown. What is causing the issue is when the checkCerts() method attempts to get the certificates which signed the currently loading class, null is returned. And obviously, comparing null, with an array of the certificates which signed the previously loaded classes, isn't going to match; therefore this exception is thrown.
    The checkCerts() method gets the certificates of the currently loading class by calling the java.security.CodeSource.getCertificates() method. Tracing deeper in the debugger, the CodeSource object ultimately gets the certificates from the 'signersRef' member variable of the com.sun.deploy.cache.CachedJarFile class. signerRef is a SoftReference object and can therefore be garbage collected at some point. If it has already been garbage collected, the CachedJarFile class will attempt to retrieve it again from the loaded cache entry by calling com.sun.deploy.cache.MemoryCache.getLoadedResource().
    The MemoryCache class maintains the cache entries to the jar files as MemoryCache.CachedResourceReference objects, which subclass WeakReference, and therefore these objects can be garbage collected as well. If the cache entries have also been garbage collected, this leaves the CachedJarFile class with no ability to repopulate the CachedJarFile.signerRef object. Therefore it is completely out of luck getting the certificates which signed the currently loading class, which ultimately causes the above exception.
    When the com.sun.deploy.cache.Cache class attempts to retrieve a cache entry using its getCacheEntry() method, it will attempt to get the entry from the MemoryCache class, if null is returned, it will recreate the cache entry and add it back to the MemoryCache. In contrast, when the CachedJarFile class attempts to get a cache entry from the MemoryCache class, if null is returned, it just gives up.
    (from com.sun.deploy.cache.CachedJarFile:244)
    private CacheEntry getCacheEntry() {
         /* if it was not created by Cache do not search for entry */
         if (resourceURL == null)
              return null;
         CacheEntry ce = (CacheEntry) MemoryCache.getLoadedResource(resourceURL);
         if (ce == null) {
              //This should not happen because CacheEntry should not get collected
              // before CachedJarFile is collected.
              Trace.println("Missing CacheEntry for " + resourceURL + "\n" + ce,
                   TraceLevel.CACHE);
         return ce;
    When debugging, code execution falls within the code block with the comment stating "This should not happen...", but it is happening in my case.
    On an interesting side note, using the jvisualvm.exe tool included with JDK 6, I was able to tell that it seems as though these objects are collected the first time that the JVM allocates more heap space, and then the issue will occur. If I set the initial heap size very large (using -Xms) this issue won't occur at all. But that is kind of a bad solution which I would rather not do, but it is interesting to note for the sake of troubleshooting this issue. The max heap size (-Xmx) is plenty big enough, so the issue is not that we are running out of memory here.
    Does anyone have any insight as to what could be causing this? I've searched, and found a couple threads with similar problems but with no clear solutions. It is not just one workstation either, it happens everywhere I deploy the app as a Java Web Start application in a JRE 6 environment. I have been using version 1.6.0_18 on XP, but it seems to happen on any update version of 1.6. Is the fact that the CachedJarFile class doesn't attempt to reload the resource when it can't retrieve it from MemoryCache a bug? I've dug as deep as I can on this and I'm at wits end, does anybody have any ideas?
    Thank you
    Jake
    Edited by: jkc532 on Nov 12, 2010 10:35 AM

    jkc532 wrote:
    .. Is the fact that the CachedJarFile class doesn't attempt to reload the resource when it can't retrieve it from MemoryCache a bug? From your comprehensive investigation and report, it seems so to me.
    ..I've dug as deep as I can on this and I'm at wits end, does anybody have any ideas?Just after read the summary I was tired, so I have some understanding of the effort you have already invested in this (the 'wits' you have already spent). I think you should raise a bug report and seek Oracle's response.

  • Deploying a jar file

    I just downloaded and installed the jdk1.3.1 into the root of my local drive. I am not sure if I am using the software correctly, I am launching a dos shell and cd to the directory c:\windows\desktop\internet, which is where the necessary files are stored. In this directory I have three class files and want to put them in a jar file. After I dir the above directory I type:
    jar cvf classes.jar internet$SymAction.class internet$SymText.class internet.class
    It seems to work correctly and creates classes.jar in the internet folder. In the html code I have,
    <applet code="classes.jar" width="698" height="326" align="middle"></applet>
    When I launch the html file, which is located in the internet folder as well, I get the error, load: class classes.jar not found. Is there something else I need to add to the applet tag?

    Hi,
    You need to add the archive attribute to your applet tag:
    archive = "classes.jar"
    you may also want to add codebase if you plan on adding images, sounds, etc. to the jar later on.
    codebase = "classes.jar"
    And finally if you use any of the 1.3 API's then you need the java plug-in and must use the OBJECT tag not the APPLET tag. See this link for further details:
    http://java.sun.com/products/plugin/
    One last tip, you can use this method to build your jar too:
    jar cvf classes.jar *.class
    and that will add all of the .class files in your folder to the archive (after you navigate to c:\windows\desktop\internet as you did before).
    -Ron
    Almost everything you wanted to know about the APPLET tag:
    http://java.sun.com/docs/books/tutorial/applet/appletsonly/html.html

  • Protecting the jar files from being web access

    I have a jnlp file which is put under tomcat webapps folder, say (\webapps\TEST\launch.jnlp), with the jar and lib files put in the subfolder (\webapps\TEST\folder1\*.jar AND \webapps\TEST\folder1\lib\*.jar).
    My question is how can i prevent user from direct access to the jar files via typing http://www.someip.com/TEST/folder1/main.jar ? I tried the following methods but it seemed not working:
    1. Change the folder permisson in \webapps\TEST\*.*, but when user type the above hyperlink they can still get the jar file
    2. put the jar and related files under \WEB-INF\, but now this time running the launch.jnlp, it returns an error saying that it can't access/find the WEB-INF.
    Is there any method? Or should I say, when you published jnlp to web, the related jar files are forced to be accessed by everyone.

    Sounds easy to me: encrypt your xml, then instead of just storing your key as plain bytes do some reversable operations on it (xor masks, reversions, whatever you like), just do them in many different points (and classes) of your code, have some parts done by methods that actually check application is running under JWS with proper codebase, scramble it all, and suddently the whole stealing operation won't be worth the effort. Obviously you should have many private (and package protected) methods, seal packages and so on. Maybe, somehow, you can even use reflection to identify calling classes (not sure, never looked for anything similar).
    What else? write down some c++ code into your own dll/JNI library and make it do something too, so they'll even need to decompile the dll. If you know first execution is always online you can send another xor key and store it with persistence service or write it down to windows registry. You can keep making it harder as much as you like, even just with silly code like
    Math.ceil((new GregorianCalendar.getField(Calendar.YEAR)%2000)/1000)*((int)('c'-'a'))just to retrieve the number 2. If you distribute such code through many lines and methods, once you scramble it, most people will give up.
    Bye.

Maybe you are looking for