Saturday, February 27, 2010

Glassfish v3 - what's the deal to have Weld and REST?

<UPDATE>

It turns out I did the right thing, but obviously needed a few more mvn clean install cycles (or in other words I have no obvious clue why this consistently failed at the start

</UPDATE>

---------------

So I've been trying to write an app that uses CDI (Weld) and JAX-RS.
As I want separate layers, I coded everything up to have a web.war, an ejb.jar and packaged everything together in an ear-file.

I've coded a bean like this:

@Stateless
@Path("/xx")
@Produces({MediaType.TEXT_PLAIN})
@Named
public class StatusManager {

public String foo() {
...
}
}


Now I can use it in a JSF like

 <h:commandButton value="Submit!" action="#{statusManager.foo}"/>

Works like a charm.

When I try to accces the REST endpoint I get a "resource not found". Ok,
so I add some stuff to web.xml:

    <servlet>
<servlet-name>ServletAdaptor</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ServletAdaptor</servlet-name>
<url-pattern>/xxx/*</url-pattern>
</servlet-mapping>


Now accessing the JAX-RS endpoint works like a charm, but the above JSF action breaks and the container shows the following in the logs:

com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.


Does anyone know what is going on and how to use both at a time?

1 comment:

  1. Consider posting your question to users@jersey.dev.java.net ?

    -Arun

    ReplyDelete