2015-04-29 47 views
5

我有一個Java桌面應用程序,它使用JAX-WS在Java SE中使用默認Metro JAX-WS實現調用某些Web服務 - 這是一個通過Java Web Start啓動的SWT應用程序(的.jnlp)。 Web服務還沒有,直到最近幾個實例開始有錯誤時,Web服務調用初始化任何問題:在Java SE 8中無法訪問Metro配置

WARNING: MASM0010: Unable to unmarshall metro config file from location [ jar:file:/C:/Program%20Files%20(x86)/Java/jre1.8.0_31/lib/resources.jar!/com/sun/xml/internal/ws/assembler/jaxws-tubes-default.xml ] 
java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessDeclaredMembers") 

最終導致:

SEVERE: MASM0003: Default [ jaxws-tubes-default.xml ] configuration file was not loaded. 

所有客戶的體驗此問題在Windows上使用JRE 1.8.31-45(x86和x86_64)。我一直在搜尋這個網站和谷歌,但一直沒能找到任何關於這個問題的信息。

感謝您對此問題的任何見解!

+0

你應該嘗試發現引入問題的版本,即什麼是最新的Java版本沒有問題,什麼是最舊的版本與問題... – Holger

+0

問題最先出現與8u45,所以我認爲這是問題...但昨天它發生在8u31,所以我不知道該怎麼想。 – idlegravity

+0

看看http://stackoverflow.com/questions/23011547/webservice-client-generation-error-with-jdk8 – heelha

回答

1

從jre 1.7_80升級到1.8.0_51後,我們在嘗試啓動web服務時收到「MASM0003」錯誤。 在發佈之前設置ContextClassLoader解決了問題:

Thread.currentThread()。setContextClassLoader(getClass()。getClassLoader()); endpoint = Endpoint.publish(wsdlUrl,engine);

0

我想你和我一樣符合issue

private static JAXBContext createJAXBContext() throws Exception { 
     return isJDKInternal()?(JAXBContext)AccessController.doPrivileged(new PrivilegedExceptionAction<JAXBContext>() { 
      public JAXBContext run() throws Exception { 
       return JAXBContext.newInstance(MetroConfig.class.getPackage().getName()); 
      } 
     }, createSecurityContext()):JAXBContext.newInstance(MetroConfig.class.getPackage().getName()); 
} 

private static AccessControlContext createSecurityContext() { 
    PermissionCollection perms = new Permissions(); 
    perms.add(new RuntimePermission("accessClassInPackage.com.sun.xml.internal.ws.runtime.config")); 
    perms.add(new ReflectPermission("suppressAccessChecks")); 
    return new AccessControlContext(new ProtectionDomain[]{new ProtectionDomain((CodeSource)null, perms)}); 
} 

這是代碼在JDK MetroConfigLoader,它會加載特定權限的資源,這是根本原因,所以你可以使用jaxws-rt這是第三件庫來實現它,

或者你可以將您的資源加載到您的類加載器中,並使用AccessController.doPrivileged,這樣您就可以訪問您的資源。