请求范围的多个上下文?

时间:2016-11-13 16:02:21

标签: tomcat7 jersey-2.0 weld

我正在尝试将Weld与Tomcat7和Jersey一起使用,在我的日志文件中我看到了这一点:

org.jboss.weld.exceptions.IllegalStateException: WELD-001304: More than one context active for scope type javax.enterprise.context.RequestScoped

应用程序正确部署,我只在尝试点击我的Jersey端点时看到这一点。

以下是pom.xml的相关部分

  <!-- Jersey Deps -->
    <dependency>
        <groupId>org.glassfish.jersey.core</groupId>
        <artifactId>jersey-server</artifactId>
        </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.core</groupId>
        <artifactId>jersey-common</artifactId>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-multipart</artifactId>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.ext</groupId>
        <artifactId>jersey-bean-validation</artifactId>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-json-jackson</artifactId>
    </dependency>
    <!-- CDI Deps -->
    <dependency>
        <groupId>org.jboss.weld.servlet</groupId>
        <artifactId>weld-servlet</artifactId>
        <version>2.3.2.Final</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.ext.cdi</groupId>
        <artifactId>jersey-weld2-se</artifactId>
    </dependency>

这是我的主要应用程序&#34;扩展了ResourceConfig:

public class MainApplication extends ResourceConfig {
public MainApplication() {
    packages(true, "com.example.api");
    property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);
    property(ServerProperties.BV_DISABLE_VALIDATE_ON_EXECUTABLE_OVERRIDE_CHECK, true);
}
}

这是我的web.xml(servlet部分):

    <servlet>
<servlet-name>Jersey Servlet Container</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>net.di2e.isfr.foldr.MainApplication</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Servlet Container</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>

我很遗憾可能会出错。

0 个答案:

没有答案