Hi
On 19/02/13 15:13, SriramSundararajan01 wrote:
Hi,
I am using CXF 2.5.6 for REST webservices and following the example provided
in this link
http://cxf.apache.org/docs/jax-rs-redirection.html
to redirect the request. I tried both the ways described in the
documentation
1. Return a bean in method and add entries in the xml file as below
<bean id="dispatchProvider"
class="org.apache.cxf.jaxrs.provider.RequestDispatcherProvider">
<property name="classResources">
<map>
<entry key="org.bar.Book" value="/book.jsp"/>
</map>
</property>
<property name="beanNames">
<map>
<entry key="org.bar.Book" value="book"/>
</map>
</property>
</bean
This method worked for me without any issues
2. Return an ENUM in the method and specify the mapping for enum to jsp/html
file in the xml file. My example code is below
@Path("/redirect/")
@GET
@Produces(MediaType.TEXT_HTML)
public Response redirect() {
DemoBean bean = new DemoBean();
return Response.ok(RedirectionStatus.LOGIN_SUCCESS).build();
}
XML file entry:
<bean id="dispatchers"
class="org.apache.cxf.jaxrs.provider.RequestDispatcherProvider">
<property name="classResources">
<map>
<entry key="com.ms.test.rest.RedirectionStatus.LOGIN_SUCCESS"
value="/html/test.jsp"/>
</map>
</property>
</bean>
Register the provider:
<jaxrs:providers>
<ref bean="dispatchers"/>
</jaxrs:providers>
ENUM class :
public enum RedirectionStatus {
LOGIN_SUCCESS
}
When i use the 2nd type I always get an error "No message body writer has
been found for response class RedirectionStatus". I am running clueless on
what is happening and why I am getting this error.
I'm afraid the fix for supporting enums in RequestDispatcheProvider is
not available in 2.5.6 - but is in 2.5.9 - can you try it instead please ?
Thanks, Sergey
My jsp file is outside web-inf folder. I tried even adding the CXF servlet
but no luck.
I tried enabling the CXF TRACE logging to see any additional log messages,
but I was unlucky there also. I gave the system property
org.apache.cxf.Logger=org.apache.cxf.common.logging.Log4jLogger and had the
log4j.xml in classpath with TRACE option. After this I saw some meesage from
Deferrable Alarm"[Deferrable Alarm : 2]
org.apache.cxf.common.logging.LogUtils - Using
org.apache.cxf.common.logging.Log4jLogger for logging". No other messages in
log file too.
Can some one please guide me what I am doing wrong here? I tried searching
the blogs and internet but I am not able to get any break through.
Thanks,
Sriram
--
View this message in context:
http://cxf.547215.n5.nabble.com/No-message-body-writer-has-been-found-error-when-using-enum-for-request-redirection-tp5723377.html
Sent from the cxf-user mailing list archive at Nabble.com.
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com