4

まず最初に、私は Java プログラマーではなく、PHP プログラマーです。

Websockets では解決できない状況に遭遇し、解決策を提供する次のサイトを見つけました。

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

これは基本的に、JavaScript で読み込んで制御できる Jar です。それはうまく機能します。同様の機能が必要な人には強くお勧めします。ただし、Jar は署名されていないため、ページが読み込まれるたびにセキュリティ警告が表示されます。これは少し面倒で、Jar に自己署名すると、「今後これを表示しない」/「永久に許可する」チェック ボックスが有効になると思いました。これは組織内で展開されるため、有料の証明書で署名する必要はないようです。

問題は、Jar に署名するとすぐに機能しないことです。クラスが見つからないというエラーが発生します。Jar ファイルに署名する方法を紹介している多数のサイトを調べて、Google で 10 ページを参照しましたが、この種の問題を抱えている人を見つけることができません。

必要と思われる部品を含めます。他に何か必要な場合はお知らせください。入手します。

アプレット コード:

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

Jar に署名した方法 (管理者コマンド プロンプトで):

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>

署名されていない Jar と署名されている Jar の両方を開きましたが、ソース ファイルは同じです。署名された Jar の META-INF フォルダーには、CRTLIVE.RSA と CRTLIVE.SF という 2 つの追加ファイルしかありません。

スレッドダンプは次のとおりです。

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.

スレッド スタックは長めですが、次のとおりです。

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.

私は考えられるすべてのものをグーグルで検索しました。

ありがとう!

4

2 に答える 2

2

Java Web Start 製品のために Java 6 から Java 7 に移行したとき、Java 7 では以前の自己署名付きの jar ファイルを実行できないことがわかりました。

Java 7 は、私たちが作成したルート CA を受け入れないことがわかりました。信頼できるルート CA を使用すると、問題は解消されました。

これで、これを回避する方法を見つけることができるかもしれません。これを調べることをお勧めします(keytoolを検索してください):http://www.oracle.com/technetwork/java/javase/jdk7-relnotes-418459.html

具体的には:

分野: ツール 概要: 非自己署名証明書を生成するための新しい keytool コマンド (-gencert) が提供されています。-gencert、-genkeypair、および -certreq コマンドの複数の X.509 v3 拡張機能を生成するために、新しいオプション (-ext) が提供されています。keytool および jarsigner ツール用のその他の新しいコマンドとオプションもあります。詳細については、keytool および jarsigner ツールのドキュメントを参照してください。RFE: 6780416、6802846、6324292、6890872

RFE には、役立つ情報へのリンクが含まれています。

于 2012-10-17T15:48:40.260 に答える
1

jar が他の jar に依存している場合は、それらにも署名したことを確認してください。MANIFEST.MF を開き、Class-Path を確認します。

この目的で ant を使用して、jar をコンパイル、作成、および署名することを好みます。

于 2012-10-14T09:05:02.783 に答える