2017-04-14 98 views
0

JUnit测试案例CXF JAXRS休息服务得到下述错误(展示了其编程配置的解决方案,但在寻找Spring XML配置解决方案) -CXF Jetty的错误:java.lang.IllegalStateException:没有SessionManager

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

Junit的annotations-为

@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> 

回答

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> 
相关问题