users@jersey.java.net

strange Viewable path resolving problem

From: <FSauer_at_dsthealthsolutions.com>
Date: Wed, 11 Nov 2009 16:52:25 -0600

When I run jersey 1.1.2-ea in JBoss 4.2.1 - deployed from an ear - I am
running into a weird issue:

my resource class has this code:

        @GET
        @Produces(MediaType.TEXT_HTML)
        public Viewable getUI() {
                return new Viewable("index", this);
        }

and stepping through jersey it he debugger I can see that this correctly
resolves to a full path:

TemplateFactory.resolveRelativeViewable line 133:

            for (TemplateProcessor t : getTemplateProcessors()) {
                String resolvedPath = t.resolve(absolutePath);
                if (resolvedPath != null) {
133 >>> return new ResolvedViewable(t, resolvedPath,
v.getModel(), c);
                }
            }

returns with the correct absolute path
/com/dsths/pmab/resources/settings/GlobalSettings/index.jsp

so far so good... Now we get to JSPTemplateProcessor creating a
RequestDispatcherWrapper and in there :

    public void forward(ServletRequest req, ServletResponse rsp) throws
ServletException, IOException {
        ResolvedViewable rv = (ResolvedViewable)hc.getProperties().get(
"com.sun.jersey.spi.template.ResolvedViewable");

        req.setAttribute("httpContext", hc);
        req.setAttribute("resolvingClass", rv.getResolvingClass());
        req.setAttribute("it", it);
        req.setAttribute("_basePath", basePath);
        req.setAttribute("_request", req);
        req.setAttribute("_response", rsp);
>>> d.forward(req,rsp);
    }

it is handed over to catalina. However, by now the requestURI in d (an
org.apache.catalina.core.ApplicationDispatcher) is:

/PMABServiceWeb/com/dsths/pmab/resources/settings/GlobalSettings/index.jsp

the first part being the contex root set in the application.xml of the
EAR:

  <module>
    <web>
      <web-uri>PMABServiceWeb.war</web-uri>
      <context-root>PMABServiceWeb</context-root>
    </web>
  </module>

basePath is an empty string and so is d.servletPath

and the result is a 404 without any indication of a problem like a stack
trace..........

 when I insert that directory (PMABServiceWeb) the Viewable does not
resolve correctly and I never get this far...

How do I make jersey work in an ear? All of this works fine in another app
I used to work on that deployed straight to tomcat in a war - no ears....


Any suggestions?

Thanks,

Frank Sauer


-----------------------------------------
Please consider the environment before printing this email and any
attachments.

This e-mail and any attachments are intended only for the
individual or company to which it is addressed and may contain
information which is privileged, confidential and prohibited from
disclosure or unauthorized use under applicable law. If you are
not the intended recipient of this e-mail, you are hereby notified
that any use, dissemination, or copying of this e-mail or the
information contained in this e-mail is strictly prohibited by the
sender. If you have received this transmission in error, please
return the material received to the sender and delete all copies
from your system.