我在weblogic 12.1.3上使用JAX-RS和CDI运行Web应用程序。
我想启用Jersey的Multipart功能,但我在部署时遇到错误。
我使用ResourceConfig配置我的REST应用程序。 它位于一个单独的jar中(让它称之为commons),因为它被多个其他应用程序使用。 并在每个应用程序中扩展另一个类。
public abstract class RestConfig extends ResourceConfig {
public RestConfig() {
property(CommonProperties.MOXY_JSON_FEATURE_DISABLE, true);
register(JacksonFeature.class);
register(RolesAllowedDynamicFeature.class);
register(SecurityFilter.class);
// here I register manually my resources classes because they are not discovered automatically, I don't why)
registerRestPackages(COMMONS_REST_PACKAGES);
registerRestPackages(getRestPackages());
registerRestClasses(getRestLambdaClasses());
// here is the important part that makes my applciation crash on startup
register(MultiPartFeature.class);
}
}
他的课程扩展了这一点:
@ApplicationPath("/api/")
public class RestApplication extends RestConfig {
public RestApplication() {
super();
}
}
根据文档https://docs.oracle.com/middleware/1213/wls/RESTF/use-jersey20-ri.htm#RESTF290
,jersey jar位于共享库中我在启动时遇到了ghis异常:
weblogic.application.ModuleException: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Providers] with qualifiers [@Default] at injection point [[parameter 1] of [constructor] @Inject public org.glassfish.jersey.media.multipart.internal.MultiPartReaderServerSide(Providers, Provider<CloseableService>)]:org.jboss.weld.exceptions.DeploymentException:WELD-001408 Unsatisfied dependencies for type [Providers] with qualifiers [@Default] at injection point [[parameter 1] of [constructor] @Inject public org.glassfish.jersey.media.multipart.internal.MultiPartReaderServerSide(Providers, Provider<CloseableService>)]
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:315)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:284)
at org.jboss.weld.bootstrap.Validator.validateInjectionTarget(Validator.java:342)
at org.jboss.weld.manager.InjectionTargetValidator.addInjectionTarget(InjectionTargetValidator.java:29)
at org.jboss.weld.manager.BeanManagerImpl.createInjectionTarget(BeanManagerImpl.java:943)
at weblogic.jaxrs.onwls.cdi.CdiComponentProvider$CdiFactory$2.<init>(CdiComponentProvider.java:201)
at weblogic.jaxrs.onwls.cdi.CdiComponentProvider$CdiFactory.<init>(CdiComponentProvider.java:180)
at weblogic.jaxrs.onwls.cdi.CdiComponentProvider.bind(CdiComponentProvider.java:262)
at org.glassfish.jersey.server.ApplicationHandler.bindWithComponentProvider(ApplicationHandler.java:874)
at org.glassfish.jersey.server.ApplicationHandler.bindProvidersAndResources(ApplicationHandler.java:804)
at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:414)
at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:162)
at org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:304)
at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)
at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:301)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:311)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:169)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:359)
at javax.servlet.GenericServlet.init(GenericServlet.java:240)
at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:337)
at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:288)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
at weblogic.servlet.internal.StubSecurityHelper.initServletInstance(StubSecurityHelper.java:98)
at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:92)
at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:69)
at weblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:57)
at weblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:36)
at weblogic.servlet.internal.ServletStubImpl.initStubLifecycleHelper(ServletStubImpl.java:653)
at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:600)
at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1979)
at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1956)
at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1846)
at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:2876)
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1661)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:823)
at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.java:360)
at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.java:356)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:138)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:216)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:211)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:73)
at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:24)
at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:729)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:258)
at weblogic.application.internal.SingleModuleDeployment.activate(SingleModuleDeployment.java:48)
at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:165)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:80)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:587)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:150)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:116)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:339)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:846)
at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1275)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:442)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:176)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:68)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:553)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)
问题似乎是应用程序找不到实现接口Providers的bean。 JaxrsProviders类在球衣中很常见,但CDI似乎没有检测到它。
这家伙似乎有同样的问题,但对我没什么帮助:https://community.oracle.com/thread/3723819
如果您有任何想法......
答案 0 :(得分:1)
它应该工作。我已成功使用Multipart
和weblogic 12.1.3以及Jersey 2.5.1。
检查您是否在provided
范围内使用以下依赖关系:
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>2.5.1</version>
<scope>provided</scope>
</dependency>
您可以分享weblogic.xml
或weblogic-application.xml
吗?
答案 1 :(得分:0)
请在weblogc.xml中添加以下库
<wls:library-ref>
<wls:library-name>wlp-rest-web-lib</wls:library-name>
<wls:specification-version>10.3.2</wls:specification-version>
<wls:implementation-version>10.3.2</wls:implementation-version>
<wls:exact-match>false</wls:exact-match>
</wls:library-ref><wls:library-ref>
<wls:library-name>p13n-rest-web-lib</wls:library-name>
<wls:specification-version>10.3.2</wls:specification-version>
<wls:implementation-version>10.3.2</wls:implementation-version>
<wls:exact-match>false</wls:exact-match>
</wls:library-ref>
<wls:library-ref>
<wls:library-name>jaxrs-framework-web-lib</wls:library-name>
<wls:specification-version>10.3.2</wls:specification-version>
<wls:implementation-version>10.3.2</wls:implementation-version>
<wls:exact-match>false</wls:exact-match>
</wls:library-ref><wls:library-ref>
<wls:library-name>jersey-web-lib</wls:library-name>
<wls:specification-version>1.0</wls:specification-version>
<wls:implementation-version>1.0.2</wls:implementation-version>
<wls:exact-match>false</wls:exact-match>
</wls:library-ref>
并从url检查库。
如果仍然出错,请将jersey-media-multipart.jar文件添加到项目lib目录中。
You can change below thing in weblogic-application.xml at ear
<prefer-application-packages>
<package-name>com.sun.jersey.*</package-name>
<package-name>org.glassfish.jersey.*</package-name>
<package-name>org.glassfish.hk2.*</package-name>
<package-name>org.jvnet.hk2.*</package-name>
<package-name>jersey.repackaged.org.objectweb.asm.*</package-name>
<package-name>com.sun.research.ws.wadl.*</package-name>
<package-name>com.sun.ws.rs.ext.*</package-name>
<package-name>org.codehaus.jackson.*</package-name>
<package-name>com.fasterxml.jackson.*</package-name>
<package-name>org.codehaus.jettison.*</package-name>
<package-name>javax.ws.rs.*</package-name>
<package-name>org.objectweb.asm.*</package-name>
<package-name>antlr.*</package-name>
</prefer-application-packages>
和Weblogic 12c
希望它有所帮助。