Problems using Jettison for JSON mapped parsing

2008-04-07 Thread rm-ramos

Hi all,

I developed a REST web service using CXF's http binding, and I have no
problem at all with the object  marshaling or the reading of the XML
outputs. I now need to get JSON output from the same web service, so I
configured a new ws endpoint in spring, which will return the JSON in the
"mapped" format.

However, I started to notice odd JSON files being produced, and wrong XML
object conversion. I'll give this example, in which I need a List of labels
and a List of value objects (and who contain a list themselves) to be
returned.

http://www.nabble.com/file/p16538281/xml.xml xml.xml 
http://www.nabble.com/file/p16538281/json.json json.json 

The JSON output, as you can see, is strangely groupin values objects, two by
two, without any particular reason. These are the objects which originate
such a result:

The response:
@XmlAccessorType(XmlAccessType.FIELD)
public class QueryByIdResponse extends GenericResponse {

@XmlElementWrapper(name="labels")
private List label;

private List values;


WorkOrderGenericValues:
@XmlAccessorType(XmlAccessType.FIELD)
public class WorkOrderGenericValues {
@XmlElement(name="value")
private List stringList;


Is this a Jettison bug or am I missing something??
Any tip would be greatly appreciated!! 

Thanks
Rui Ramos
-- 
View this message in context: 
http://www.nabble.com/Problems-using-Jettison-for-JSON-mapped-parsing-tp16538281p16538281.html
Sent from the cxf-user mailing list archive at Nabble.com.



CXF problem using extended class as Web Param

2008-02-27 Thread rm-ramos

Hi all,

I'm implementing an unwrapped REST web service using HTTP Binding, deployed
on JBoss, using Spring. 
In a specific method I need to use a class that's extending other as a web
parameter. Lets say:


The web service:
@Post 
@HttpResource(location="/auth")
public String authenticate(@WebParam(name="AuthRequest") AuthRequest
request);   


AuthRequest:
public class AuthRequest extends GenericRequest{

final static long serialVersionUID = 1L;

public AuthRequest() {  
super();
}

public AuthRequest(Integer applicationId, String password, String 
login) {
super(applicationId, password, login);
}


And GenericRequest..
public class GenericRequest implements Serializable {

public GenericRequest(){

}


public GenericRequest(Integer applicationId, String password, String 
login)
{
super();
this.applicationId = applicationId;
this.password = password;
this.login = login;
}

private static final long serialVersionUID = 5037815176301473091L;

private Integer applicationId;

private String password;

private String login;
   
... and further setters and getters...


Wasn't this supposed to work?? 
I'm getting the following exception instead:

INFO: Interceptor has thrown exception, unwinding now
java.lang.NullPointerException
at
org.apache.cxf.binding.http.IriDecoderHelper.interopolateParams(IriDecoderHelper.java:306)
at
org.apache.cxf.binding.http.interceptor.URIParameterInInterceptor.mergeParams(URIParameterInInterceptor.java:122)
at
org.apache.cxf.binding.http.interceptor.URIParameterInInterceptor.handleMessage(URIParameterInInterceptor.java:103)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220)
at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:78)
at
org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:92)

(...)


Thanks in advance,
Rui Ramos


-- 
View this message in context: 
http://www.nabble.com/CXF-problem-using-extended-class-as-Web-Param-tp15721500p15721500.html
Sent from the cxf-user mailing list archive at Nabble.com.



Re: Servlet.service() for servlet CXFServlet exception

2008-02-19 Thread rm-ramos

Hi Sergey, and thanks again for your insights on the matter.

The fact is that is I launch my server from a main() method, using a
JAXRSServerFactoryBean as described on the cxf's user manual, everything
runs smoothly and I have no problem accessing the data from a web browser,
for ex.

Don't think the problem (back to JBoss) is the content-type either, been
doing some experiments with 'Poster' (the firefox extension) and the results
haven't been any different.

I couldn't find the sample you talked about,
BookServerResourceCreatedSpring. Can you please tell me where to find it?

Thanks again,
Rui Ramos



Hi

It seems to be a lower-level CXF issue, ChainInitiationObserver.java:93
shows this code in my snapshot :

exchange.put(Bus.class, bus);

which is harmlessPerhaps the fact that a content type is set to null
causes the problem.

Still it's likely that Endpoint which ChainInitiationObserver deals with has
not been set up properly...
Is there any chance you can try to run your server using a simple main(),
without JBoss involved ?

For ex, have a look at BookServerResourceCreatedSpring. It runs a server
using a /jaxrs_spring resource folder which has beans.xml, 
so just update it to refer to your web-app folder and try to get resources
from a browser. It will help narrow the problem.

Cheers, Sergey

-- 
View this message in context: 
http://www.nabble.com/JAX-RS-%22No-service-found%22-using-Spring-and-JBoss-tp15461660p15561555.html
Sent from the cxf-user mailing list archive at Nabble.com.



Re: Servlet.service() for servlet CXFServlet exception

2008-02-18 Thread rm-ramos

Hi,

Thanks for your reply Sergey. I managed to solve the problem, it actually 
was a JBoss config issue...

Now, however, I'm facing new problems deploying my JAX-RS based web service.
On accessing /services/, I already find it listed as it should be, but when
I try to call the service I get a 500 Server Error in return. From JBoss
logs, I found out the exception being raised:

INFO: URIParameterInterceptor handle message on path [/workorder/6] with
content-type [null]
15:53:15,008 ERROR [[CXFServlet]] Servlet.service() for servlet CXFServlet
threw exception
java.lang.NullPointerException
at
org.apache.cxf.transport.ChainInitiationObserver.setExchangeProperties(ChainInitiationObserver.java:93)
at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:59)
at
org.apache.cxf.transport.servlet.ServletDestination.doMessage(ServletDestination.java:79)
at
org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:256)
at
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:123)
at
org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:170)
at
org.apache.cxf.transport.servlet.AbstractCXFServlet.doGet(AbstractCXFServlet.java:152)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at
com.criticalsoftware.wow.presentation.CookieFilter.doFilter(CookieFilter.java:61)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
at
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at
org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at
org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)

Any thoughts on this one?
Thanks in advance,
Rui Ramos

-- 
View this message in context: 
http://www.nabble.com/JAX-RS-%22No-service-found%22-using-Spring-and-JBoss-tp15461660p15546908.html
Sent from the cxf-user mailing list archive at Nabble.com.



JAX-RS "No service found" using Spring and JBoss

2008-02-13 Thread rm-ramos

Hi guys,

I'm trying to move from HTTP-Binding RESTful services to the new Java
standard JAX-RS using CXF+Spring, deployed on JBoss.
However I can't seem to make it work due to a "No service found" problem.
I've been trying to get help from multiple sources, including CXF's IRC
channel, but unfortunately there's not so much written about this. I've
tried to base my config in the CXF docs as much as I could, but still no
luck.


So, moving on to the interesting part:

My web.xml contains the CXFServlet declaration, mapped on

CXFServlet
/services/*


On beans.xml: (not actually how we call it but..)

  

  

  

And on to the implementing class:
@UriTemplate("/rest/")
public class WorkOrderOperations {
(..)
@HttpMethod("GET")
@UriTemplate("/wo/{id}/")
public String getWorkOrder(@UriParam("id") String id){return "it works!
#"+id;}



So, and if I got it right, http://localhost/app-name/services/rest/wo/123
should output a string, but instead a not-so-nice "No service found" message
shows up. And i've tried almost every possible URI, can never find a
service. Is there anything else I'm missing?
I think the CXFServlet is mapped correctly, but I'm not so sure if the
service is being registered somewhere (or where..), so I would really thank
you if you could help me out on this one. 
It's been 3 days on this now :\

Thanks,
Rui Ramos

PS. I've already though on sticking with HTTP-Bindings ftm, since I'm
starting to lose hope on this one. What are your thoughts about implementing
a REST service using bindings vs. jaxrs, both present and future
implications?
-- 
View this message in context: 
http://www.nabble.com/JAX-RS-%22No-service-found%22-using-Spring-and-JBoss-tp15461660p15461660.html
Sent from the cxf-user mailing list archive at Nabble.com.



Can't route REST calls to methods using CXF2.0.3 and JBoss

2007-12-10 Thread rm-ramos

Hi all,

I'm trying to deploy a very simple REST Webservice, using two Get methods:

@WebService(name="GetWorkOrderServiceRest",
targetNamespace="http://webservice.api.wow";)
public class GetWorkOrderServiceRestImpl implements GetWorkOrderServiceRest
{

@Get
@HttpResource(location="/workorders")
public String getWorkorders() {
return "hello world!";
}

@Get
@HttpResource(location="/workorder/{id}")
public String getWorkorder(@WebParam(name = "id")long id) {
return "hello id:" + id;
}

..and though I *can* access the getWorkorders() method (via browser), I keep
getting the same error when I try to access, for instance, /workorder/123:
Invalid URL/Verb combination. Verb: GET Path: /workorder/123.

I've already tried to change the getWorkorder(id)'s HttpResource location to
/workorders/{id}, but that didn't work either as the first method, with no
arguments, was being called everytime I accessed the /workorders path.

Strange thing is I'm almost sure this was working, before I upgraded from
v2.0.0.
I would like to know if any of you guys understands what's going on. Am I
missing something here?!

Thanks in advance,
Rui Ramos


My remaining config files follow:

###
# applicationContext.xml
###
http://apache.org/cxf/binding/http";>
  

  

  



###
# beans.xml
###

CXFServlet
CXF Servlet

org.apache.cxf.transport.servlet.CXFServlet

1



CXFServlet
/webservice/*



###
# Interface (GetWorkOrderServiceRest)
###
@WebService
public interface GetWorkOrderServiceRest {

String getWorkorders();
String getWorkorder(long id);
void addWorkorder(String person);
void updateWorkorder(long id, String person);
void deleteWorkorder(long id);

}


###
# The exception I get on the server
###
INFO: Invoking GET on /workorder/453
11:49:48,768 ERROR [STDERR] 10/Dez/2007 11:49:48
org.apache.cxf.phase.PhaseInterceptorChain doInterc
ept
INFO: Interceptor has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Invalid URL/Verb combination. Verb: GET
Path: /workorder/453
at
org.apache.cxf.binding.http.interceptor.DispatchInterceptor.handleMessage(DispatchInterceptor.ja
va:74)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:207)
at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:73)
at
org.apache.cxf.transport.servlet.ServletDestination.doMessage(ServletDestination.java:79)
at
org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:256)
at
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:123)
at
org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:170)
at
org.apache.cxf.transport.servlet.AbstractCXFServlet.doGet(AbstractCXFServlet.java:152)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
(...)


-- 
View this message in context: 
http://www.nabble.com/Can%27t-route-REST-calls-to-methods-using-CXF2.0.3-and-JBoss-tp14251784p14251784.html
Sent from the cxf-user mailing list archive at Nabble.com.



Re: CXF2.0+JBoss namespace issue with custom objects

2007-12-04 Thread rm-ramos

Thank you both! 
I has in fact still using 2.0.0 and upgrading did the trick for me.

Thanks once again :)
Rui Ramos
-- 
View this message in context: 
http://www.nabble.com/CXF2.0%2BJBoss-namespace-issue-with-custom-objects-tf4942815.html#a14164218
Sent from the cxf-user mailing list archive at Nabble.com.



Re: CXF2.0+JBoss namespace issue with custom objects

2007-12-04 Thread rm-ramos

I forgot to leave you the generated WSDL, from java2wsdl. 

For convenience, I posted it online instead of pasting the full code here. 
You can access it here:
 -  http://student.dei.uc.pt/~rmramos/GetWorkOrderWebService.wsdl
http://student.dei.uc.pt/~rmramos/GetWorkOrderWebService.wsdl 

Thanks again,
Rui Ramos
-- 
View this message in context: 
http://www.nabble.com/CXF2.0%2BJBoss-namespace-issue-with-custom-objects-tf4942815.html#a14151295
Sent from the cxf-user mailing list archive at Nabble.com.



CXF2.0+JBoss namespace issue with custom objects

2007-12-04 Thread rm-ramos

Hi all,

I'm trying to enter this beautiful world of deploying  CXF WS in JBoss, but
I'm having some namespace issues with the XML I get as an answer, from the
WS. 

I created a code first service, with the following service endpoint
interface:


@WebService(name="GetWorkOrderService",
targetNamespace="http://webservice.api.wow/";)
public interface GetWorkOrderService {

@WebMethod
@WebResult(targetNamespace="", name = "simpleWODetails")
public simpleWODetails get(@WebParam(name = "workOrderId") Integer
workOrderId);


The 'get' method's impletation will then return a simpleWODetails' object,
which is only formed by pojo's. Of course, I have my impl annotated with:
@WebService(endpointInterface =
"com.criticalsoftware.wow.GetWorkOrderService")

On generating the WSDL, via java2wsdl, everything goes fine, but when I
tested the service on soapUI, the XML returned didn't validate. It went
something like:

#1 - Request


http://schemas.xmlsoap.org/soap/envelope/";
xmlns:web="http://webservice.api.wow/";>
   
   
  
 4054
  
 (...)


#2 - Response


http://schemas.xmlsoap.org/soap/envelope/";>
   
  http://webservice.api.wow/";>
 http://webservice.api.wow/";>
369
()


The validation outputs that 'Expected element 'simpleWODetails instead of
[EMAIL PROTECTED]://webservice.api.wow/', even though I already set up
the answer's targetNamespace to "" (in the SEI). The strange thing is that I
can change it to anything else (if I set the targetNamespace to "x.y.z", it
does change in the answer), but I just can't clear it.

As a result, all the calls I make with the stubs generated from the WSDL 
return null, since they can't find the object with the correct (empty)
namespace on the answer.

Hope you guys can help me out, been stuck on this for some days now...
Thanks!
Rui Ramos

-- 
View this message in context: 
http://www.nabble.com/CXF2.0%2BJBoss-namespace-issue-with-custom-objects-tf4942815.html#a14149710
Sent from the cxf-user mailing list archive at Nabble.com.