Well, let me clarify something, which is what [1] was all about. If I
do this:
ServletAdapter sa = new ServletAdapter();
sa.setRootFolder(".");
the code belows runs fine, with the exception of the error I
reported. If I do this, however,
sa.setRootFolder("/Users/jasonlee/src/jsf2demo/target/jsf2demo");
I get a really odd exception:
javax.faces.FacesException: java.util.concurrent.ExecutionException:
java.lang.ClassCastException: java.io.File cannot be cast to
java.lang.String
at
com
.sun.faces.config.ConfigManager.getAnnotatedClasses(ConfigManager.java:
385)
at
com
.sun
.faces
.config
.processor
.AbstractConfigProcessor
.processAnnotations(AbstractConfigProcessor.java:304)
at
com
.sun
.faces
.config
.processor
.ApplicationConfigProcessor.process(ApplicationConfigProcessor.java:304)
at
com
.sun
.faces
.config
.processor
.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:114)
at
com
.sun
.faces
.config
.processor
.LifecycleConfigProcessor.process(LifecycleConfigProcessor.java:114)
at
com
.sun
.faces
.config
.processor
.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:114)
at
com
.sun
.faces
.config
.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:
207)
at
com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:311)
at
com
.sun
.faces
.config.ConfigureListener.contextInitialized(ConfigureListener.java:208)
at
com
.sun
.grizzly
.http.servlet.ServletContextImpl.initListeners(ServletContextImpl.java:
150)
at
com
.sun
.grizzly
.http.servlet.ServletAdapter.configureServletEnv(ServletAdapter.java:
322)
at
com.sun.grizzly.http.servlet.ServletAdapter.start(ServletAdapter.java:
198)
at
com.sun.grizzly.http.SelectorThread.initEndpoint(SelectorThread.java:
1084)
at
com.sun.grizzly.http.SelectorThread.listen(SelectorThread.java:1135)
at
com
.sun.grizzly.http.embed.GrizzlyWebServer.start(GrizzlyWebServer.java:
544)
at com.steeplesoft.grizzlyfaces.Main.main(Main.java:29)
Based on earlier errors, it seems the root folder is not on the
classpath, so code that looks for resources in /WEB-INF, for example,
fails. Am I misinterpreting things? If not, *can* the root folder be
added to the CP? I'm no ClassLoader expert, but I don't see any
methods that might allow something like that.
Or am I going about this all wrong. Has anyone gotten the
ServletAdapter to work with an exploded .war (JSF or not)? I'd love
to hear from you. :)
On Jan 28, 2009, at 3:46 PM, Jason Lee wrote:
> Hey, Jeanfracois. I got passed the original issue (the null
> InputStream). When Mojarra initializes, it tries to get context
> params from web.xml unless told not to. Since web.xml wasn't in the
> classpath[1], I told Mojarra not to search for it. Problem
> "solved." When I run my test app now, it starts up with no errors
> and starts taking requests. The problem I'm seeing now is that
> either I'm not setting up the servlet-mapping correctly, or it's not
> being honored. Here's my code:
>
> sa.setServletInstance(new FacesServlet());
>
> sa
> .addContextParameter
> (BooleanWebContextInitParameter
> .ForceLoadFacesConfigFiles.getQualifiedName(), "true");
> ws.addGrizzlyAdapter(sa, new String[] {"*.jsf"});
> ws.start();
>
> When I request, say, http://localhost:8080/index.jsf, I get this
> error:
>
> com.sun.grizzly.http.servlet.ServletAdapter service
> SEVERE: service exception:
> javax.servlet.ServletException: The FacesServlet cannot have a url-
> pattern of /*. Please define a different url-pattern.
> at javax.faces.webapp.FacesServlet.service(FacesServlet.java:
> 323)
> at
> com
> .sun
> .grizzly.http.servlet.FilterChainImpl.doFilter(FilterChainImpl.java:
> 174)
>
> Am I configuring my ServletAdapter/GrizzlyWebServer incorrectly, or
> is there a bug? Or something else. :)
>
> On Jan 23, 2009, at 12:04 PM, Jeanfrancois Arcand wrote:
>
>> Salut,
>>
>> Jason Lee wrote:
>>> I'm trying to follow the ServletAdapter example from the javadocs
>>> and not having much luck. Here's my code
>>> GrizzlyWebServer ws = new GrizzlyWebServer("/Users/jasonlee/
>>> Sites");
>>> try {
>>> ServletAdapter sa = new ServletAdapter();
>>> ConfigureListener cl = new ConfigureListener();
>>>
>>> sa.addServletListener("com.sun.faces.config.ConfigureListener");
>>> sa.setRootFolder("/Users/jasonlee/src/glassfish/test/
>>> glassfish/lib/install/applications/__admingui/");
>>> FacesServlet fs = new FacesServlet();
>>> sa.setServletInstance(fs);
>>> sa.setProperty("display-name", "Admin GUI");
>>> sa.setServletPath("*.jsf");
>>> sa.setContextPath("/");
>>> ws.addGrizzlyAdapter(sa);
>>> ws.start();
>>> } catch (Exception ex) {
>>> ex.printStackTrace();
>>> }
>>> }
>>
>> So far so good. Now you want to embed a JSF application, which is
>> something we never experimented. Fist, is the JSF application uses
>> the following:
>>
>> + RequestDispatcher/NameDispatcher
>> + Error page mechanism
>> + Authentication
>> + No JSP
>>
>> Grizzly Servlet Container is not yet compliant, being developed
>> mainly by the community.
>>
>>> and here's the stack trace I'm getting:
>>> Jan 23, 2009 11:09:57 AM com.sun.faces.config.ConfigureListener
>>> $WebXmlProcessor scanForFacesServlet
>>> WARNING: Unable to process deployment descriptor for context '/'
>>> java.lang.IllegalArgumentException: InputStream cannot be null
>>> at javax.xml.parsers.SAXParser.parse(SAXParser.java:194)
>>> at com.sun.faces.config.ConfigureListener
>>> $WebXmlProcessor.scanForFacesServlet(ConfigureListener.java:705)
>>> at com.sun.faces.config.ConfigureListener
>>> $WebXmlProcessor.<init>(ConfigureListener.java:676)
>>> at
>>> com
>>> .sun
>>> .faces
>>> .config
>>> .ConfigureListener.contextInitialized(ConfigureListener.java:164)
>>> at
>>> com
>>> .sun
>>> .grizzly
>>> .http
>>> .servlet.ServletContextImpl.initListeners(ServletContextImpl.java:
>>> 150)
>>> at
>>> com
>>> .sun
>>> .grizzly
>>> .http
>>> .servlet.ServletAdapter.configureServletEnv(ServletAdapter.java:322)
>>> at
>>> com
>>> .sun.grizzly.http.servlet.ServletAdapter.start(ServletAdapter.java:
>>> 198)
>>> at
>>> com
>>> .sun.grizzly.http.SelectorThread.initEndpoint(SelectorThread.java:
>>> 1084)
>>> at
>>> com.sun.grizzly.http.SelectorThread.listen(SelectorThread.java:1135)
>>> at
>>> com
>>> .sun
>>> .grizzly.http.embed.GrizzlyWebServer.start(GrizzlyWebServer.java:
>>> 544)
>>> at com.steeplesoft.grizzlyfaces.Main.main(Main.java:40)
>>> Jan 23, 2009 11:09:57 AM com.sun.faces.config.ConfigureListener
>>
>> Can you point me to the code that is doing that? I guess I can find
>> it in the JSF project....
>>
>>
>>> contextInitialized
>>> INFO: Initializing Mojarra 2.0.0 (SNAPSHOT 20090123) for context '/'
>>> Jan 23, 2009 11:09:58 AM
>>> com.sun.faces.spi.InjectionProviderFactory createInstance
>>> INFO: JSF1048: PostConstruct/PreDestroy annotations present.
>>> ManagedBeans methods marked with these annotations will have said
>>> annotations processed.
>>> Jan 23, 2009 11:09:58 AM com.sun.faces.config.ConfigManager
>>> initialize
>>> INFO: Unsanitized stacktrace from failed start...
>>> java.lang.ClassCastException: java.io.File cannot be cast to
>>> java.lang.String
>>> at com.sun.faces.application.resource.ResourceCache
>>> $WebappResourceMonitor.createSnapshot(ResourceCache.java:534)
>>
>> Same here.
>>
>>> at com.sun.faces.application.resource.ResourceCache
>>> $WebappResourceMonitor.createSnapshot(ResourceCache.java:520)
>>> at com.sun.faces.application.resource.ResourceCache
>>> $WebappResourceMonitor.<init>(ResourceCache.java:472)
>>> at
>>> com
>>> .sun
>>> .faces
>>> .application
>>> .resource.ResourceCache.initMonitors(ResourceCache.java:303)
>>> at
>>> com
>>> .sun
>>> .faces
>>> .application.resource.ResourceCache.<init>(ResourceCache.java:148)
>>> at
>>> com
>>> .sun
>>> .faces
>>> .application.ApplicationAssociate.<init>(ApplicationAssociate.java:
>>> 218)
>>> at
>>> com
>>> .sun.faces.application.ApplicationImpl.<init>(ApplicationImpl.java:
>>> 205)
>>> at
>>> com
>>> .sun
>>> .faces
>>> .application
>>> .ApplicationFactoryImpl.getApplication(ApplicationFactoryImpl.java:
>>> 107)
>>> at
>>> com
>>> .sun
>>> .faces
>>> .config
>>> .processor
>>> .AbstractConfigProcessor
>>> .getApplication(AbstractConfigProcessor.java:130)
>>> at
>>> com
>>> .sun
>>> .faces
>>> .config
>>> .processor
>>> .ApplicationConfigProcessor
>>> .process(ApplicationConfigProcessor.java:234)
>>> at
>>> com
>>> .sun
>>> .faces
>>> .config
>>> .processor
>>> .AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:
>>> 114)
>>> at
>>> com
>>> .sun
>>> .faces
>>> .config
>>> .processor
>>> .LifecycleConfigProcessor.process(LifecycleConfigProcessor.java:114)
>>> at
>>> com
>>> .sun
>>> .faces
>>> .config
>>> .processor
>>> .AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:
>>> 114)
>>> at
>>> com
>>> .sun
>>> .faces
>>> .config
>>> .processor
>>> .FactoryConfigProcessor.process(FactoryConfigProcessor.java:207)
>>> at
>>> com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:
>>> 311)
>>> at
>>> com
>>> .sun
>>> .faces
>>> .config
>>> .ConfigureListener.contextInitialized(ConfigureListener.java:207)
>>> at
>>> com
>>> .sun
>>> .grizzly
>>> .http
>>> .servlet.ServletContextImpl.initListeners(ServletContextImpl.java:
>>> 150)
>>> at
>>> com
>>> .sun
>>> .grizzly
>>> .http
>>> .servlet.ServletAdapter.configureServletEnv(ServletAdapter.java:322)
>>> at
>>> com
>>> .sun.grizzly.http.servlet.ServletAdapter.start(ServletAdapter.java:
>>> 198)
>>> at
>>> com
>>> .sun.grizzly.http.SelectorThread.initEndpoint(SelectorThread.java:
>>> 1084)
>>> at
>>> com.sun.grizzly.http.SelectorThread.listen(SelectorThread.java:1135)
>>> at
>>> com
>>> .sun
>>> .grizzly.http.embed.GrizzlyWebServer.start(GrizzlyWebServer.java:
>>> 544)
>>> at com.steeplesoft.grizzlyfaces.Main.main(Main.java:40)
>>> Jan 23, 2009 11:09:58 AM
>>> com.sun.grizzly.http.servlet.ServletContextImpl initListeners
>>> SEVERE: com.sun.faces.config.ConfigurationException: CONFIGURATION
>>> FAILED! java.io.File cannot be cast to java.lang.String
>>> at
>>> com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:
>>> 331)
>>> at
>>> com
>>> .sun
>>> .faces
>>> .config
>>> .ConfigureListener.contextInitialized(ConfigureListener.java:207)
>>> at
>>> com
>>> .sun
>>> .grizzly
>>> .http
>>> .servlet.ServletContextImpl.initListeners(ServletContextImpl.java:
>>> 150)
>>> at
>>> com
>>> .sun
>>> .grizzly
>>> .http
>>> .servlet.ServletAdapter.configureServletEnv(ServletAdapter.java:322)
>>> at
>>> com
>>> .sun.grizzly.http.servlet.ServletAdapter.start(ServletAdapter.java:
>>> 198)
>>> at
>>> com
>>> .sun.grizzly.http.SelectorThread.initEndpoint(SelectorThread.java:
>>> 1084)
>>> at
>>> com.sun.grizzly.http.SelectorThread.listen(SelectorThread.java:1135)
>>> at
>>> com
>>> .sun
>>> .grizzly.http.embed.GrizzlyWebServer.start(GrizzlyWebServer.java:
>>> 544)
>>> at com.steeplesoft.grizzlyfaces.Main.main(Main.java:40)
>>> Caused by: java.lang.ClassCastException: java.io.File cannot be
>>> cast to java.lang.String
>>> at com.sun.faces.application.resource.ResourceCache
>>> $WebappResourceMonitor.createSnapshot(ResourceCache.java:534)
>>> at com.sun.faces.application.resource.ResourceCache
>>> $WebappResourceMonitor.createSnapshot(ResourceCache.java:520)
>>> at com.sun.faces.application.resource.ResourceCache
>>> $WebappResourceMonitor.<init>(ResourceCache.java:472)
>>> at
>>> com
>>> .sun
>>> .faces
>>> .application
>>> .resource.ResourceCache.initMonitors(ResourceCache.java:303)
>>> at
>>> com
>>> .sun
>>> .faces
>>> .application.resource.ResourceCache.<init>(ResourceCache.java:148)
>>> at
>>> com
>>> .sun
>>> .faces
>>> .application.ApplicationAssociate.<init>(ApplicationAssociate.java:
>>> 218)
>>> at
>>> com
>>> .sun.faces.application.ApplicationImpl.<init>(ApplicationImpl.java:
>>> 205)
>>> at
>>> com
>>> .sun
>>> .faces
>>> .application
>>> .ApplicationFactoryImpl.getApplication(ApplicationFactoryImpl.java:
>>> 107)
>>> at
>>> com
>>> .sun
>>> .faces
>>> .config
>>> .processor
>>> .AbstractConfigProcessor
>>> .getApplication(AbstractConfigProcessor.java:130)
>>> at
>>> com
>>> .sun
>>> .faces
>>> .config
>>> .processor
>>> .ApplicationConfigProcessor
>>> .process(ApplicationConfigProcessor.java:234)
>>> at
>>> com
>>> .sun
>>> .faces
>>> .config
>>> .processor
>>> .AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:
>>> 114)
>>> at
>>> com
>>> .sun
>>> .faces
>>> .config
>>> .processor
>>> .LifecycleConfigProcessor.process(LifecycleConfigProcessor.java:114)
>>> at
>>> com
>>> .sun
>>> .faces
>>> .config
>>> .processor
>>> .AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:
>>> 114)
>>> at
>>> com
>>> .sun
>>> .faces
>>> .config
>>> .processor
>>> .FactoryConfigProcessor.process(FactoryConfigProcessor.java:207)
>>> at
>>> com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:
>>> 311)
>>> ... 8 more
>>> The paths on disk exist, but I'm making semi-educated guesses on
>>> the rest of the values. Any nudges in the right direction?
>>
>> I guess I need to see what JSF is trying to do. Can you file an
>> issue:
>>
>> https://grizzly.dev.java.net/issues/
>>
>> so we can work on it. BTW You want to run the admin gui on Grizzly?
>> This is great .... and scary as well :-)
>>
>> A+
>>
>> -- Jeanfrancois
>>
>>
>>
>>> <http://www.java.com> * Jason Lee *
>>> Senior Java Developer
>>> GlassFish Administration Console
>>> *Sun Microsystems, Inc.*
>>> Phone x31197/+1 405-343-1964
>>> Email jasondlee_at_sun.com <mailto:jasondlee_at_sun.com>
>>> Blog http://blogs.sun.com/jasondlee
>>> Blog http://blogs.steeplesoft.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>
>
> Jason Lee
> Senior Java Developer
> GlassFish Administration Console
>
> Sun Microsystems, Inc.
> Phone x31197/+1 405-343-1964
> Email jasondlee_at_sun.com
> Blog http://blogs.sun.com/jasondlee
> Blog http://blogs.steeplesoft.com
>
Jason Lee
Senior Java Developer
GlassFish Administration Console
Sun Microsystems, Inc.
Phone x31197/+1 405-343-1964
Email jasondlee_at_sun.com
Blog
http://blogs.sun.com/jasondlee
Blog
http://blogs.steeplesoft.com