users@jersey.java.net

Re: [Jersey] Viewable is not able to resolve jsp path when integrated with Guice

From: Dinesh Narayanan <ndchandar_at_gmail.com>
Date: Tue, 13 Oct 2009 16:17:49 -0700

Paul,
I was testing this in Jetty 6.1.19. I did not get any deployment error. I
got this error when I was accessing HelloWorldResource.
Thanks
Dinesh

On Tue, Oct 13, 2009 at 3:48 AM, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:

> Hi Dinesh,
>
> Are you using WebSphere? or Jetty?
>
> The following error is odd:
>
> ERROR: PWC6117: File
>> "/Users/ndchandar/IdeaProjects/GuicyMyBrocade/MiniMyBrocadeWeb/src/main/webapp/helloworld"
>> not found
>>
>
>
> Was there a deployment error?
>
> Note that i have not actually tried using the Guice integration with JSP
> support.
>
> Paul.
>
>
> On Oct 12, 2009, at 11:15 AM, Dinesh Narayanan wrote:
>
> Hello,
>> When I integrate Guice with JAX-RS, Viewable is not able to resolve my jsp
>> path. I get a 404 error (Problem accessing
>> /MiniMyBrocadeWeb/myAccount/helloWorld.jsp.)
>>
>> I did my integration based on the following email thread (
>> http://n2.nabble.com/WebPageContentRegex-and-Guice-integration-td3615214.html
>> )
>>
>> Example:
>> -------------
>> A) My HelloWorldResource:
>>
>> @Path("/helloworld")
>> @RequestScoped
>> public class HelloWorldResource {
>> private static final Logger logger =
>> Logger.getLogger(HelloWorldResource.class);
>>
>> @Context
>> private UriInfo uriInfo;
>>
>> private String name;
>> private int no;
>>
>> public String getName() {
>> return name;
>> }
>>
>> public void setName(String name) {
>> this.name = name;
>> }
>>
>> public int getNo() {
>> return no;
>> }
>>
>> public void setNo(int no) {
>> this.no = no;
>> }
>>
>> @GET
>> @Produces("text/html")
>> public Viewable get() {
>> logger.info("inside HelloWorldResource get()");
>> logger.info("uri info "+uriInfo);
>> logger.info("abs path "+uriInfo.getAbsolutePath());
>> logger.info("baseUri "+uriInfo.getBaseUri());
>> logger.info("getPath "+uriInfo.getPath());
>>
>> this.name = "Dinesh";
>> this.no = 007;
>>
>> return new Viewable("/myAccount/helloWorld.jsp", this);
>>
>> }
>> }
>>
>> B) MyGuiceServletConfig:
>>
>> public class MyGuiceServletConfig extends GuiceServletContextListener {
>>
>> private static final Logger logger =
>> Logger.getLogger(MyGuiceServletConfig.class);
>>
>> @Override
>> protected Injector getInjector() {
>>
>> final ServletModule servletModule = new ServletModule() {
>> @Override
>> protected void configureServlets() {
>> logger.info("inside configureServlets method");
>>
>> //bind resources
>> bind(HelloWorldResource.class);
>>
>> // this serves the static content
>> //
>> serveRegex("/(dojo|dijit|dojox|util|js)/.*").with(DefaultWrapperServlet.class);
>>
>> Map<String, String> params = new HashMap<String, String>();
>> params.put("com.sun.jersey.config.feature.Redirect",
>> "true");
>>
>> params.put("com.sun.jersey.config.feature.ImplicitViewables", "true");
>> params.put("com.sun.jersey.config.property.packages",
>>
>> "com.brocade.webportal.common;com.brocade.webportal.myAccount.resource;com.brocade.webportal.myHome.resource");
>>
>> //
>> params.put("com.sun.jersey.config.property.WebPageContentRegex",
>> "/(dojo|dijit|dojox|util|js)/.*");
>>
>> serve("/*").with(GuiceContainer.class, params);
>> }
>> };
>>
>> return Guice.createInjector(servletModule);
>> }
>>
>> }
>>
>> C) web.xml
>> <?xml version="1.0" encoding="UTF-8"?>
>> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="
>> http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
>> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
>> http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
>> id="WebApp_ID" version="2.5">
>>
>> <display-name>MyBrocade</display-name>
>>
>> <listener>
>>
>> <listener-class>com.brocade.webportal.config.MyGuiceServletConfig</listener-class>
>> </listener>
>>
>> <filter>
>> <filter-name>guiceFilter</filter-name>
>> <filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
>> </filter>
>>
>> <filter-mapping>
>> <filter-name>guiceFilter</filter-name>
>> <url-pattern>/*</url-pattern>
>> </filter-mapping>
>>
>> </web-app>
>>
>> The logs indicate the following error
>> ERROR: PWC6117: File
>> "/Users/ndchandar/IdeaProjects/GuicyMyBrocade/MiniMyBrocadeWeb/src/main/webapp/helloworld"
>> not found
>>
>> What was I missing here?
>>
>> Thanks
>> Dinesh
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>