4
我是否需要專門包含JAX-RS和HttpServlet jar來將Swagger 2.0集成到我的JAX-RS項目中?將Swagger 2.0與Glassfish 4.1集成OSGi REST項目
我想提出我在下面的規格開發RESTful服務:
- 的Java
- NetBeans IDE中8.0.2 [Maven的]
- 的OSGi 4.2
- 在JSON項目交流信息格式
- Glassfish 4.1
- JAX-RS 2.0
- 澤西2.0
該項目成功地部署到Glassfish的,但任何的REST服務被調用時,它拋出Error 404服務器的日誌抱怨類加載錯誤,特別是javax.ws.rs。*(被提供,儘管javax.ws.rs-API),併產生 java.lang.NoClassDefFoundError: javax/ws/rs/core/Application
的pom.xml - Maven的捆綁插件
<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>
工作迄今所做的:
- 更新Glassfish的4.1包括澤西2 JAX-RS 2
- 全部爲 「提供」
- 解決重複的依賴