gpt4 book ai didi

java - Weblogic 12.1.3,Jersey 2.5.1,如何启用MultiPartFeature : WELD-001408 Unsatisfied dependencies for type [Providers]

转载 作者:行者123 更新时间:2023-12-01 09:09:38 25 4
gpt4 key购买 nike

我有一个在 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();
}
}

根据文档, Jersey jar 位于共享库中:https://docs.oracle.com/middleware/1213/wls/RESTF/use-jersey20-ri.htm#RESTF290

我在启动时遇到 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)

问题似乎是应用程序找不到实现接口(interface) Providers 的 bean。jersey-common中有JaxrsProviders类,但CDI似乎没有检测到它。

这家伙似乎也有同样的问题,但它对我没有多大帮助:https://community.oracle.com/thread/3723819

如果你有任何想法......

最佳答案

它应该可以工作。我已成功将 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.xmlweblogic-application.xml吗?

关于java - Weblogic 12.1.3,Jersey 2.5.1,如何启用MultiPartFeature : WELD-001408 Unsatisfied dependencies for type [Providers],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40999580/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com