CXF-Jetty错误:java.lang.IllegalStateException:没有SessionManager

时间:2017-04-14 09:20:25

标签: java spring jetty jax-rs cxf

针对CXF JAXRS休息服务的JUnit测试用例给出了以下错误(找到了一些用于编程配置但寻找spring xml配置解决方案的解决方案) -

Caused by: java.lang.IllegalStateException: No SessionManager
at org.eclipse.jetty.server.Request.getSession(Request.java:1402)

Junit注释 -

@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(locations = {"classpath:test-spring-context.xml"})

jaxrs服务器的弹簧配置 -

<jaxrs:server id="testServer" address="http://localhost:9191/$$$/service">
    <jaxrs:inInterceptors>
        <ref bean="cxfRestInInterceptor" />
    </jaxrs:inInterceptors>
    <jaxrs:outInterceptors>
        <ref bean="cxfRestOutInterceptor" />
    </jaxrs:outInterceptors>
    <jaxrs:serviceBeans>
        <bean class="$$$" />


    </jaxrs:serviceBeans>
     <jaxrs:features>
        <ref bean="swagger2Feature" />
    </jaxrs:features>
    <jaxrs:providers>
        <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" />
        <bean class="$$$" />
        <bean class="$$$">
            <property name="authenticationProvider" ref="authenticationProvider"/>
        </bean>
        <bean class="$$$"></bean>
        <bean class="$$$"/>
    </jaxrs:providers>
    <jaxrs:extensionMappings>
        <entry key="json" value="application/json" />
    </jaxrs:extensionMappings>
</jaxrs:server>

1 个答案:

答案 0 :(得分:0)

以下配置解决了问题http://cxf.apache.org/docs/jetty-configuration.html -

    <httpj:engine-factory bus="cxf" id="port9191">
    <httpj:engine port="9191">
        <httpj:threadingParameters minThreads="5"
            maxThreads="15" />
        <httpj:handlers>
            <bean class="org.eclipse.jetty.server.handler.DefaultHandler" />
        </httpj:handlers>
        <httpj:sessionSupport>true</httpj:sessionSupport>
    </httpj:engine>
</httpj:engine-factory>