我是否需要专门包含JAX-RS和HttpServlet jar以将Swagger 2.0集成到我的JAX-RS项目中?
我正在尝试展示按以下规范开发的RESTful服务:
项目成功部署到Glassfish上,但是当调用任何REST服务时,它会抛出错误404.服务器日志抱怨类加载错误,特别是javax.ws.rs。*(尽管javax.ws.rs提供-api),并生产
java.lang.NoClassDefFoundError: javax/ws/rs/core/Application
pom.xml - Maven Bundle插件
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.5.4</version>
<extensions>true</extensions>
<configuration>
<supportedProjectTypes>
<supportedProjectType>ejb</supportedProjectType>
<supportedProjectType>war</supportedProjectType>
<supportedProjectType>bundle</supportedProjectType>
<supportedProjectType>jar</supportedProjectType>
</supportedProjectTypes>
<instructions>
<!-- Specify elements to add to MANIFEST.MF -->
<Web-ContextPath>/sample</Web-ContextPath>
<!-- By default, nothing is exported -->
<!--<Export-Package>!*.impl.*, *</Export-Package>-->
<Import-Package>
!com.sun*;resolution:=optional,
!javassist*;resolution:=optional,
!groovy*;resolution:=optional,
!javax.microedition*;resolution:=optional,
!org.apache*;resolution:=optional,
!org.codehaus*;resolution:=optional,
!nu.xom;resolution:=optional,
!org*;resolution:=optional,*
</Import-Package>
<Bundle-ClassPath>.,WEB-INF/classes,WEB-INF/lib/slf4j-api-1.7.12.jar,WEB-INF/lib/slf4j-jdk14-1.7.12.jar,{maven-dependencies}</Bundle-ClassPath>
<Embed-Dependency>
annotations,asm-all-repackaged,cglib,
aopalliance-repackaged,commons-lang3,commons-vfs2,
dom4j,gson,guava,
hk2-api,hk2-locator,hk2-utils,
jackson-core,jackson-annotations,jackson-databind,
jackson-dataformat-yaml,jackson-dataformat-xml,
jackson-datatype-joda,jackson-jaxrs-base,
jackson-jaxrs-json-provider,
jackson-module-jaxb-annotations,
javaee-web-api,
javassist,
javax.ws.rs-api,
javax.annotation-api,javax.inject,javax.json-api,
javax.servlet-api,
jaxen,jaxb-api,
jersey-client,jersey-common,jersey-server,
jersey-container-servlet-core,
jersey-media-multipart,
joda-convert,joda-time,jsch,jsr311-api,jzlib,
logback-classic,logback-core,
mongo-java-driver,maven,mimepull,
org.apache.felix.scr.annotations,
org.apache.servicemix.bundles.commons-httpclient,
org.osgi.compendium,org.osgi.core,
osgi-cdi-api,osgi-resource-locator,
pull-parser,reflections,
slf4j-api,slf4j-jdk14,
snakeyaml,stax2-api,
swagger-annotations,swagger-core,swagger-jaxrs,
swagger-jersey2-jaxrs,swagger-models,
validation-api;
scope=compile|runtime;
</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
<execution>
<id>bundle-install</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
</plugin>
到目前为止完成的工作:
答案 0 :(得分:0)
确保系统包提供了javax.ws.rs。*包。您可以使用Felix Gogo Remote Shell连接到OSGi Module Management Subsystem glassfish,并使用内置命令查询注册表。