Reputation: 19
This problem is related to JAX-RS configuration.
I configured JAX-RS for a single class. The configuration worked fine.
@Path(/bean1/)
@Produces("application/xml")
public class class1 {
@POST
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.APPLICATION_XML)
@Path(/m1)
public String method1(JAXBElement<String> request) {
}
@POST
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.APPLICATION_XML)
@Path(/m2)
public String method2(JAXBElement<String> request) {
}
}
Below is jaxrs:server tag
<jaxrs:server id="bean1" address="/">
<jaxrs:serviceBeans>
<ref bean="class1" />
</jaxrs:serviceBeans>
<jaxrs:extensionMappings>
<entry key="xml" value="application/xml" />
</jaxrs:extensionMappings>
</jaxrs:server>
I could call through Apache Jersey client with URL "/bean1/m1"
Now, I wanted to configure another class with JAX-RS. Hence, I added configuration as below
@Path(/bean2/)
@Produces("application/xml")
public class class2 {
@POST
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.APPLICATION_XML)
@Path(/m3)
public String method3(JAXBElement<String> request) {
}
}
I added another jaxrs:server tag and specified address. The effective configuration is
<jaxrs:server id="bean1" address="/bean1">
<jaxrs:serviceBeans>
<ref bean="class1" />
</jaxrs:serviceBeans>
<jaxrs:extensionMappings>
<entry key="xml" value="application/xml" />
</jaxrs:extensionMappings>
</jaxrs:server>
<jaxrs:server id="bean2" address="/bean2">
<jaxrs:serviceBeans>
<ref bean="class2" />
</jaxrs:serviceBeans>
<jaxrs:extensionMappings>
<entry key="xml" value="application/xml" />
</jaxrs:extensionMappings>
</jaxrs:server>
I again tried to call web service with URL "/bean1/m1".
However, I received an error No root resource matching request path /m1 has been found.
Requesting help.
Upvotes: 1
Views: 8819
Reputation: 3146
Looking at your configuration you now have a mapping that maps to:
/bean1/bean1/m1
/bean2/bean2/m3
You probably want to do something like this:
<jaxrs:server id="server" address="/">
<jaxrs:serviceBeans>
<ref bean="class1" />
<ref bean="class2" />
</jaxrs:serviceBeans>
<jaxrs:extensionMappings>
<entry key="xml" value="application/xml" />
</jaxrs:extensionMappings>
</jaxrs:server>
You can just define 2 servicebeans for the same server if you want. That should give you what you want.
Upvotes: 8