java - OSGi ClassNotFoundException WSServletContextListener

标签 java web-services maven osgi classloader

我正在编写一个 OSGi 包 (hu.libra.commons.osgi.core.wsbundle),其中包含一个 Web 服务服务器 (com.sun.xml.ws/jaxws-rt)。 这是可行的,但是生成的包包含 5Mb 的嵌入式 jar,我不想将其包含在我的所有 Web 服务包中(毕竟 OSGi 是关于模块化的),我想将它们放入“Web 服务核心”包(hu.libra.commons.webservice.core)中,并且我的所有 Web 服务都将依赖于此。

但是当我尝试这样做时,我得到 java.lang.ClassNotFoundException: com.sun.xml.ws.transport.http.servlet.WSServletContextListener 异常。 有什么问题吗?

当前正在运行 pom.xml (hu.libra.commons.osgi.core.wsbundle)

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <bundlename>hu.libra.commons.osgi.core.wsbundle</bundlename>
</properties>

<organization>
    <name>Libra Szoftver Zrt.</name>
    <url>http://www.libra.hu</url>
</organization>

<modelVersion>4.0.0</modelVersion>
<groupId>hu.libra.commons</groupId>
<artifactId>libra-commons-osgi-core-wsbundle</artifactId>
<version>1.7.0</version>
<name>Libra Common OSGi Core Webservice Bundle</name>
<packaging>war</packaging>

<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
        </resource>
    </resources>

    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <archive>
                    <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                </archive>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <extensions>true</extensions>
            <executions>
                <execution>
                    <id>bundle-manifest</id>
                    <phase>process-classes</phase>
                    <goals>
                        <goal>manifest</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <supportedProjectTypes>
                    <supportedProjectType>war</supportedProjectType>
                </supportedProjectTypes>
                <instructions>
                    <Bundle-SymbolicName>${bundlename}</Bundle-SymbolicName>
                    <Private-Package>hu.libra.commons.osgi.core.wsbundle</Private-Package>   
                    <Import-Package>
                        org.osgi.framework,
                        javax.servlet,
                        javax.servlet.http,
                        hu.libra.commons.osgi.utils,
                        hu.libra.commons.osgi.core.service                          
                    </Import-Package>
                    <DynamicImport-Package>
                        javax.*,
                        org.xml.sax,
                        org.xml.sax.*,
                        org.w3c.*                           
                    </DynamicImport-Package>
                    <Bundle-ClassPath>.,WEB-INF/classes</Bundle-ClassPath> 
                    <Embed-Directory>WEB-INF/lib</Embed-Directory>
                    <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
                    <Embed-Transitive>true</Embed-Transitive>
                    <Web-ContextPath>/libraosgicore</Web-ContextPath>
                    <Webapp-Context>/libraosgicore</Webapp-Context>
                </instructions>
            </configuration>
        </plugin>
    </plugins>
    <finalName>${bundlename}-${project.version}</finalName>
</build>

<dependencies>
    <!-- OSGi -->
    <dependency>
        <groupId>org.osgi</groupId>
        <artifactId>org.osgi.core</artifactId>
        <version>6.0.0</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>jaxws-rt</artifactId>
        <version>2.2.10</version>
    </dependency>


    <!-- Libra OSGi Core Service -->
    <dependency>
        <groupId>hu.libra.commons</groupId>
        <artifactId>libra-commons-osgi-utils</artifactId>
        <version>1.7.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>hu.libra.commons</groupId>
        <artifactId>libra-commons-osgi-core-service</artifactId>
        <version>1.7.0</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

接下来的两个 pom 不起作用,我得到 java.lang.ClassNotFoundException: com.sun.xml.ws.transport.http.servlet.WSServletContextListener 异常。

pom.xml(hu.libra.commons.webservice.core)

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <bundlename>hu.libra.commons.webservice.core</bundlename>
</properties>

<organization>
    <name>Libra Szoftver Zrt.</name>
    <url>http://www.libra.hu</url>
</organization>

<modelVersion>4.0.0</modelVersion>
<groupId>hu.libra.commons</groupId>
<artifactId>libra-commons-webservice-core</artifactId>
<version>1.7.0</version>
<name>Libra Commons Webservice Core</name>
<packaging>bundle</packaging>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <extensions>true</extensions>
            <executions>
                <execution>
                    <id>bundle-manifest</id>
                    <phase>process-classes</phase>
                    <goals>
                        <goal>manifest</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <supportedProjectTypes>
                    <supportedProjectType>jar</supportedProjectType>
                    <supportedProjectType>bundle</supportedProjectType>
                </supportedProjectTypes>
                <instructions>
                    <Bundle-SymbolicName>${bundlename}</Bundle-SymbolicName>                        
                    <Import-Package>
                        org.osgi.framework,
                        javax.servlet,
                        javax.servlet.http                          
                    </Import-Package>
                    <DynamicImport-Package>
                        javax.*,
                        org.xml.sax,
                        org.xml.sax.*,
                        org.w3c.*                           
                    </DynamicImport-Package>
                    <Export-Package>*</Export-Package>
                    <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
                    <Embed-Transitive>true</Embed-Transitive>                       
                </instructions>
            </configuration>
        </plugin>
    </plugins>
    <finalName>${bundlename}-${project.version}</finalName>
</build>
<dependencies>
    <dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>jaxws-rt</artifactId>
        <version>2.2.10</version>
    </dependency>
</dependencies>

pom.xml(hu.libra.commons.osgi.core.wsbundle)

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <bundlename>hu.libra.commons.osgi.core.wsbundle</bundlename>
</properties>

<organization>
    <name>Libra Szoftver Zrt.</name>
    <url>http://www.libra.hu</url>
</organization>

<modelVersion>4.0.0</modelVersion>
<groupId>hu.libra.commons</groupId>
<artifactId>libra-commons-osgi-core-wsbundle</artifactId>
<version>1.7.0</version>
<name>Libra Common OSGi Core Webservice Bundle</name>
<packaging>war</packaging>

<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
        </resource>
    </resources>

    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <archive>
                    <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                </archive>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <extensions>true</extensions>
            <executions>
                <execution>
                    <id>bundle-manifest</id>
                    <phase>process-classes</phase>
                    <goals>
                        <goal>manifest</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <supportedProjectTypes>
                    <supportedProjectType>war</supportedProjectType>
                </supportedProjectTypes>
                <instructions>
                    <Bundle-SymbolicName>${bundlename}</Bundle-SymbolicName>
                    <Private-Package>hu.libra.commons.osgi.core.wsbundle</Private-Package>
                    <Bundle-ClassPath>.,WEB-INF/classes</Bundle-ClassPath>
                    <Web-ContextPath>/libraosgicore</Web-ContextPath>
                    <Webapp-Context>/libraosgicore</Webapp-Context>
                </instructions>
            </configuration>
        </plugin>
    </plugins>
    <finalName>${bundlename}-${project.version}</finalName>
</build>

<dependencies>
    <!-- OSGi -->
    <dependency>
        <groupId>org.osgi</groupId>
        <artifactId>org.osgi.core</artifactId>
        <version>6.0.0</version>
        <scope>provided</scope>
    </dependency>

    <!-- Libra OSGi Core Service -->
    <dependency>
        <groupId>hu.libra.commons</groupId>
        <artifactId>libra-commons-osgi-utils</artifactId>
        <version>1.7.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>hu.libra.commons</groupId>
        <artifactId>libra-commons-osgi-core-service</artifactId>
        <version>1.7.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>hu.libra.commons</groupId>
        <artifactId>libra-commons-webservice-core</artifactId>
        <version>1.7.0</version>
        <scope>provided</scope>
    </dependency>       
</dependencies>

异常日志/堆栈跟踪

    java.lang.ClassNotFoundException: com.sun.xml.ws.transport.http.servlet.WSServletContextListener
    at java.lang.ClassLoader.findClass(ClassLoader.java:530)
    at org.apache.felix.http.jetty.internal.WebAppBundleContext$1.findClass(WebAppBundleContext.java:54)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at org.eclipse.jetty.server.handler.ContextHandler.loadClass(ContextHandler.java:1681)
    at org.eclipse.jetty.webapp.StandardDescriptorProcessor.visitListener(StandardDescriptorProcessor.java:1897)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.jetty.webapp.IterativeDescriptorProcessor.visit(IterativeDescriptorProcessor.java:83)
    at org.eclipse.jetty.webapp.IterativeDescriptorProcessor.process(IterativeDescriptorProcessor.java:70)
    at org.eclipse.jetty.webapp.MetaData.resolve(MetaData.java:403)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1364)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:778)
    at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:262)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:520)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.apache.felix.http.jetty.internal.JettyService$4.doExecute(JettyService.java:817)
    at org.apache.felix.http.jetty.internal.JettyService$JettyOperation.call(JettyService.java:976)
    at org.apache.felix.http.jetty.internal.JettyService$JettyOperation.call(JettyService.java:966)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
2017-05-30 09:12:27.083:WARN:oejs.BaseHolder:Jetty HTTP Service: 
java.lang.ClassNotFoundException: com.sun.xml.ws.transport.http.servlet.WSServlet
    at java.lang.ClassLoader.findClass(ClassLoader.java:530)
    at org.apache.felix.http.jetty.internal.WebAppBundleContext$1.findClass(WebAppBundleContext.java:54)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at org.eclipse.jetty.util.Loader.loadClass(Loader.java:86)
    at org.eclipse.jetty.servlet.BaseHolder.doStart(BaseHolder.java:95)
    at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:361)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:874)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:349)
    at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1404)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1366)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:778)
    at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:262)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:520)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.apache.felix.http.jetty.internal.JettyService$4.doExecute(JettyService.java:817)
    at org.apache.felix.http.jetty.internal.JettyService$JettyOperation.call(JettyService.java:976)
    at org.apache.felix.http.jetty.internal.JettyService$JettyOperation.call(JettyService.java:966)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
2017-05-30 09:12:27.083:WARN:/libraosgicore:Jetty HTTP Service: unavailable
javax.servlet.UnavailableException: com.sun.xml.ws.transport.http.servlet.WSServlet
    at org.eclipse.jetty.servlet.BaseHolder.doStart(BaseHolder.java:102)
    at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:361)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:874)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:349)
    at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1404)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1366)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:778)
    at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:262)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:520)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.apache.felix.http.jetty.internal.JettyService$4.doExecute(JettyService.java:817)
    at org.apache.felix.http.jetty.internal.JettyService$JettyOperation.call(JettyService.java:976)
    at org.apache.felix.http.jetty.internal.JettyService$JettyOperation.call(JettyService.java:966)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
2017-05-30 09:12:27.084:WARN:oejs.BaseHolder:Jetty HTTP Service: 
java.lang.ClassNotFoundException: com.sun.xml.ws.transport.http.servlet.WSServlet
    at java.lang.ClassLoader.findClass(ClassLoader.java:530)
    at org.apache.felix.http.jetty.internal.WebAppBundleContext$1.findClass(WebAppBundleContext.java:54)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at org.eclipse.jetty.util.Loader.loadClass(Loader.java:86)
    at org.eclipse.jetty.servlet.BaseHolder.doStart(BaseHolder.java:95)
    at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:361)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:892)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:349)
    at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1404)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1366)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:778)
    at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:262)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:520)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.apache.felix.http.jetty.internal.JettyService$4.doExecute(JettyService.java:817)
    at org.apache.felix.http.jetty.internal.JettyService$JettyOperation.call(JettyService.java:976)
    at org.apache.felix.http.jetty.internal.JettyService$JettyOperation.call(JettyService.java:966)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
2017-05-30 09:12:27.084:WARN:/libraosgicore:Jetty HTTP Service: unavailable
javax.servlet.UnavailableException: com.sun.xml.ws.transport.http.servlet.WSServlet
    at org.eclipse.jetty.servlet.BaseHolder.doStart(BaseHolder.java:102)
    at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:361)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:892)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:349)
    at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1404)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1366)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:778)
    at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:262)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:520)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.apache.felix.http.jetty.internal.JettyService$4.doExecute(JettyService.java:817)
    at org.apache.felix.http.jetty.internal.JettyService$JettyOperation.call(JettyService.java:976)
    at org.apache.felix.http.jetty.internal.JettyService$JettyOperation.call(JettyService.java:966)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
2017-05-30 09:12:27.085:WARN:oejw.WebAppContext:Jetty HTTP Service: Failed startup of context o.a.f.h.j.i.WebAppBundleContext@42a7d0a{/libraosgicore,bundle://23.0:0/,UNAVAILABLE}{libraosgicore}
MultiException[javax.servlet.UnavailableException: com.sun.xml.ws.transport.http.servlet.WSServlet, javax.servlet.UnavailableException: com.sun.xml.ws.transport.http.servlet.WSServlet]
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:846)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:349)
    at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1404)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1366)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:778)
    at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:262)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:520)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.apache.felix.http.jetty.internal.JettyService$4.doExecute(JettyService.java:817)
    at org.apache.felix.http.jetty.internal.JettyService$JettyOperation.call(JettyService.java:976)
    at org.apache.felix.http.jetty.internal.JettyService$JettyOperation.call(JettyService.java:966)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Suppressed: 
    |javax.servlet.UnavailableException: com.sun.xml.ws.transport.http.servlet.WSServlet
    |   at org.eclipse.jetty.servlet.BaseHolder.doStart(BaseHolder.java:102)
    |   at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:361)
    |   at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    |   at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:892)
    |   at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:349)
    |   at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1404)
    |   at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1366)
    |   at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:778)
    |   at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:262)
    |   at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:520)
    |   at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    |   at org.apache.felix.http.jetty.internal.JettyService$4.doExecute(JettyService.java:817)
    |   at org.apache.felix.http.jetty.internal.JettyService$JettyOperation.call(JettyService.java:976)
    |   at org.apache.felix.http.jetty.internal.JettyService$JettyOperation.call(JettyService.java:966)
    |   at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    |   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    |   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    |   at java.lang.Thread.run(Thread.java:745)
Caused by: 
javax.servlet.UnavailableException: com.sun.xml.ws.transport.http.servlet.WSServlet
    at org.eclipse.jetty.servlet.BaseHolder.doStart(BaseHolder.java:102)
    at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:361)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:874)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:349)
    at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1404)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1366)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:778)
    at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:262)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:520)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.apache.felix.http.jetty.internal.JettyService$4.doExecute(JettyService.java:817)
    at org.apache.felix.http.jetty.internal.JettyService$JettyOperation.call(JettyService.java:976)
    at org.apache.felix.http.jetty.internal.JettyService$JettyOperation.call(JettyService.java:966)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

最佳答案

问题可能是 com.sun.xml 包位于 Java 框架中 - 据我所知,jaxws 运行时是随 JRE 一起提供的。 java框架包可以定义在容器的启动委托(delegate)包中,也可以定义为框架扩展包。

扩展 Pom 示例:

<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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.github.livesense</groupId>
    <artifactId>org.liveSense.parent</artifactId>
    <version>1.0.6-SNAPSHOT</version>
    <relativePath>..</relativePath>
  </parent>
  <version>1.0.6-SNAPSHOT</version>
<scm>
  <connection>scm:git:https://github.com/liveSense/org.liveSense.fragment.sun.misc.git</connection>
  <developerConnection>scm:git:https://github.com/liveSense/org.liveSense.fragment.sun.misc.git</developerConnection>
  <url>https://github.com/liveSense/org.liveSense.fragment.sun.misc</url>
  <tag>HEAD</tag>
</scm>
<artifactId>org.liveSense.fragment.sun.misc</artifactId>
<packaging>jar</packaging>
<name>liveSense :: Extension :: Sun misc</name>
<description>
        This bundle extends the System Bundle export
        list with the sun.misc package such
        that OSGi bundles may refer to Sun's misc implementation
        without the OSGi framework itself to provide it in a
        non-portable way.
</description>
<build>
  <plugins>
    <plugin>
      <artifactId>maven-jar-plugin</artifactId>
      <configuration>
        <forceCreation>true</forceCreation>
        <archive>
          <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
          <manifestEntries>
            <Export-Package>sun.misc</Export-Package>
          </manifestEntries>
        </archive>
      <configuration>
    </plugin>
    <plugin>
      <groupId>org.apache.felix</groupId>
      <artifactId>maven-bundle-plugin</artifactId>
      <executions>
        <execution>
          <id>bundle-manifest</id>
          <phase>process-classes</phase>
          <goals>
            <goal>manifest</goal>
          </goals>
        </execution>
      </executions>
      <configuration>
        <instructions>
          <Bundle-Category>liveSense</Bundle-Category>
          <Fragment-Host>system.bundle; extension:=framework</Fragment-Host>
        </instructions>
      </configuration>
    </plugin>
  </plugins>
</build>
</project>

并且 com.sun.misc 包可以通过捆绑导入。

关于java - OSGi ClassNotFoundException WSServletContextListener,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44258814/

相关文章:

java - "Multiple markers at this line"

java - 需要 SWT 通知动画框(又名 toastr )

java - 无法生成有效的网页。引用

java - 学习 Flex Java Web 服务的建议

maven - 运行 selenium maven 插件时 firefox 配置文件为 "parent.lock"

java - Maven 找不到存储库中已存在的 Artifact

java - 强制 maven 在 OpenDaylight 中使用来自 Yang 的旧编译 java 类

java - 当赋值运算符的优先级最低时,y=x++ 和 y=x-- 有何不同?

android - 在 Internet 上发布我的 RESTful Web 服务

java - Hibernate + SQLite 数据库外部 jar