2014-01-29 146 views
2

我有一個webstart應用程序連接到一個web服務。該清單:Webstart應用程序:SecurityException:setContextClassLoader

Permissions: all-permissions 

而且JNLP有:

<security> 
    <all-permissions/> 
</security> 

然而當創建到Web服務的連接,我收到了java.lang.SecurityException: setContextClassLoader(完整的堆棧跟蹤以下)。當我直接運行應用程序(沒有webstart)時,它工作正常。有什麼我應該檢查或更改我的設置來解決問題?

說明:我正在使用Java 8.該應用程序在構建121時正常工作,但未能構建123,124或125(最新版本)。所以無論我的設置是否正常,並且b121和b123之間引入了一個錯誤,或者b123中的一個錯誤已經修復,這在我的設置中暴露了一個問題。

org.glassfish.hk2.api.MultiException: A MultiException has 2 exceptions. They are: 
1. java.lang.SecurityException: setContextClassLoader 
2. java.lang.IllegalStateException: Unable to perform operation: create on org.jvnet.hk2.internal.DynamicConfigurationServiceImpl 

    at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:362) ~[na:na] 
    at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:454) ~[na:na] 
    at org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:119) ~[na:na] 
    at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2296) ~[na:na] 
    at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:590) ~[na:na] 
    at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:577) ~[na:na] 
    at org.glassfish.hk2.utilities.ServiceLocatorUtilities.enablePerThreadScope(ServiceLocatorUtilities.java:89) ~[na:na] 
    at org.glassfish.jersey.internal.inject.Injections._createLocator(Injections.java:144) ~[na:na] 
    at org.glassfish.jersey.internal.inject.Injections.createLocator(Injections.java:137) ~[na:na] 
    at org.glassfish.jersey.client.ClientConfig$State.initRuntime(ClientConfig.java:352) ~[na:na] 
    at org.glassfish.jersey.client.ClientConfig$State.access$000(ClientConfig.java:85) ~[na:na] 
    at org.glassfish.jersey.client.ClientConfig$State$3.get(ClientConfig.java:117) ~[na:na] 
    at org.glassfish.jersey.client.ClientConfig$State$3.get(ClientConfig.java:114) ~[na:na] 
    at org.glassfish.jersey.internal.util.collection.Values$LazyValue.get(Values.java:311) ~[na:na] 
    at org.glassfish.jersey.client.ClientConfig.getRuntime(ClientConfig.java:669) ~[na:na] 
    at org.glassfish.jersey.client.ClientRequest.getConfiguration(ClientRequest.java:214) ~[na:na] 
    at org.glassfish.jersey.client.JerseyInvocation.validateHttpMethodAndEntity(JerseyInvocation.java:124) ~[na:na] 
    at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:97) ~[na:na] 
    at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:90) ~[na:na] 
    at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:396) ~[na:na] 
    at org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:296) ~[na:na] 
    at com.assylias.fund.master.impl.DefaultUserMaster.authenticate(DefaultUserMaster.java:55) ~[na:na] 
    at com.assylias.bigblue.gui.javafx.users.Login$AuthenticationTask.call(Login.java:342) ~[na:na] 
    at com.assylias.bigblue.gui.javafx.users.Login$AuthenticationTask.call(Login.java:325) ~[na:na] 
    at javafx.concurrent.Task$TaskCallable.call(Unknown Source) ~[na:na] 
    at java.util.concurrent.FutureTask.run(Unknown Source) ~[na:1.8.0-ea] 
    at java.util.concurrent.CompletableFuture$AsyncRun.exec(Unknown Source) ~[na:1.8.0-ea] 
    at java.util.concurrent.ForkJoinTask.doExec(Unknown Source) ~[na:1.8.0-ea] 
    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(Unknown Source) ~[na:1.8.0-ea] 
    at java.util.concurrent.ForkJoinPool.scan(Unknown Source) ~[na:1.8.0-ea] 
    at java.util.concurrent.ForkJoinPool.runWorker(Unknown Source) ~[na:1.8.0-ea] 
    at java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source) ~[na:1.8.0-ea] 
Caused by: java.lang.SecurityException: setContextClassLoader 
    at java.util.concurrent.ForkJoinWorkerThread$InnocuousForkJoinWorkerThread.setContextClassLoader(Unknown Source) ~[na:1.8.0-ea] 
    at org.glassfish.hk2.utilities.reflection.ReflectionHelper$2.run(ReflectionHelper.java:1049) ~[na:na] 
    at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0-ea] 
    at org.glassfish.hk2.utilities.reflection.ReflectionHelper.setContextClassLoader(ReflectionHelper.java:1045) ~[na:na] 
    at org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1101) ~[na:na] 
    at org.jvnet.hk2.internal.ClazzCreator.createMe(ClazzCreator.java:261) ~[na:na] 
    at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:336) ~[na:na] 

回答

3

我應該仔細閱讀stacktrace。 java.util.concurrent.ForkJoinWorkerThread$InnocuousForkJoinWorkerThread.setContextClassLoader這是一個默認的,沒有權限的工作線程引發的異常。更改已在this post之後,並且這是diff

CompletableFuture.runAsync(accessWebservice()); 

它使用默認的線程池ForkJoinPool,這本身就依賴於新InnocuousForkJoinWorkerThread,它拋出一個異常,如果setContextClassLoader被稱爲:

我和訪問Web服務。

解決方法:

CompletableFuture.runAsync(accessWebservice(), executor); //provide an executor 
相關問題