再次是我。今天,我面临着一个奇怪的问题。要么我没有正确理解某些东西,要么我只是错过了树前的福雷斯特。
以下情景:
以下是一些更多的环境信息和我的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不在类路径上。
因此,我不关心我是从服务器还是本地主机打开小程序。
这是stacktrace:
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,这是一个类加载问题吗?没有这个例外,该应用程序就像一个魅力。我可以做我需要做的所有Web服务:连接,切换URL,......所以我不希望这是原因。
另外注意:我认为现在这里没关系,但是因为我正在使用guice,当然我的JNLP文件有
<security>
</all-permissions>
</security>
标记。
你们有没有经历过这个?也许我真的只是错过了一件事,但任何帮助(一如既往;))都非常感激:)
答案 0 :(得分:1)
最后我在classpath中得到了tools.jar。我发现它在我正在发送的jar文件的清单中缺失,其中包含我的客户端应用程序。
由于这是一个JavaFX应用程序,我需要在客户端子模块的清单文件配置的classpath标记中添加tools.jar依赖项:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
...
<Class-Path>jfxrt.jar tools.jar</Class-Path>
</manifestEntries>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
在类路径中有tools.jar之后,CXF尝试调用java编译器,请参阅错误消息:
org.apache.cxf.common.jaxb.JAXBUtils logGeneratedClassNames
INFO: Created classes: <list of my generated JAVA files from the wsdl file here>
[ERROR] IOException during exec() of compiler "javac". Check your path environment variable.
Okt 23, 2012 3:46:20 PM org.apache.cxf.endpoint.dynamic.DynamicClientFactory createClient
SEVERE: Could not compile java files for <url to wsdl file here>.
所以这对我来说意味着我需要在客户机上运行并设置JDK。如果我也服务于javac(只是一个思想游戏不要怪我:)),这意味着我需要在客户端机器上执行一些东西,这对我来说是不行的。
那样,我会为我最初想要的东西找到一个替代解决方案(解决方案将外包generate-ws-acces-classes)。
但是,对于如何在类路径中集成tools.jar的初始问题,我上面写的内容为我解决了这个问题。