2017-04-14 88 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> 
相關問題