Quantcast
Viewing all articles
Browse latest Browse all 5648

JAXB exception when using @Context to inject UriInfo

When I deploy a CXF JAX-RS application that uses the @Context annotation to inject a UriInfo object into a parameter of a method, the following error occurs:

Caused By: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
javax.ws.rs.core.UriInfo is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at javax.ws.rs.core.UriInfo

I have tried following two versions for jaxb jars (i.e., 'api', 'core', 'impl', 'runtime', and 'xjc') with the ear deployment:

1. The version 2.2.7 distributed with CXF version 3.0.0 release

2. The latest version 2.2.10-b140310.1920 for core, impl, runtime, xjc, and version 2.2.10 for api

The ear deployment is deployed to WebLogic server version 10.3.6.0, with the filtering classloading below:

<prefer-application-packages>
<package-name>org.apache.*</package-name>
<package-name>com.ctc.wstx.*</package-name>
<package-name>com.sun.xml.bind.*</package-name>
<package-name>javax.xml.bind.*</package-name>
</prefer-application-packages>

There is no examples of using @Context in the CXF JAX-RS samples (i.e., in ${CXF-Release}/samples/jax_rs directory). Although the CXF document has the example below (http://cxf.apache.org/docs/jax-rs-basics.html):

@Path("/customers")
public class CustomerService {

@GET
public Customers getCustomers(@Context UriInfo ui) {
......
// builder starts with current URI and has the path of the getCustomer method appended to it
UriBuilder ub = ui.getAbsolutePathBuilder().path(this.getClass(), "getCustomer");
for (Customer customer: customers) {
// builder has {id} variable that must be filled in for each customer
URI uri = ub.build(customer.getId());
c.setUrl(uri);

return customers;

@GET
@Path("/{id}")
public Customer getCustomer(@PathParam("id") String id) {
......

Are there any special configurations to make the inject work?

Thanks,
Lee Yang

________________________________

The information contained in this message and any accompanying attachments may contain privileged, private and/or confidential information protected by state and federal law. Penalties may be assessed for unauthorized use and/or disclosure. This message and any attachments are intended for the designated recipient only. If you have received this information in error, please notify the sender immediately and return or destroy the information.

This e-mail transmission and any attachments are believed to have been sent free of any virus or other defect that might affect any computer system into which it is received and opened. It is, however, the recipient's responsibility to ensure that the e-mail transmission and any attachments are virus free, and the sender accepts no responsibility for any damage that may in any way arise from their use.

Viewing all articles
Browse latest Browse all 5648

Trending Articles