[mule-user] Error posting to the web service

25 views
Skip to first unread message

Mohit Anchlia

unread,
Aug 24, 2011, 1:56:26 PM8/24/11
to us...@mule.codehaus.org
Not sure if I am missing something here.

----

curl -X POST -d @in.xml http://SDGL04R8gtby1t:8080/dpApi

mule throws:

ERROR [[app-client-api].connector.http.mule.default.receiver.2]:
********************************************************************************

Message : Failed to invoke JerseyResourcesComponent{dpApi.commpone
nt.8569405}. Component that caused exception is: JerseyResourcesComponent{dpApi.
commponent.8569405}. Message payload is of type: ContentLengthInputStream
Code : MULE_ERROR--2
--------------------------------------------------------------------------------

Exception stack is:
1. String index out of range: -1 (java.lang.StringIndexOutOfBoundsException)
java.lang.String:-1 (null)
2. Failed to invoke JerseyResourcesComponent{dpApi.commponent.8569405}. Componen
t that caused exception is: JerseyResourcesComponent{dpApi.commponent.8569405}.
Message payload is of type: ContentLengthInputStream (org.mule.component.Compone
ntException)
org.mule.component.AbstractComponent:142 (http://www.mulesoft.org/docs/site/cu
rrent3/apidocs/org/mule/component/ComponentException.html)
--------------------------------------------------------------------------------

Root Exception stack trace:
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(Unknown Source)
at java.lang.String.substring(Unknown Source)
at com.sun.jersey.spi.container.ContainerRequest.getEncodedPath(Containe
rRequest.java:365)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for ev
erything)
********************************************************************************


----

<flow name="dpApi">
<inbound-endpoint address="http://localhost:8080/dpApi" />
<jersey:resources>
<component class="com.intuit.cg.services.dp.pipeline.api.ApiResourceImpl" />
</jersey:resources>
<component class="com.intuit.cg.services.dp.pipeline.api.JerseyAdapter"
doc:name="Jersey Adapter" doc:description="Adapt Jersey Request to a
Mule Message "/>
<component
class="com.intuit.cg.services.dp.pipeline.api.XmlToApiMessage"
doc:name="Unmarshal XML" doc:description="Unmarshal the XML String to
a com.intuit.cg.services.dp.api.generated.Message implicitly via
JAXB"/>
<component
class="com.intuit.cg.services.dp.pipeline.api.RequestHandler"
doc:name="API Request Handler" doc:description=""/>
<async>
<jms:outbound-endpoint queue="log.queue"
exchange-pattern="one-way">
</jms:outbound-endpoint>
</async>
</flow>
<flow name="LogManager">
<jms:inbound-endpoint queue="log.queue">
</jms:inbound-endpoint>
<component class="com.intuit.cg.services.dp.pipeline.api.LogManager" />
</flow>


config is

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


David Dossot

unread,
Aug 24, 2011, 2:00:56 PM8/24/11
to us...@mule.codehaus.org
What's in @Path of ApiResourceImpl?

Mohit Anchlia

unread,
Aug 24, 2011, 2:12:54 PM8/24/11
to us...@mule.codehaus.org
On Wed, Aug 24, 2011 at 11:00 AM, David Dossot <da...@dossot.net> wrote:
> What's in @Path of ApiResourceImpl?

Thanks. I think I figured it out I was missing "/" at the end. Thanks.

But now I am getting, NullPayload even though I have data in.xml when using curl

Message : The transformer "JAXBUnmarshallerTransformer" does not s
upport source type "org.mule.transport.NullPayload". Endpoint is "null"
Code : MULE_ERROR-65054
--------------------------------------------------------------------------------

Exception stack is:
1. The transformer "JAXBUnmarshallerTransformer" does not support source type "o
rg.mule.transport.NullPayload". Endpoint is "null" (org.mule.api.transformer.Tra
nsformerException)
org.mule.transformer.AbstractTransformer:412 (http://www.mulesoft.org/docs/sit
e/current3/apidocs/org/mule/api/transformer/TransformerException.html)
--------------------------------------------------------------------------------

Root Exception stack trace:
org.mule.api.transformer.TransformerException: The transformer "JAXBUnmarshaller
Transformer" does not support source type "org.mule.transport.NullPayload". Endp
oint is "null"
at org.mule.transformer.AbstractTransformer.transform(AbstractTransforme
r.java:412)
at org.mule.DefaultMuleMessage.getPayload(DefaultMuleMessage.java:359)
at org.mule.DefaultMuleMessage.getPayload(DefaultMuleMessage.java:311)

David Dossot

unread,
Aug 24, 2011, 2:22:04 PM8/24/11
to us...@mule.codehaus.org
Not sure why this is happening nor where it is happening. Moreover, I don't understand the dpApi flow: what is the purpose of all these components after the Jersey resource? 

Mohit Anchlia

unread,
Aug 24, 2011, 2:36:56 PM8/24/11
to us...@mule.codehaus.org
First component just read string so it's:

!) @POST
@Path("/api")
@Consumes({ MediaType.APPLICATION_XML, "application/xml" })
@Produces({ MediaType.APPLICATION_XML, "application/xml" })
String processApiRequest(String m);

2) Component adds some more info as noted on the mule site:

public Object onCall(MuleEventContext muleEventContext) throws Exception {
String payload;
MuleMessage message = muleEventContext.getMessage();
ContainerResponse cr = (ContainerResponse)
message.getInvocationProperty("jersey_response");
String restMethod = cr.getContainerRequest().getMethod();
message.setOutboundProperty("restMethod", restMethod);
payload = (String) cr.getResponse().getEntity();
return payload;
}
3) Is supposed to do the JAXB parsing

public CreateResponse handle(CreateRequest req) {
CreateResponse resp = dh.handle(req);
return resp;

Mohit Anchlia

unread,
Aug 24, 2011, 2:39:38 PM8/24/11
to us...@mule.codehaus.org
This is what I see:

INFO [[app-client-api].connector.http.mule.default.receiver.2]: No common Objec
t of type 'class javax.xml.bind.JAXBContext' configured, creating a local one fo
r: SimpleDataType{type=org.mule.transport.NullPayload, mimeType='*/*'}, SimpleDa
taType{type=com.i.cg.services.dp.api.generated.Message, mimeType='*/*'}
No common Object of type 'class javax.xml.bind.JAXBContext' configured, creating
a local one for: SimpleDataType{type=org.mule.transport.NullPayload, mimeType='
*/*'}, SimpleDataType{type=com.intuit.cg.services.dp.api.generated.Message, mime
Type='*/*'}
ERROR [[app-client-api].connector.http.mule.default.receiver.2]:
********************************************************************************

I think I am missing some header. I'll look more

Mohit Anchlia

unread,
Aug 24, 2011, 2:52:59 PM8/24/11
to us...@mule.codehaus.org
I do have charset utf-8 set so not sure why it's complaining.

David Dossot

unread,
Aug 24, 2011, 3:09:27 PM8/24/11
to us...@mule.codehaus.org
I really don't get it :(

You have:

- com.intuit.cg.services.dp.pipeline.api.ApiResourceImpl that is a JAX-RS resource, correctly declared as a Jersey resource so Mule can route messages to it,
- com.intuit.cg.services.dp.pipeline.api.JerseyAdapter that looks like JAX-RS resource but is *not* declared as a Jersey resource! Moreover, being placed downstream in the flow it will consume result messages from com.intuit.cg.services.dp.pipeline.api.ApiResourceImpl: is it really what you want?
- then com.intuit.cg.services.dp.pipeline.api.XmlToApiMessage that extracts a String property from the inflight Mule message,
- this String value is passed to com.intuit.cg.services.dp.pipeline.api.RequestHandler that expects it to be unmarshalled to a CreateRequest object.
 
Are all this bits and pieces really necessary? What response do you expect to come back to the caller? What is the actual service component here? Why is the first one only handled by Jersey?

Lost...

Mohit Anchlia

unread,
Aug 24, 2011, 5:20:02 PM8/24/11
to us...@mule.codehaus.org
On Wed, Aug 24, 2011 at 12:09 PM, David Dossot <da...@dossot.net> wrote:
> I really don't get it :(
> You have:
> - com.intuit.cg.services.dp.pipeline.api.ApiResourceImpl that is a JAX-RS
> resource, correctly declared as a Jersey resource so Mule can route messages
> to it,
> - com.intuit.cg.services.dp.pipeline.api.JerseyAdapter that looks like
> JAX-RS resource but is *not* declared as a Jersey resource! Moreover, being
> placed downstream in the flow it will consume result messages
> from com.intuit.cg.services.dp.pipeline.api.ApiResourceImpl: is it really
> what you want?
> - then com.intuit.cg.services.dp.pipeline.api.XmlToApiMessage that extracts
> a String property from the inflight Mule message,
> - this String value is passed
> to com.intuit.cg.services.dp.pipeline.api.RequestHandler that expects it to
> be unmarshalled to a CreateRequest object.
>
> Are all this bits and pieces really necessary? What response do you expect
> to come back to the caller? What is the actual service component here? Why
> is the first one only handled by Jersey?
> Lost...

Those components are hooks for some xml manipulation as on the wire
content. But that shouldn't cause this issue since it's mostly passing
through the Message for now.

Are we missing something here or something wrong that's causing this
issue? From the below error it looks like it's some mimetype issue. I
can try and print message and see what I get.

INFO [[app-client-api].connector.http.mule.default.receiver.2]: No common Objec
t of type 'class javax.xml.bind.JAXBContext' configured, creating a local one fo
r: SimpleDataType{type=org.mule.transport.NullPayload, mimeType='*/*'}, SimpleDa
taType{type=com.i.cg.services.dp.api.generated.Message, mimeType='*/*'}
No common Object of type 'class javax.xml.bind.JAXBContext' configured, creating
a local one for: SimpleDataType{type=org.mule.transport.NullPayload, mimeType='
*/*'}, SimpleDataType{type=com.intuit.cg.services.dp.api.generated.Message, mime
Type='*/*'}

>

Mohit Anchlia

unread,
Aug 24, 2011, 5:29:21 PM8/24/11
to us...@mule.codehaus.org
more info

this is the link that says we need to modify jersey to add
"jersey_response" before forwarding the request.

http://www.mulesoft.org/documentation/display/MULE3USER/Jersey+Module+Reference

Mohit Anchlia

unread,
Aug 24, 2011, 7:21:59 PM8/24/11
to us...@mule.codehaus.org
It seems to work. I didn't have correct path in the uri
Reply all
Reply to author
Forward
0 new messages