又是我。而今天,我面临着一个奇怪的问题。要么我没有正确理解某些东西,要么我只是想念树前的阿甘。
以下场景:
- 我正在使用捆绑在 JDK 1.7 中的 JavaFX
- 我需要两个客户端运行时:桌面(jar)和小程序(浏览器内的 jnlp)
- 我为该项目设置了一个 Maven 项目
- 我有一个父 pom 和不同的子模块
- 我需要我的客户端与 Web 服务进行通信,因为我选择了CXF作为框架(我需要能够在运行时切换 Web 服务)以连接到 Web 服务
- “连接到 Web 服务的东西”是一个名为 wsConnector 的自己的 maven 子模块
这是更多环境信息和我的 pom 片段:
mvn -version
Apache Maven 3.0.4 (r1232337; 2012-01-17 09:44:56+0100)
Maven home: C:\Program Files (x86)\Apache\maven-3.0.4\bin\..
Java version: 1.7.0_07, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_07\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
为了能够编译 wsConnector 子模块,它再次处理所有 Web 服务连接的东西,我需要从 JDK 集成 tools.jar,因为 CXF 需要它。
来自父 pom.xml 的相关属性:
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
...
</properties>
子模块 pom.xml:
<properties>
<cxf.version>2.6.2</cxf.version>
</properties>
<dependencies>
<dependency>
... // some other sub modules
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>tools</artifactId>
<version>${maven.compiler.source}]</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
如果我跑步mvn clean package
,一切正常,花花公子。在我的客户端应用程序的部署目录中(jar、生成的 HTML 和 jnlp 文件也在其中),我也找到了tools.jar
.
如果我查看 JNLP 文件,我会找到以下条目:
<jar href="tools.jar" size="15226565" download="eager" />
现在我的问题是:如果我用 运行客户端java -jar client.jar
,一切正常。但是,如果我调用 HTML / JNLP 文件,我会得到一个ClassNotFoundException
,指出 tools.jar 不在类路径中。因此,不管我是从服务器还是本地主机打开小程序。
这是堆栈跟踪:
java.lang.IllegalStateException: Unable to create schema compiler
at org.apache.cxf.common.jaxb.JAXBUtils.createSchemaCompilerWithDefaultAllocator(JAXBUtils.java:694)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:303)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:270)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:263)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:198)
at com.multiguide.ws.WebServiceConnector.setWsdlUrl(WebServiceConnector.java:45)
at com.multiguide.ws.WebServiceConnector.setWsdlUrl(WebServiceConnector.java:31)
at com.multiguide.view.administration.WebServiceInformationPanel.connect(WebServiceInformationPanel.java:130)
at com.multiguide.view.administration.WebServiceInformationPanel.refresh(WebServiceInformationPanel.java:70)
at com.multiguide.view.administration.WebServiceInformationPanel.<init>(WebServiceInformationPanel.java:45)
at com.multiguide.view.administration.WebServiceInformationPanel$$FastClassByGuice$$da5f387e.newInstance(<generated>)
at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40)
at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:60)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:84)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1031)
at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
at com.google.inject.Scopes$1$1.get(Scopes.java:65)
at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:84)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:54)
at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:84)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1031)
at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
at com.google.inject.Scopes$1$1.get(Scopes.java:65)
at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
at com.google.inject.internal.InjectorImpl$4$1.call(InjectorImpl.java:978)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1024)
at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:974)
... 9 more
Caused by: javax.xml.bind.JAXBException - with linked exception:
java.lang.ClassNotFoundException: com/sun/tools/internal/xjc/api/XJC
at org.apache.cxf.common.jaxb.JAXBUtils.createSchemaCompiler(JAXBUtils.java:679)
at org.apache.cxf.common.jaxb.JAXBUtils.createSchemaCompilerWithDefaultAllocator(JAXBUtils.java:686)
... 49 more
Caused by:
java.lang.ClassNotFoundException: com/sun/tools/internal/xjc/api/XJC
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.cxf.common.jaxb.JAXBUtils.createSchemaCompiler(JAXBUtils.java:672)
... 50 more
当我使用 guice 时,这是一个类加载问题吗?没有这个例外,该应用程序就像一个魅力。我可以做所有我需要做的网络服务工作:连接、切换 URL,......所以我不认为这是原因。
另外请注意:我认为现在在这里没关系,但是由于我使用的是 guice,当然我的 JNLP 文件有
<security>
</all-permissions>
</security>
旗帜。
你们有没有人有这方面的经验?也许我真的只是想念一件事,但任何帮助(一如既往;))非常感谢:)