【发布时间】:2020-09-01 18:13:49
【问题描述】:
我无法将 WebService 重新联机。到目前为止,它还不是一个 Maven 项目,但我决定继续使用 Maven 依赖项来实现它。在此之前,所有依赖项都是手动复制的。所以我的 pom.xml 看起来像这样:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.iifleuchten.auth.webservice</groupId>
<artifactId>AuthService</artifactId>
<version>0.9</version>
<name>AuthService</name>
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<dependencies>
<!-- jax-ws maven dependency -->
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.1.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.jws/javax.jws-api -->
<dependency>
<groupId>javax.jws</groupId>
<artifactId>javax.jws-api</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.messaging.saaj</groupId>
<artifactId>saaj-impl</artifactId>
<version>1.5.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<archive>
<manifest>
<mainClass>com.iifleuchten.auth.webservice.AuthPublisher</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
我正在使用 eclipse,我可以在 eclipse 中运行 web 服务。它可以工作并且服务可用(使用同一项目中的另一个小程序进行测试,该程序调用本地 web 服务)虽然我在运行服务时收到警告:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.sun.xml.bind.v2.runtime.reflect.opt.Injector$1 (file:/home/manoca/.m2/repository/com/sun/xml/bind/jaxb-impl/2.1.6/jaxb-impl-2.1.6.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int)
WARNING: Please consider reporting this to the maintainers of com.sun.xml.bind.v2.runtime.reflect.opt.Injector$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
当我通过 Eclipse 上下文菜单执行 maven 安装时,构建工作正常并且 jar 被创建。但是,当像 java -jar AuthService.jar 一样调用它时,这个 jar 在 cli 中不起作用。我在那里得到了一个找不到类的异常。他找不到 Endpoint 类:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/ws/Endpoint
这是代码,它偶然发现的地方:
Endpoint.publish("http://0.0.0.0:7779/ws/auth", authImpl);
我认为 javax.jws 包中的其他类确实可以工作,因为 WebService 的所有实现和相应的注释都应该在 Endpoint.publish 之前“发生”,这不会导致任何异常?长话短说:这是我第一次与 Maven 相关的实验,几个小时后,我真的不知道该怎么做。任何建议都非常感谢;)
【问题讨论】: