Error with Java WebStart Signed Jars on 1.6.0_19's new Mixed  Code

All,
First, we have a valid code signing certificate/keystore from Thawte that works for signing webstart jars as of update 18. For some reason, if you run our webstart application on update 19 JRE, the runtime believes that some of the jars are not signed and some are. Even though we create and sign the jars in the exact same way and after inspecting the jar the JRE believes are not signed they have the necessary signing entries/files in the manifest folder. Not sure why the signing process would work for some of our jars and not for others. There is nothing really all that different.
So, because the JRE believes some of the jars are not signed the new security warning "...contains both signed and unsigned code." pops up ( [Error Description|http://java.com/en/download/help/error_mixedcode.xml] ). If I press yes, then I get the following exception.
java.lang.SecurityException: trusted loader attempted to load sandboxed resource from https://path-to-our.jar
     at com.sun.deploy.security.CPCallbackHandler$ParentCallback.check(Unknown Source)
     at com.sun.deploy.security.CPCallbackHandler$ParentCallback.access$1400(Unknown Source)
     at com.sun.deploy.security.CPCallbackHandler$ChildElement.checkResource(Unknown Source)
     at com.sun.deploy.security.DeployURLClassPath$JarLoader.checkResource(Unknown Source)
     at com.sun.deploy.security.DeployURLClassPath$JarLoader.getResource(Unknown Source)
     at com.sun.deploy.security.DeployURLClassPath.getResource(Unknown Source)
     at java.net.URLClassLoader$1.run(Unknown Source)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.net.URLClassLoader.findClass(Unknown Source)
     at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
     at java.lang.ClassLoader.loadClass(Unknown Source)
     at java.lang.ClassLoader.loadClass(Unknown Source)
     at main.JwsMain.main(JwsMain.java:32)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
     at java.lang.reflect.Method.invoke(Unknown Source)
     at com.sun.javaws.Launcher.executeApplication(Unknown Source)
     at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
     at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
     at com.sun.javaws.Launcher.run(Unknown Source)
     at java.lang.Thread.run(Unknown Source)If I press "no" I get the following exception (I get this exception if I try to run our WebStart application with no signed jars as well, no warnings about missing certs, just straight to error)
java.lang.NullPointerException
     at com.sun.deploy.cache.CachedJarFile.findMatchingSignerIndices(Unknown Source)
     at com.sun.deploy.cache.CachedJarFile.entryNames(Unknown Source)
     at com.sun.deploy.cache.DeployCacheJarAccessImpl.entryNames(Unknown Source)
     at com.sun.deploy.security.CPCallbackHandler.assertTrust(Unknown Source)
     at com.sun.deploy.security.CPCallbackHandler.access$700(Unknown Source)
     at com.sun.deploy.security.CPCallbackHandler$ParentCallback.check(Unknown Source)
     at com.sun.deploy.security.CPCallbackHandler$ParentCallback.access$1400(Unknown Source)
     at com.sun.deploy.security.CPCallbackHandler$ChildElement.checkResource(Unknown Source)
     at com.sun.deploy.security.DeployURLClassPath$JarLoader.checkResource(Unknown Source)
     at com.sun.deploy.security.DeployURLClassPath$JarLoader.getResource(Unknown Source)
     at com.sun.deploy.security.DeployURLClassPath.getResource(Unknown Source)
     at java.net.URLClassLoader$1.run(Unknown Source)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.net.URLClassLoader.findClass(Unknown Source)
     at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
     at java.lang.ClassLoader.loadClass(Unknown Source)
     at java.lang.ClassLoader.loadClass(Unknown Source)
     at main.JwsMain.main(JwsMain.java:32)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
     at java.lang.reflect.Method.invoke(Unknown Source)
     at com.sun.javaws.Launcher.executeApplication(Unknown Source)
     at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
     at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
     at com.sun.javaws.Launcher.run(Unknown Source)
     at java.lang.Thread.run(Unknown Source)Does anyone know why this would be happening? It only occurs with the new update. We use the same keystore and process for signing all of our jars so it really doesn't make since why some of them work and some of them don't. Also, our JNLP is correct or it wouldn't work in update 18.
Edit: We've tried it on Windows XP SP3 and compiled the code using update 18 and used jarsigner both from 18 and 19 with same results.
Edited by: chenthor on Apr 1, 2010 8:44 AM
Edited by: chenthor on Apr 1, 2010 8:51 AM

Hi All,
So we've been battling this bug for a year or so now, and I've come up with a solution to the webstart bugs
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6967414
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6805618
(see the bugs for more details)
From what we can tell the bug stems from the way that the jar signers information is "cached" by webstart.
When a jar is loaded by webstart, it is represented by a CachedJarFile instance. When loading and using classes the signature for the jar is verified. The signers used is the one that is stored in the CachedJarFile instances. These "signers" are stored as SoftReferences. SoftReferences are like WeakReferences, except that they only become eligible for garbage collection when there is a small amount of available heaps space remaining and that the object is only softly reachable. (That's a pretty crude description, but it will do for now)
So what we found was happening is that when the JVM reached a certain heap size threshold and needed to allocate more heap, that these soft references (and hence the signers information) werebeing garbage collected. if you attempt to load a class after this you get the security error.
So I came up with a hack to work around this. At application startup, iterate through all of the CachedJarFile objects on the classpath and create a hard reference to each of the signers info by putting them in a static list somewhere. From our tests this seems to work. (though with the intermittent nature of the problem, it has been hard to prove conclusively, though we've had some success repro-ing the issue, by reducing the intial heap size and using VisualVM to watch for heap expansions and forcing gc's)
Below is the code for the hack, to run it just call JarSignersHardLinker.go() and it will do some sanity checks (running on webstart on java 1.6 update 19 or higher) before spawning a new thread to create hard refs for all signers info for all jars on the classpath.
import java.io.IOException;
import java.lang.ref.SoftReference;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.JarURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.jar.JarFile;
* A utility class for working around the java webstart jar signing/security bug
* see http://bugs.sun.com/view_bug.do?bug_id=6967414 and http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6805618
* @author Scott Chan
public class JarSignersHardLinker {
    private static final String JRE_1_6_0 = "1.6.0_";
     * the 1.6.0 update where this problem first occurred
    private static final int PROBLEM_JRE_UPDATE = 19;
    public static final List sm_hardRefs = new ArrayList();
    protected static void makeHardSignersRef(JarFile jar) throws java.io.IOException {
        System.out.println("Making hard refs for: " + jar );
        if(jar != null && jar.getClass().getName().equals("com.sun.deploy.cache.CachedJarFile")) {
             //lets attempt to get at the each of the soft links.
             //first neet to call the relevant no-arg method to ensure that the soft ref is populated
             //then we access the private member, resolve the softlink and throw it in a static list.
            callNoArgMethod("getSigners", jar);
            makeHardLink("signersRef", jar);
            callNoArgMethod("getSignerMap", jar);
            makeHardLink("signerMapRef", jar);
//            callNoArgMethod("getCodeSources", jar);
//            makeHardLink("codeSourcesRef", jar);
            callNoArgMethod("getCodeSourceCache", jar);
            makeHardLink("codeSourceCacheRef", jar);
     * if the specified field for the given instance is a Softreference
     * That soft reference is resolved and the returned ref is stored in a static list,
     * making it a hard link that should never be garbage collected
     * @param fieldName
     * @param instance
    private static void makeHardLink(String fieldName, Object instance) {
        System.out.println("attempting hard ref to " + instance.getClass().getName() + "." + fieldName);
        try {
            Field signersRef = instance.getClass().getDeclaredField(fieldName);
            signersRef.setAccessible(true);
            Object o = signersRef.get(instance);
            if(o instanceof SoftReference) {
                SoftReference r = (SoftReference) o;
                Object o2 = r.get();
                sm_hardRefs.add(o2);
            } else {
                System.out.println("noooo!");
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
            return;
        } catch (IllegalAccessException e) {
            e.printStackTrace();
     * Call the given no-arg method on the given instance
     * @param methodName
     * @param instance
    private static void callNoArgMethod(String methodName, Object instance) {
        System.out.println("calling noarg method hard ref to " + instance.getClass().getName() + "." + methodName + "()");
        try {
            Method m = instance.getClass().getDeclaredMethod(methodName);
            m.setAccessible(true);
            m.invoke(instance);
        } catch (SecurityException e1) {
            e1.printStackTrace();
        } catch (NoSuchMethodException e1) {
            e1.printStackTrace();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
     * is the preloader enabled. ie: will the preloader run in the current environment
     * @return
    public static boolean isHardLinkerEnabled() {
         boolean isHardLinkerDisabled = false;  //change this to use whatever mechanism you use to enable or disable the preloader
        return !isHardLinkerDisabled && isRunningOnJre1_6_0_19OrHigher() && isRunningOnWebstart();
     * is the application currently running on webstart
     * detect the presence of a JNLPclassloader
     * @return
    public static boolean isRunningOnWebstart() {
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        while(cl != null) {
            if(cl.getClass().getName().equals("com.sun.jnlp.JNLPClassLoader")) {
                return true;
            cl = cl.getParent();
        return false;
     * Is the JRE 1.6.0_19 or higher?
     * @return
    public static boolean isRunningOnJre1_6_0_19OrHigher() {
        String javaVersion = System.getProperty("java.version");
        if(javaVersion.startsWith(JRE_1_6_0)) {
            //then lets figure out what update we are on
            String updateStr = javaVersion.substring(JRE_1_6_0.length());
            try {
                return Integer.parseInt(updateStr) >= PROBLEM_JRE_UPDATE;
            } catch (NumberFormatException e) {
                //then unable to determine updatedate level
                return false;
        //all other cases
        return false;
      * get all the JarFile objects for all of the jars in the classpath
      * @return
     public static Set<JarFile> getAllJarsFilesInClassPath() {
          Set<JarFile> jars = new LinkedHashSet<JarFile> ();
         for (URL url : getAllJarUrls()) {
             try {
                 jars.add(getJarFile(url));
             } catch(IOException e) {
                  System.out.println("unable to retrieve jar at URL: " + url);
         return jars;
     * Returns set of URLS for the jars in the classpath.
     * URLS will have the protocol of jar eg: jar:http://HOST/PATH/JARNAME.jar!/META-INF/MANIFEST.MF
    static Set<URL> getAllJarUrls() {
        try {
            Set<URL> urls = new LinkedHashSet<URL>();
            Enumeration<URL> mfUrls = Thread.currentThread().getContextClassLoader().getResources("META-INF/MANIFEST.MF");
            while(mfUrls.hasMoreElements()) {
                URL jarUrl = mfUrls.nextElement();
//                System.out.println(jarUrl);
                if(!jarUrl.getProtocol().equals("jar")) continue;
                urls.add(jarUrl);
            return urls;
        } catch(IOException e) {
            throw new RuntimeException(e);
     * get the jarFile object for the given url
     * @param jarUrl
     * @return
     * @throws IOException
    public static JarFile getJarFile(URL jarUrl) throws IOException {
        URLConnection urlConnnection = jarUrl.openConnection();
        if(urlConnnection instanceof JarURLConnection) {
            // Using a JarURLConnection will load the JAR from the cache when using Webstart 1.6
            // In Webstart 1.5, the URL will point to the cached JAR on the local filesystem
            JarURLConnection jcon = (JarURLConnection) urlConnnection;
            return jcon.getJarFile();
        } else {
            throw new AssertionError("Expected JarURLConnection");
     * Spawn a new thread to run through each jar in the classpath and create a hardlink
     * to the jars softly referenced signers infomation.
    public static void go() {
        if(!isHardLinkerEnabled()) {
            return;
        System.out.println("Starting Resource Preloader Hardlinker");
        Thread t = new Thread(new Runnable() {
            public void run() {
                try {
                    Set<JarFile> jars = getAllJarsFilesInClassPath();
                    for (JarFile jar : jars) {
                        makeHardSignersRef(jar);
                } catch (Exception e) {
                    System.out.println("Problem preloading resources");
                    e.printStackTrace();
                } catch (Error e) {
                     System.out.println("Error preloading resources");
                     e.printStackTrace();
        t.start();
}

Similar Messages

  • Servlet Communication with Java WebStart

    Hi there,
    we have an application that works fine with Java WebStart whenever we start it in a local area network. But from outside the LAN the application cannot communicate to it's servlets. I use the codebase IP address with the servlet runner's port (http://<codebase IP>:port/) as URL for servlet communication, but the application's request never reaches the servlets.
    My question is now, if anyone had the same or a similar problem with servlet communication using Java WebStart, or if anyone knows, if that might be a problem with proxy configuration.
    The servlet runner we use, is JServ from Sun (JSDK2.0) and the webserver where it is running on is not behind a firewall or a proxy, but the client PC with the web start application is.
    Thanks,
    Katja

    Thank you for your early reply. But I think, that's not the problem.
    I get no security error and the webserver is identified the same way it is in the jnlp file. Also my application is not running in the Sandbox. My assumption is, that the http-request to the servlet does not go through the proxy server between my PC and the PC the servletrunner is running on.
    I wonder if I have to configure my application to use a proxy server for communication with the servlets instead of the direct http-request to the servlet runner?

  • Can't find xml within jar with java webstart

    I use Jasper Reports,I am reading a xml file in my application.
    The code I use to read this xml file is:
    JasperCompileManager.compileReportToFile("xmlfile.xml","jasperfile.jasper");
    When I run this code in JBuilder it run fine.
    But when I compile the classes and this xml to my jar file,sign it and then try to run it in java Webstart.It tells me that it can not find the path.
    What is wrong?

    I don't know Jasper Reports, so I may be wrong here.
    A file inside a .jar file is not a file on the filesystem, and cannot be accessed with java.io file-related classes. You should use ClassLoader.getResource() to get an inputstream reading from it.

  • [ SOLVED ] Compile Error with Java Fonts & IntelliJ

    Hi All
    I have now got a new problem when i compile a flex project.  Yesterday inorder to get the IJ Interface font smoothing sorted, i had to add this line to my ~/.bashrc file
    _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on
    But now when i go to run a flex project, i get the following error message
    Information:Using built-in compiler shell, up to 4 parallel threads
    See compiler settings at File | Settings | Compiler | Flex Compiler page
    Information:Starting Flex compiler:
    /opt/java/jre/bin/java -Dapplication.home=/home/julian/SDK/flex_sdk_4.5.0.17855 -Xmx384m -Dsun.io.useCanonCaches=false -Duser.language=en -Duser.region=en -Xmx1024m -classpath /opt/idea-IU-98.311/plugins/flex/lib/flex-compiler.jar:/home/julian/SDK/flex_sdk_4.5.0.17855/lib/flex-compiler-oem.jar com.intellij.flex.compiler.FlexCompiler 48936
    Information:Compilation completed with 2 errors and 0 warnings
    Information:2 errors
    Information:0 warnings
    Error:Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on
    Error:java.net.SocketException: Socket closed
    Error:java.net.ConnectException: Connection refused
    Error:     at java.net.PlainSocketImpl.socketConnect(Native Method)
         at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
         at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
         at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
         at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
         at java.net.Socket.connect(Socket.java:529)
         at java.net.Socket.connect(Socket.java:478)
         at java.net.Socket.<init>(Socket.java:375)
         at java.net.Socket.<init>(Socket.java:218)
         at com.intellij.flex.compiler.FlexCompiler.openSocket(FlexCompiler.java:35)
         at com.intellij.flex.compiler.FlexCompiler.main(FlexCompiler.java:70)
    Any suggestions, besides disabling the _JAVA_OPTION again ?
    Many Thanks
    Last edited by whitetimer (2010-11-14 17:24:11)

    -Dawt.useSystemAAFontSettings=on needs to be added to the end of file
    idea.vmoptions

  • [SOLVED] Netbens Error with java openjdk7

    hi! i have a error with netbeans:
    [pablo@arch ~]$ netbeans
    # A fatal error has been detected by the Java Runtime Environment:
    # SIGSEGV (0xb) at pc=0x802067a9, pid=11781, tid=2165295936
    # JRE version: 7.0_21-b02
    # Java VM: OpenJDK Client VM (23.7-b01 mixed mode linux-x86 )
    # Problematic frame:
    # C [libGL.so.1+0x707a9] glXChooseVisual+0xaf69
    # Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
    # An error report file with more information is saved as:
    # /home/pablo/hs_err_pid11781.log
    # If you would like to submit a bug report, please include
    # instructions on how to reproduce the bug and visit:
    # http://icedtea.classpath.org/bugzilla
    /usr/share/netbeans/platform/lib/nbexec: línea 572: 11781 Abortado (`core' generado) "/usr/lib/jvm/java-7-openjdk/bin/java" -Djdk.home="/usr/lib/jvm/java-7-openjdk" -classpath "/usr/share/netbeans/platform/lib/boot.jar:/usr/share/netbeans/platform/lib/org-openide-modules.jar:/usr/share/netbeans/platform/lib/org-openide-util.jar:/usr/share/netbeans/platform/lib/org-openide-util-lookup.jar:/usr/share/netbeans/platform/lib/locale/boot_ja.jar:/usr/share/netbeans/platform/lib/locale/boot_pt_BR.jar:/usr/share/netbeans/platform/lib/locale/boot_ru.jar:/usr/share/netbeans/platform/lib/locale/boot_zh_CN.jar:/usr/share/netbeans/platform/lib/locale/org-openide-modules_ja.jar:/usr/share/netbeans/platform/lib/locale/org-openide-modules_pt_BR.jar:/usr/share/netbeans/platform/lib/locale/org-openide-modules_ru.jar:/usr/share/netbeans/platform/lib/locale/org-openide-modules_zh_CN.jar:/usr/share/netbeans/platform/lib/locale/org-openide-util_ja.jar:/usr/share/netbeans/platform/lib/locale/org-openide-util-lookup_ja.jar:/usr/share/netbeans/platform/lib/locale/org-openide-util-lookup_pt_BR.jar:/usr/share/netbeans/platform/lib/locale/org-openide-util-lookup_ru.jar:/usr/share/netbeans/platform/lib/locale/org-openide-util-lookup_zh_CN.jar:/usr/share/netbeans/platform/lib/locale/org-openide-util_pt_BR.jar:/usr/share/netbeans/platform/lib/locale/org-openide-util_ru.jar:/usr/share/netbeans/platform/lib/locale/org-openide-util_zh_CN.jar:/usr/lib/jvm/java-7-openjdk/lib/dt.jar:/usr/lib/jvm/java-7-openjdk/lib/tools.jar" -Dnetbeans.default_userdir_root="/home/pablo/.netbeans" -Dnetbeans.system_http_proxy="DIRECT" -Dnetbeans.system_http_non_proxy_hosts="" -Dnetbeans.dirs="/usr/share/netbeans/nb:/usr/share/netbeans/ergonomics:/usr/share/netbeans/ide:/usr/share/netbeans/java:/usr/share/netbeans/apisupport:/usr/share/netbeans/webcommon:/usr/share/netbeans/websvccommon:/usr/share/netbeans/enterprise:/usr/share/netbeans/mobility:/usr/share/netbeans/profiler:/usr/share/netbeans/python:/usr/share/netbeans/php:/usr/share/netbeans/identity:/usr/share/netbeans/harness:/usr/share/netbeans/cnd:/usr/share/netbeans/dlight:/usr/share/netbeans/groovy:/usr/share/netbeans/extra:/usr/share/netbeans/javacard:/usr/share/netbeans/javafx:" -Dnetbeans.home="/usr/share/netbeans/platform" '-Dnetbeans.importclass=org.netbeans.upgrade.AutoUpgrade' '-Dnetbeans.accept_license_class=org.netbeans.license.AcceptLicense' '-XX:MaxPermSize=384m' '-Xmx403m' '-client' '-Xss2m' '-Xms32m' '-XX:PermSize=32m' '-Dapple.laf.useScreenMenuBar=true' '-Dapple.awt.graphics.UseQuartz=true' '-Dsun.java2d.noddraw=true' '-Dsun.java2d.dpiaware=true' '-Dsun.zip.disableMemoryMapping=true' '-Dsun.awt.disableMixing=true' -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="/home/pablo/.netbeans/7.3/var/log/heapdump.hprof" org.netbeans.Main --userdir "/home/pablo/.netbeans/7.3" "--cachedir" "/home/pablo/.cache/netbeans/7.3" "--branding" "nb" 0<&0
    i am with netbeans 7.3-1  in 32bits , i try the "ulimit -c ulimited"  command and nothing happens and java version
    OpenJDK Runtime Environment (IcedTea 2.3.9) (ArchLinux build 7.u21_2.3.9-4-i686)
    OpenJDK Client VM (build 23.7-b01, mixed mode)
    java runs fine with other programs like Eclipse
    thank's, sorry my bad english
    Last edited by senjik (2013-06-15 20:25:29)

    Restored thread from dustbin.  It is not clear to me how it got there
    Senjik, Sorry for the inconvenience.  See my suggestions in my PM.
    ewaller

  • Help with java digital signing code

    hello people.
    can anybody help me?
    i have find a java code to resolve my problem with sending pay in soap envelope with digital signature and attached certificate. i compiled it with jdk jdk1.6.0_37. and it works.
    i need it to work in built-in jvm in oracle 9i. in oracle 9i jvm release is 1.3.1. Java code does not work there. there is an error
    class import com.sun.org.apache.xerces.internal.impl.dv.util.Base64 not found in import.
    i did not find this class in network.
    can anybody help with rewriting it for jvm 1.3.1?
    thanks in advance.
    code below:
    import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
    import java.io.*;
    import java.security.Key;
    import java.security.KeyStore;
    import java.security.PrivateKey;
    import java.security.Signature;
    import java.security.cert.Certificate;
    public class Sign {
    public static void main(String[] args) throws Exception {
    // TODO code application logic here
    BufferedReader reader = new BufferedReader(new FileReader("c:\\cert.p12"));
    StringBuilder fullText = new StringBuilder();
    String line = reader.readLine();
    while (line != null) {
    fullText.append(line);
    line = reader.readLine();
    KeyStore p12 = KeyStore.getInstance("pkcs12");
    p12.load(new FileInputStream("c:\\cert.p12"), "Hfrtnf$5".toCharArray());
    //????????? ????????? ????, ??? ????? ????? ???????????? alias ? ??????
    //Key key = p12.getKey("my kkb key", "ryba-mech".toCharArray());
    Key key = (Key) p12.getKey("my kkb key", "Hfrtnf$5".toCharArray());
    Certificate userCert = (Certificate) p12.getCertificate("my kkb key");
    String base64Cert = new String(Base64.encode(userCert.getEncoded()));
    //signing
    Signature signer = Signature.getInstance("SHA1withRSA");
    signer.initSign((PrivateKey) key);
    signer.update(fullText.toString().getBytes());
    byte[] digitalSignature = signer.sign();
    String base64sign = new String(Base64.encode(digitalSignature));
    String base64Xml = new String(Base64.encode(fullText.toString().getBytes()));
    System.out.println("<certificate>" + base64Cert+"</certificate>");
    System.out.println("<xmlBody>" + base64Xml+"</xmlBody>");
    System.out.println("<signature>" + base64sign+"</signature>");
    Edited by: user13622283 on 22.01.2013 22:08

    My first search is to see if there is an Apache commons project that provides it. Lo and behold:
    http://commons.apache.org/codec/apidocs/org/apache/commons/codec/binary/Base64.html
    commons-codec.

  • Download Error in java webstart

    Hi
    I am getting a error while downloading application from java webstart
    I am using Apache 2.2 http server running on port 80
    In that in htdocs folder I have placed my jnlp file and my jar file
    My jnlp file is like this .
    All file are in the folder htdocs/products/
    <jnlp spec="1.0+" codebase="http://127.0.0.1/" href="/products/note.jnlp">
    <information>
    <title>My Application </title>
    <vendor>ABC Pvt Ltd</vendor>
    <homepage href="http://127.0.0.1/products/"/>
    <description>Sample Test</description>
    <shortcut>
    <desktop/>
    <menu submenu="My Application 2.0 (web)"/>
    </shortcut>
    </information>
    <security><all-permissions/></security>
    <resources>
    <j2se version="1.4+" />
    <jar href="/products/Notepad.jar" main="true" download="eager"/>
    </resources>
    <application-desc main-class="Notepad">
    </application-desc>
    </jnlp>
    The error which i am getting is
    An error occurred while launching/running the application.
    Title: My Application
    Vendor: ABC Pvt Ltd
    Category: Download Error
    Bad MIME type returned from server when accessing resource: http://127.0.0.1/products/note.jnlp - text/plain
    JNLPException[category: Download Error : Exception: null : LaunchDesc: null ]
    at com.sun.javaws.cache.DownloadProtocol.doDownload(U nknown Source)
    at com.sun.javaws.cache.DownloadProtocol.isLaunchFile UpdateAvailable(Unknown Source)
    at com.sun.javaws.LaunchDownload.getUpdatedLaunchDesc (Unknown Source)
    at com.sun.javaws.Launcher.downloadResources(Unknown Source)
    at com.sun.javaws.Launcher.handleApplicationDesc(Unkn own Source)
    at com.sun.javaws.Launcher.handleLaunchFile(Unknown Source)
    at com.sun.javaws.Launcher.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Please help ...
    How to solve this issue .
    But the same file is working in Tomcat Server
    please let me know
    Thank you
    Prakash

    Bad MIME type returned from server..A server should return a content type of..
    application/x-java-jnlp-file for JNLP
    files.
    Tomcat probably does that by default, but
    other servers might need to be told about it.
    See your server help, for how to set a
    content-type.

  • PeopleSoft XML Publisher report error with java.io.FileNotFoundException

    Hi,
    I have created two reports using XML Publisher in Peoplesoft Financials. The two reports are not related and they were submitted for processing separately. The first report completes without any issues. The second report results in error with the following message:
    09.11.17 ..(CIS_POTRPT.XML_FILE.Step03) (PeopleCode)
    [012309_091118154][oracle.apps.xdo.template.FOProcessor][EXCEPTION] IOException is occurred in FOProcessor.setData(String) with 'files/cis_potrpt.xml'.
    [012309_091118500][oracle.apps.xdo.template.FOProcessor][EXCEPTION] java.io.FileNotFoundException: files/cis_potrpt.xml (A file or directory in the path name does not exist.)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.<init>(FileInputStream.java(Compiled Code))
         at java.io.FileInputStream.<init>(FileInputStream.java:89)
         at oracle.apps.xdo.template.FOProcessor.getInputStream(FOProcessor.java:1316)
         at oracle.apps.xdo.template.FOProcessor.getXMLInput(FOProcessor.java:1100)
         at oracle.apps.xdo.template.FOProcessor.setData(FOProcessor.java:372)
         at com.peoplesoft.pt.xmlpublisher.PTFOProcessor.generateOutput(PTFOProcessor.java:53)
    2009-01-23-09.11.18.000418 AePcdExecutePeopleCode [174] Exception logged: RC=100.
    Error generating report output: (235,2309) PSXP_RPTDEFNMANAGER.ReportDefn.OnExecute Name:ProcessReport PCPC:51552 Statement:1153
    Called from:CIS_POTRPT.XML_FILE.GBL.default.1900-01-01.Step03.OnExecute Statement:8
    2009-01-23-09.11.18.000617 DoStepActions [1797] Exception logged: RC=100.
    Process 598607 ABENDED at Step CIS_POTRPT.XML_FILE.Step03 (PeopleCode) -- RC = 24 (108,524)
    In the process monitor detail > view log/trace page, the xml file is accessible so the file was generated to a valid directory.
    The weird thing is I was able to run this report without any issues few weeks ago although another user also ran into same error. The PeopleCode step that has been identified is essentially same in the two reports. I checked the app server and the directory does exist as well as the xml files for the two reports. The problem does not occur in test environment, just in production. Any help would be appreciated.

    We encounter the same problem. Did you get the answer for this issue? Thanks in advance.

  • Error with Java Virtual Machine Laucher

    Hi, I'm getting the follwowing error with I try to lauch universal installer.
    Fatal exception occured. Program will exit.
    Does anyone have any idea what's going on? I have java ee 5 sdk installed on my machine.

    Hello Guys!
    I have a problem here and i cant find the solution!
    somebody can help me?
    In the installation, after run the runInstaller show
    this message:
    Initializing Java Virtual Machine from
    /tmp/OraInstall2008-04-27_0733-08PM/jre/1.4.2/bin/java
    . Please wait...
    [oracle@localhost ~]$ Oracle Universal Installer,
    Version 10.2.0.1.0 Production
    Copyright (C) 1999, 2005, Oracle. All rights
    reserved.
    Exception java.lang.UnsatisfieldLinkError:
    /tmp/OraInstall2008-04-27_0733-08PM/jre/1.4.2/lib/i386
    /libawt.so: libXp.so.6: cannot open shared object
    file: No such file or directory occurred..
    java.lang.UnsatisfieldLinkError:
    /tmp/OraInstall2008-04-27_0733-08PM/jre/1.4.2/lib/i386
    /libawt.so: libXp.so.6: cannot open shared object
    file: No such file or directory<snip>
    So I went to MetaLink and did a search on the "libXp.so.6: cannot open shared object" found in your error message. The very first hit returned was note 308755.1, titled "OUI Reports The Error: Exception java.lang.UnsatisfiedLinkError: /tmp/OraInstall*/jre/1.4.2/lib/i386/libawt.so: libXp.So.6: Cannot Open Shared Object File"
    The terms of MetaLink usage prevent me from quoting from the note, but you would be advised to go read it for yourself. Suffice it to say you are missing some rpms. The specific ones missing are not listed in the above referenced not, but it will point you in the right direction.

  • Install NW04S PI - Error with Java 710 CD

    I am trying to install the UNIX/Oracle version SAP Netweaver Process Integration 7.1 using the follow installation media
    51033243_2               NW 7.1 UC-Kernel 7.10 HP-UX on IA64 64bit
    51033237                     SAP NW AS ABAP 7.1 Inst. Export     
    51033240_3.               NW 7.1 Inst.Master HPUX on IA64 64bit ORACLE           
    51033242_1              SAP NW PI 7.1 Java based SW Comp.s 1 of 4           
    51033242_2              SAP NW PI 7.1 Java based SW Comp.s 2 of 4             
    51033242_3              SAP NW PI 7.1 Java based SW Comp.s 3 of 4          
    51033242_4              SAP NW PI 7.1 Java based SW Comp.s 4 of 4
    After I run sapinst from the Installation master CD I am prompted to enter the location of the media.
    For the media JAVA COMPONENT NW71 (JAVA_J2EE_OSINDEP) 
    I am using the unpacked disk 51033242_1 (through4) SAP NW PI 7.1 Java based SW Comp  
    I bounces back the following error.
    Found the label SAP:NETWEAVER:710:DVD_JAVA:SAP Netweaver 7.10 PI Java DVD:D51033242 but need the label SAP:J2EE-CD:710:J2EE-CD:j2ee-cd
    What installation media should I be using in order to install this with JAVA 710 components for PI?
    Thanks.

    Thanks...
    Ive tried that CD as well. but it has the wrong label.
    Is there a way to preview LABEL.ASC without downloading the whole file
    $ cd 51032257
    $ ls
    CDLABEL.ASC   COPY_TM.TXT   JAVA_EXPORT   LABELIDX.ASC  VERSION.ASC
    CDLABEL.EBC   CRCFILE.DAT   LABEL.ASC     PROD_LABEL    VERSION.EBC
    COPY_TM.HTM   J2EE_OSINDEP  LABEL.EBC     SHAFILE.DAT
    $ cd J2EE_OSINDEP/
    $ ls
    CDVersion.txt         KernelVersions.xml    UT
    ComponentCatalog.xml  LABEL.ASC             UT_SOLMAN
    J2EE-INST             LABELIDX.ASC          vmparams.xml
    JDKVersion.xml        TOC.XML
    $ more LABEL.ASC
    SAP:J2EE-CD:700SR2:J2EE-CD:j2ee-cd:*

  • Timestamp/Date format error with Java 1.6

    I'm getting this error trying to getObjects from a ResultSet query for an Oracle Lite 10G table that has colums of the TIMESTAMP or DATE type. This works fine under java 1.5. Java 1.6 seems to have broken TIMESTAMP/DATE compatibility with Oracle Lite. Are there any plans to make 10G compatible with Java 1.6? We would like to port our application from Java 1.5 to 1.6, but this is an obstacle. I suppose one work-around would be to use TO_CHAR on all the DATE fields and convert them back to java Dates programatically, but that would be a hassle.
    Update: I changed the column types of the table from TIMESTAMP to DATE. The same exception occurs when calling POLJDBCResultSet.getObject() on the DATE columns. Again, this works fine under Java 1.5, but not 1.6.
    java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]
         at java.sql.Timestamp.valueOf(Timestamp.java:194)
         at oracle.lite.poljdbc.LiteEmbResultSet.jniGetDataTimestamp(Native Method)
         at oracle.lite.poljdbc.LiteEmbResultSet.getVal(Unknown Source)
         at oracle.lite.poljdbc.POLJDBCResultSet.getTimestamp(Unknown Source)
         at oracle.lite.poljdbc.POLJDBCResultSet.getObject(Unknown Source)
         at oracle.lite.poljdbc.POLJDBCResultSet.getObject(Unknown Source)

    I just found a pretty easy java work-around for this that doesn't involve changing the table column types or the SQL:
    Check the column type from the ResultSetMetaData before calling ResultSet.getObject(). If the type is DATE, TIMESTAMP or TIME, call ResultSet.getString() which doesn't throw an exception. Then convert the string to a java.util.Date using java.text.SimpleDateFormat. That can then be used to instantiate a Timestamp.
    This seems to work.
    Message was edited by:
    user490596

  • JavaMail error with "java -jar" on 1.6

    The following code sends an email. The following ant build script compiles the code, creates a jar, runs the program using "java Test", and runs the program using "java -jar test.jar". Both runs work with Sun's 1.5 JRE. With Sun's 1.6 JRE, it does not work when using "java -jar" (my output is following the code). I am not sure why. I thought it might be conflicting versions of JavaMail and the JAF in Java6, but I have the latest JavaMail. I guess it is an issue with how libraries are loaded when using "java -jar", but I am not sure how to resolve this.
    If you want to run this, simply drop mail-1.4.1.jar and activation-1.1.1.jar into the same directory as these two files, set your.mail.server.here and [email protected], and run ant.
    Test.java
    import java.util.Properties;
    import javax.mail.*;
    import javax.mail.internet.*;
    public class Test {
        public static void main( String[] args )
            throws Exception {
            String host = "your.mail.server.here";
            String from = "[email protected]";
            String to = from;
            String subject = "Test JavaMail";
            Address[] toRecipients = new Address[1];
            toRecipients[0] = new InternetAddress( to );
            Properties properties = System.getProperties();
            properties.put( "mail.smtp.host" , host );
            Session session = Session.getDefaultInstance( properties, null );
            MimeMessage message = new MimeMessage( session );
            Address fromAddress = new InternetAddress( from );
            message.setFrom( fromAddress );
            message.setRecipients( Message.RecipientType.TO, toRecipients );
            message.setSubject( subject );
            message.setText( "this is the body" );
            Transport.send( message );
    build.xml
    <project name="test" basedir="." default="all">
        <property name="jar.path" value="test.jar" />
        <path id="classpath">
            <pathelement location="mail-1.4.1.jar" />
            <pathelement location="activation-1.1.1.jar" />
        </path>
        <target name="clean">
            <delete>
                <fileset dir=".">
                    <include name="${jar.path}" />
                    <include name="Test.class" />
                </fileset>
            </delete>
        </target>
        <target name="build">
            <javac destdir="." srcdir=".">
                <classpath refid="classpath" />
                <include name="Test.java" />
            </javac>
        </target>
        <target name="jar">
            <manifestclasspath property="mf.classpath" jarfile="${jar.path}">
                <classpath refid="classpath" />
            </manifestclasspath>
            <jar destfile="${jar.path}" basedir="." update="no" index="true">
                <include name="Test.class" />
                <manifest>
                    <attribute name="Manifest-Version" value="1" />
                    <attribute name="Class-Path" value="${mf.classpath}" />
                    <attribute name="Main-Class" value="Test" />
                </manifest>
                <indexjars>
                    <path refid="classpath" />
                </indexjars>
            </jar>
        </target>
        <target name="run">
            <echo message="This will work in 1.5 and 1.6" />
            <java classname="Test">
                <classpath refid="classpath" />
                <classpath location="${jar.path}" />
            </java>
        </target>
        <target name="runjar">
            <echo message="This will not work in 1.6" />
            <java jar="${jar.path}" fork="true" />
        </target>
        <target name="all" depends="clean,build,jar,run,runjar" />
    </project>
    output (with 1.6)
         [java] Exception in thread "main" javax.mail.MessagingException: IOException while sending message;
         [java]   nested exception is:
         [java]     javax.activation.UnsupportedDataTypeException: no object DCH for MIME type text/plain; charset=us-ascii
         [java]     at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:676)
         [java]     at javax.mail.Transport.send0(Transport.java:189)
         [java]     at javax.mail.Transport.send(Transport.java:118)
         [java]     at Test.main(Unknown Source)
         [java] Caused by: javax.activation.UnsupportedDataTypeException: no object DCH for MIME type text/plain; charset=us-ascii
         [java]     at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:870)
         [java]     at javax.activation.DataHandler.writeTo(DataHandler.java:301)
         [java]     at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1403)
         [java]     at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1745)
         [java]     at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:636)
         [java]     ... 3 more

    I spent quite a bit of time looking into this. Thanks for the reproducible test
    case, it was essential to figuring out the problem!
    The problem appears to be a bug in the jar file index. The jar file index doesn't
    include the META-INF directory, which means JavaMail can't find the config
    files it's looking for in mail.jar. If you change the ant build file to set index="false",
    it will work as expected. If you really need the index, you can fix it by using
    the jar command explicitly - "jar i test.jar".
    It looks like this is a bug in ant.

  • Downloading updated jars with java webstart

    I have a web start application where I download individual data jars using the javaws DownloadService API. These jars change infrequently but do change. My initial implementation was relatively straightforward:
    String dataArchiveUrl = study.getDataArchiveUrl();
    URL url = new URL(dataArchiveUrl);
    DownloadServiceListener dsl = new MyTestDownloadServiceListener();
    ds.loadResource(url, null, dsl);This works great for the initial download and when there is no update to the data jar. The problem is that when the data jar is updated, javaws does not download the update unless I manually delete the original data jar from the web start cache. I had expected(hoped?) that loadResource would work like javaws and check the timestamp of the resource to determine if an update was needed, but that does not appear to be what happened. I have confirmed that the jar timestamps are being served accurately.
    I was able to put in a work around that checks the timestamp and, if the server timestamp is newer, removes the resource from the cache. This forces webstart to update the data jar when the timestamp is updated but is less than ideal for a couple reasons:
    (1) It seems inefficient to open up my own URLConnection to the resource. Is there a way to get webstart to handle the updating for me based on the timestamp?
    (2) The application is designed for offline use. The work around removes the data jar before downloading the new one. This would seem to open a gap where if a user starts downloading an update but gets disconnected before finishing, they won't have access to either the old or new data file. Does anyone have any ideas on closing this gap?

    I have a web start application where I download individual data jars using the javaws DownloadService API. These jars change infrequently but do change. My initial implementation was relatively straightforward:
    String dataArchiveUrl = study.getDataArchiveUrl();
    URL url = new URL(dataArchiveUrl);
    DownloadServiceListener dsl = new MyTestDownloadServiceListener();
    ds.loadResource(url, null, dsl);This works great for the initial download and when there is no update to the data jar. The problem is that when the data jar is updated, javaws does not download the update unless I manually delete the original data jar from the web start cache. I had expected(hoped?) that loadResource would work like javaws and check the timestamp of the resource to determine if an update was needed, but that does not appear to be what happened. I have confirmed that the jar timestamps are being served accurately.
    I was able to put in a work around that checks the timestamp and, if the server timestamp is newer, removes the resource from the cache. This forces webstart to update the data jar when the timestamp is updated but is less than ideal for a couple reasons:
    (1) It seems inefficient to open up my own URLConnection to the resource. Is there a way to get webstart to handle the updating for me based on the timestamp?
    (2) The application is designed for offline use. The work around removes the data jar before downloading the new one. This would seem to open a gap where if a user starts downloading an update but gets disconnected before finishing, they won't have access to either the old or new data file. Does anyone have any ideas on closing this gap?

  • Permissions Error Dispite using a Signed Jar

    I have developed a PC program that has a built in web server for talking with and relaying command to a device attached to the COM port. Now Right now I'm using JavaScript to talk with the programs web interface. Now this brought browser compatibility issues though, because commands could be relayed to the programs web interface from a cross domain. Dispite adding in the needed header output records to allow it. Only one browser had the ability to do this. So I created a extremely basic java applet that just opens the web pages on the programs web server and returns the output from the web server to a Javascript function on the parent document to be handled as needed.
    Now while this worked great going from localhost to localhost. I then moaved the applet to another computer on the network and tired localhost again and got:
    java.security.AccessControlException: access denied (java.net.SocketPermission localhost:988 connect,resolve).Well at first I thought "Oh I forgot to sign the jar." So i signed the jar file and it still kicked back the same error.
    Now the only way i could get rid of the error was adding a policy entry, but that is not acceptable because of a number of reasons. So it could very well be something in my code. Though I'm not sure. As you can see below it is very simplistic.
    public void CallTimeServ(String Target)
             URL                url;
             URLConnection      urlConn;
             DataInputStream    dis;
               try {
                   url = new URL(Target);
                   urlConn = url.openConnection();
                  urlConn.setDoInput(true);
                  urlConn.setUseCaches(false);
                  dis = new DataInputStream(urlConn.getInputStream());
                  String JSon;
                  while ((JSon = dis.readLine()) != null)
                       ContentsRetrived(JSon);
                  dis.close();
              } catch (MalformedURLException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
         public void ContentsRetrived(String msg)
              try
                   msg = msg.replace("'", "\'");
                   getAppletContext().showDocument(new URL("javascript:ContentsRetrived('" + msg +"')"));
              catch (MalformedURLException me) { }
         public void init()
        }So any one have any ideal on how to to do this. With out requiring a policy file entry?

    Phil - did you check out http://otn.oracle.com/products/forms/pdf/SigningJint13.pdf
    regards
    Grant Ronald
    Forms Product Management

  • Error with XMII/CMSLogicEditor/logging.jar

    Hi,
    I faced with the problem like below.
    How can i solve this problem without reinstalling MII?
    Thanks.
    Log message
    500 Internal Server Error is returned for HTTP request [http://host:port/XMII/CMSLogicEditor/logging.jar]:
      component [default],
      web module [XMII],
      application [sap.com/xappsxmiiear],
      DC name [],
      CSN component[],
      problem categorization [],
      internal categorization [-299490430].

    java.lang.NoClassDefFoundError: chat/chat/ChatApplet (wrong name: chat/ChatApplet)The above says you use chat/chat/ChatApplet but it should be chat/ChatApplet.

Maybe you are looking for

  • Quicktime does not work with iphoto

    Quicktime no longer opens when I click on a movie in iPhoto...  Anyone know why?

  • How to use .dbf files zipped into a .zip file from within a java program

    i have a .zip file containing several .dbf files. the zip file is automatically downloaded regularly and data from the .dbf files is inserted into the database. how do i facilitate automatic extraction of a zip file or how do i fetch data from the .d

  • Query on XML Form Builder

    Hi, I have an news application to be developed in XML Form Builder. I am creating News Author part of it. It has an Date field where i have to do an validation like the user cannot enter date less than the current date. I can perform simple data type

  • How to have control overwrite container "enabled" attribute?

    Hi, I found out that setting attributes on the container (like "enabled" or "visible") affects all the child controls in the container. For example, if I set a canvas' enabled="false", the buttons and text inputs inside this canvas will be disabled a

  • IMP.EXE not working in 11gR2 as it did in previous versions

    I am trying to restore a database which was backed up using EXP.EXE on Oracle 10g to a new Oracle 11gR2 instance. I was having trouble with the tablespaces at first and finally gave the user unlimited quota on the data and index tablespaces. The scri