简体   繁体   English

ClassNotFoundException:javax.xml.ws.Endpoint 尽管具有正确的(?)maven 依赖项并且仅在 CLI 中

[英]ClassNotFoundException: javax.xml.ws.Endpoint despite having the correct(?) maven dependency and only in CLI

I am having troubles bringing a WebService back online.我在将 WebService 重新联机时遇到问题。 It was not a Maven Project till now, but I decided to move on an bring it in shape with Maven dependencies.到目前为止,它还不是一个 Maven 项目,但我决定继续使用 Maven 依赖项来完善它。 Before that point all of the dependencies were copied manually.在此之前,所有依赖项都是手动复制的。 So my pom.xml looks like this:所以我的 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>

I am using eclipse, and I can run the webservice inside eclipse. It works and the service is available (tested with another small program within the same project, which calls the local webservice) although I do get a warning when running the service:我正在使用 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

When I do the maven install thing via the eclipse context menu the build works fine and the jar gets created.当我通过 eclipse 上下文菜单执行 maven 安装时,构建工作正常并创建了 jar。 However, this jar does not work in the cli when calling it like java -jar AuthService.jar.但是,当像 java -jar AuthService.jar 这样调用它时,这个 jar 在 cli 中不起作用。 I get a class not found exception there.我在那里收到 class not found 异常。 He can't find the Endpoint class:他找不到端点 class:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/ws/Endpoint

here's the code, where it stumbles upon:这是它偶然发现的代码:

Endpoint.publish("http://0.0.0.0:7779/ws/auth", authImpl);

I think other classes from for example the javax.jws package do work, as all the implementation of the WebService stuff and the corresponding annotations should "happen" before it comes to the Endpoint.publish and this does not cause any exceptions?我认为来自例如 javax.jws package 的其他类确实有效,因为 WebService 内容的所有实现和相应的注释应该在它到达 Endpoint.publish 之前“发生”,这不会导致任何异常吗? Long story short: this are my first Maven related experiments and after a few hours now, I am really out of ideas what to do.长话短说:这是我的第一个 Maven 相关实验,几个小时后,我真的不知道该怎么做。 Any suggestions are highly appreciated;)非常感谢任何建议;)

Thanks a lot for the hint.非常感谢提示。 I do begin to understand the whole deal a lot more now.我现在确实开始更加了解整个交易。 This link really has some good information although I was just stupid in the first place: https://medium.com/@randilfernando/when-to-use-maven-jar-maven-assembly-or-maven-shade-ffc3f76ba7a6这个链接确实有一些很好的信息,虽然我一开始只是愚蠢的: https://medium.com/@randilfernando/when-to-use-maven-jar-maven-assembly-or-maven-shade-ffc3f76ba7a6

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM