Frage

I'm going to start this out by saying I'm not a Java programmer, I'm a PHP programmer.

I ran into a situation were websockets weren't going to cut it and I found this site that offered a solution:

http://stephengware.com/proj/javasocketbridge/

It's basically a Jar that you can load in and control with JavaScript. It works great, I'd highly recommend it to anyone needing similar functionality. However, since the Jar was not signed, every time the page loads, it shows a security warning. It's a little annoying and I thought that if I self-signed the Jar, it would have the 'Never show me this again' / 'Allow Forever' check box enabled. This is to be deployed internally to our organization, so signing it with a paid cert doesn't seem necessary.

The problem is that as soon as I sign the Jar, it doesn't work. I get a class not found error. I've looked at dozens of sites that show you how to sign Jar files and googled this to page 10, and I can't find anyone that's had this kind of issue.

I'm going to include the parts that I think are needed, if you need something else let me know and I'll get it.

Applet code:

<applet id="JavaSocketBridge" archive="JavaSocketBridge.jar" code="JavaSocketBridge.class" width="400" height="30"></applet>

How I signed the Jar (in an administrator command prompt):

C:\Program Files\Java\jdk1.7.0_07\bin>keytool -genkey -keyalg rsa -alias crtlive
Enter keystore password:
What is your first and last name?
  [Unknown]:  first last
What is the name of your organizational unit?
  [Unknown]:  Tech
What is the name of your organization?
  [Unknown]:  ourorg
What is the name of your City or Locality?
  [Unknown]:  city
What is the name of your State or Province?
  [Unknown]:  ST
What is the two-letter country code for this unit?
  [Unknown]:  US
Is CN=first last, OU=Tech, O=ourorg, L=city, ST=ST, C=US correct?
  [no]:  yes

Enter key password for <crtlive>
        (RETURN if same as keystore password):

C:\Program Files\Java\jdk1.7.0_07\bin>keytool -export -alias crtlive -file crtlive
.crt
Enter keystore password:
Certificate stored in file <crtlive.crt>

C:\Program Files\Java\jdk1.7.0_07\bin>jarsigner JavaSocketBridge.jar crtlive
Enter Passphrase for keystore:

Warning:
The signer certificate will expire within six months.

C:\Program Files\Java\jdk1.7.0_07\bin>keytool -export -alias crtlive -rfc -file s
ig.x509
Enter keystore password:
Certificate stored in file <sig.x509>

C:\Program Files\Java\jdk1.7.0_07\bin>

I've opened up both the unsigned and signed Jars and the source files are identical, there are just two additional files in the META-INF folder on the signed Jar: CRTLIVE.RSA and CRTLIVE.SF.

Here's the thread dump:

Dump thread list ...
Group main,ac=18,agc=4,pri=10
    main,5,alive
    traceMsgQueueThread,5,alive,daemon
    Timer-0,5,alive
    Java Plug-In Pipe Worker Thread (Client-Side),5,alive,daemon
    AWT-Windows,6,alive,daemon
    SysExecutionTheadCreator,5,alive,daemon
    CacheMemoryCleanUpThread,5,alive,daemon
    CacheCleanUpThread,5,alive,daemon
    Browser Side Object Cleanup Thread,5,alive
    JVM[id=4]-Heartbeat,5,alive,daemon
    AWT-Shutdown,5,alive
    AWT-EventQueue-0,6,alive
Group Plugin Thread Group,ac=2,agc=0,pri=10
    AWT-EventQueue-1,6,alive
    TimerQueue,5,alive,daemon
Group http://www.example.com/admin/-threadGroup,ac=0,agc=0,pri=4,destoyed
Group http://www.example.com/admin/-threadGroup,ac=0,agc=0,pri=4,destoyed
Group http://www.example.com/admin/-threadGroup,ac=4,agc=0,pri=4
    Applet 49 LiveConnect Worker Thread,4,alive
    AWT-EventQueue-23,4,alive
    TimerQueue,4,alive,daemon
    ConsoleTraceListener,4,alive,daemon
Done.

The thread stack is on the long side, but here it is:

Full thread dump Java HotSpot(TM) Client VM (23.3-b01 mixed mode, sharing):

"TimerQueue" daemon prio=6 tid=0x04d55800 nid=0x1f28 waiting on condition [0x0ac7f000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x24820770> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(Unknown Source)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source)
    at java.util.concurrent.DelayQueue.take(Unknown Source)
    at javax.swing.TimerQueue.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

"ConsoleTraceListener" daemon prio=4 tid=0x04e12400 nid=0x2c14 runnable [0x09d7f000]
   java.lang.Thread.State: RUNNABLE
    at java.lang.Object.wait(Native Method)
    at java.lang.Thread.join(Unknown Source)
    - locked <0x244218e0> (a sun.plugin.util.PluginSysUtil$SysExecutionThread)
    at java.lang.Thread.join(Unknown Source)
    at sun.plugin.util.PluginSysUtil.execute(Unknown Source)
    at sun.plugin.util.PluginSysUtil.execute(Unknown Source)
    at sun.plugin.util.PluginSysUtil.delegate(Unknown Source)
    at com.sun.deploy.util.DeploySysRun.execute(Unknown Source)
    at com.sun.deploy.uitoolkit.impl.awt.ui.SwingConsoleWindow.invokeLater(Unknown Source)
    at com.sun.deploy.uitoolkit.impl.awt.ui.SwingConsoleWindow.append(Unknown Source)
    at com.sun.deploy.uitoolkit.ui.ConsoleTraceListener$ConsoleWriterThread.run(Unknown Source)

"AWT-EventQueue-1" prio=6 tid=0x04e37400 nid=0x338 waiting on condition [0x0a10e000]
   java.lang.Thread.State: RUNNABLE
    at com.sun.deploy.uitoolkit.ui.ConsoleHelper.dumpAllStacksImpl(Native Method)
    at com.sun.deploy.uitoolkit.ui.ConsoleHelper.dumpAllStacks(Unknown Source)
    at com.sun.deploy.uitoolkit.impl.awt.ui.SwingConsoleWindow$3.actionPerformed(Unknown Source)
    at javax.swing.JComponent$ActionStandin.actionPerformed(Unknown Source)
    at javax.swing.SwingUtilities.notifyAction(Unknown Source)
    at javax.swing.JComponent.processKeyBinding(Unknown Source)
    at javax.swing.KeyboardManager.fireBinding(Unknown Source)
    at javax.swing.KeyboardManager.fireKeyboardAction(Unknown Source)
    at javax.swing.JComponent.processKeyBindingsForAllComponents(Unknown Source)
    at javax.swing.JComponent.processKeyBindings(Unknown Source)
    at javax.swing.JComponent.processKeyEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$200(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

"TimerQueue" daemon prio=4 tid=0x04e11c00 nid=0x1f7c waiting on condition [0x0940f000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x24820e00> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(Unknown Source)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source)
    at java.util.concurrent.DelayQueue.take(Unknown Source)
    at javax.swing.TimerQueue.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

"AWT-EventQueue-23" prio=4 tid=0x04e32c00 nid=0x31d8 waiting on condition [0x09e5f000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x29e3a6b8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(Unknown Source)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source)
    at java.awt.EventQueue.getNextEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

"Applet 49 LiveConnect Worker Thread" prio=4 tid=0x04de8c00 nid=0x2e88 in Object.wait() [0x09c6f000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:503)
    at sun.plugin2.main.client.LiveConnectSupport$PerAppletInfo$LiveConnectWorker.run(Unknown Source)
    - locked <0x29e3a798> (a java.lang.Object)
    at java.lang.Thread.run(Unknown Source)

"AWT-EventQueue-0" prio=6 tid=0x04de8800 nid=0x1038 waiting on condition [0x0977f000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x2998d388> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(Unknown Source)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source)
    at java.awt.EventQueue.getNextEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

"AWT-Shutdown" prio=6 tid=0x04d56000 nid=0x37f8 in Object.wait() [0x07cdf000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:503)
    at sun.awt.AWTAutoShutdown.run(Unknown Source)
    - locked <0x2998d4f0> (a java.lang.Object)
    at java.lang.Thread.run(Unknown Source)

"D3D Screen Updater" daemon prio=8 tid=0x04e35800 nid=0x674 in Object.wait() [0x0963f000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at sun.java2d.d3d.D3DScreenUpdateManager.run(Unknown Source)
    - locked <0x2998cdf0> (a java.lang.Object)
    at java.lang.Thread.run(Unknown Source)

"JVM[id=4]-Heartbeat" daemon prio=6 tid=0x04e33800 nid=0x2578 in Object.wait() [0x054df000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at sun.plugin2.main.server.HeartbeatThread.run(Unknown Source)
    - locked <0x2998d010> (a sun.plugin2.main.client.PluginMain$Heartbeat)

"Browser Side Object Cleanup Thread" prio=6 tid=0x04e32400 nid=0x1834 in Object.wait() [0x07f1f000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x2998d180> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(Unknown Source)
    - locked <0x2998d180> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(Unknown Source)
    at sun.plugin2.main.client.LiveConnectSupport$BrowserSideObjectCleanupThread.run(Unknown Source)

"CacheCleanUpThread" daemon prio=6 tid=0x04e28000 nid=0x2208 in Object.wait() [0x07b5f000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:503)
    at com.sun.deploy.cache.CleanupThread.run(Unknown Source)
    - locked <0x2998d1a0> (a com.sun.deploy.cache.CleanupThread)

"CacheMemoryCleanUpThread" daemon prio=6 tid=0x04e21000 nid=0x3484 in Object.wait() [0x0735f000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x2998d290> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(Unknown Source)
    - locked <0x2998d290> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(Unknown Source)
    at com.sun.deploy.cache.MemoryCache$LoadedResourceCleanupThread.run(Unknown Source)

"SysExecutionTheadCreator" daemon prio=6 tid=0x04dd8400 nid=0x2f40 in Object.wait() [0x07e8f000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:503)
    at sun.plugin.util.PluginSysUtil$SysExecutionThreadCreator.run(Unknown Source)
    - locked <0x2998d2b0> (a sun.plugin.util.PluginSysUtil$SysExecutionThreadCreator)

"AWT-Windows" daemon prio=6 tid=0x04dabc00 nid=0x1eb4 runnable [0x00daf000]
   java.lang.Thread.State: RUNNABLE
    at sun.awt.windows.WToolkit.eventLoop(Native Method)
    at sun.awt.windows.WToolkit.run(Unknown Source)

"Java2D Disposer" daemon prio=10 tid=0x04da0c00 nid=0x3014 in Object.wait() [0x057cf000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at java.lang.ref.ReferenceQueue.remove(Unknown Source)
    - locked <0x2998d580> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(Unknown Source)
    at sun.java2d.Disposer.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

"Java Plug-In Pipe Worker Thread (Client-Side)" daemon prio=6 tid=0x04d99000 nid=0x1e74 runnable [0x058df000]
   java.lang.Thread.State: RUNNABLE
    at sun.plugin2.os.windows.Windows.ReadFile0(Native Method)
    at sun.plugin2.os.windows.Windows.ReadFile(Unknown Source)
    at sun.plugin2.ipc.windows.WindowsNamedPipe.read(Unknown Source)
    at sun.plugin2.message.transport.NamedPipeTransport$SerializerImpl.read(Unknown Source)
    at sun.plugin2.message.transport.NamedPipeTransport$SerializerImpl.readByte(Unknown Source)
    at sun.plugin2.message.AbstractSerializer.readInt(Unknown Source)
    at sun.plugin2.message.transport.SerializingTransport.read(Unknown Source)
    at sun.plugin2.message.Pipe$WorkerThread.run(Unknown Source)

"Timer-0" prio=6 tid=0x04d75800 nid=0x1438 in Object.wait() [0x0517f000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x2998d8c0> (a java.util.TaskQueue)
    at java.lang.Object.wait(Object.java:503)
    at java.util.TimerThread.mainLoop(Unknown Source)
    - locked <0x2998d8c0> (a java.util.TaskQueue)
    at java.util.TimerThread.run(Unknown Source)

"traceMsgQueueThread" daemon prio=6 tid=0x04cce800 nid=0x2aec in Object.wait() [0x04b0f000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:503)
    at com.sun.deploy.trace.Trace$TraceMsgQueueChecker.run(Unknown Source)
    - locked <0x298b6d28> (a java.util.ArrayList)
    at java.lang.Thread.run(Unknown Source)

"Service Thread" daemon prio=6 tid=0x00b14400 nid=0x2804 runnable [0x00000000]
   java.lang.Thread.State: RUNNABLE

"C1 CompilerThread0" daemon prio=10 tid=0x00b0fc00 nid=0x1ff4 waiting on condition [0x00000000]
   java.lang.Thread.State: RUNNABLE

"Attach Listener" daemon prio=10 tid=0x00b0e800 nid=0x1980 runnable [0x00000000]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" daemon prio=10 tid=0x00b0b400 nid=0x21bc runnable [0x00000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" daemon prio=8 tid=0x00ae4000 nid=0x2df0 in Object.wait() [0x047df000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at java.lang.ref.ReferenceQueue.remove(Unknown Source)
    - locked <0x2998db48> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(Unknown Source)
    at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)

"Reference Handler" daemon prio=10 tid=0x00ae2800 nid=0xc0c in Object.wait() [0x0485f000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:503)
    at java.lang.ref.Reference$ReferenceHandler.run(Unknown Source)
    - locked <0x2998cd80> (a java.lang.ref.Reference$Lock)

"main" prio=6 tid=0x003ddc00 nid=0x2fa0 in Object.wait() [0x0098f000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at sun.plugin2.message.Queue.waitForMessage(Unknown Source)
    - locked <0x2998dbd0> (a sun.plugin2.message.Queue)
    at sun.plugin2.message.Pipe$1.run(Unknown Source)
    at com.sun.deploy.util.Waiter$1.wait(Unknown Source)
    at com.sun.deploy.util.Waiter.runAndWait(Unknown Source)
    at sun.plugin2.message.Pipe.receive(Unknown Source)
    at sun.plugin2.main.client.PluginMain.mainLoop(Unknown Source)
    at sun.plugin2.main.client.PluginMain.run(Unknown Source)
    at sun.plugin2.main.client.PluginMain.main(Unknown Source)

"VM Thread" prio=10 tid=0x00ae1000 nid=0x23f4 runnable 

"VM Periodic Task Thread" prio=10 tid=0x00b2fc00 nid=0x32b8 waiting on condition 

lugin2.main.client.PluginMain.run(Unknown Source)
    at sun.plugin2.main.client.PluginMain.main(Unknown Source)

"VM Thread" prio=10 tid=0x00ae1000 nid=0x23f4 runnable 

"VM Periodic Task Thread" prio=10 tid=0x00b2fc00 nid=0x32b8 waiting on condition 


----------------------------------------------------
Done.

I've googled for everything I could think of, any help would be appreciated.

Thanks!

War es hilfreich?

Lösung

When we moved from java 6 to java 7 for our java web start product, we found that java 7 would not let our previously self signed jar files run.

We found that java 7 would not accept a Root CA that we had created. Once we used a trusted Root CA the problem went away.

Now, it might be possible to find a way around this. I suggest looking into this (search for keytool): http://www.oracle.com/technetwork/java/javase/jdk7-relnotes-418459.html

Specifically:

Area: Tools Synopsis: A new keytool command (-gencert) is provided to generate a non self-signed certificate. A new option (-ext) is provided to generate several X.509 v3 extensions for the -gencert, -genkeypair, and -certreq commands. There are also other new commands and options for the keytool and jarsigner tools. See the keytool and jarsigner tool docs for more information. RFE: 6780416, 6802846, 6324292, 6890872

The RFE contain links to information that might help you.

Andere Tipps

If your jar depends from other jars, be sure that you signed them as well. Open your MANIFEST.MF and check Class-Path.

I prefer to use ant for this purpose to compile, create and sign jars.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top