my dog learned polymorphism*
The moose likes JSF and the fly likes problems with faces (myfaces and mojarr 2.1.7) and grails 2.03 incompatibility - need some assistanc Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "problems with faces (myfaces and mojarr 2.1.7) and grails 2.03 incompatibility - need some assistanc" Watch "problems with faces (myfaces and mojarr 2.1.7) and grails 2.03 incompatibility - need some assistanc" New topic
Author

problems with faces (myfaces and mojarr 2.1.7) and grails 2.03 incompatibility - need some assistanc

william Woodman
Greenhorn

Joined: Apr 23, 2012
Posts: 12
been a closet grails developer and i was trying to have a crack with primefaces and JSF through grails (on STS 2.9.1/Grails 2.0.3)

had a TON of problems

1. JSF2 plugin deosnt work under grails 2 and hasnt been touched for 2 years now.- gave up on this idea
2. Tried deconstructing JSF2 but didnt get very far - stopped
3. decided to have a go rolling my own plugin using spring faces and weblow (grails is essentially spring under the covers) and webflow has a primefaces demo you can get.

I tried the standalone spring webflow/faces - maven example and it seemend to work (no grails)

then tried to do a very simple plugin and i'm having no end of difficulties. essentially my plugin works if a i generate plugin as a as a war and deploy on tomcat outside of STS - but when i run in STS in embedded tomcat mode it just wont work

i get a couple of variations of related errors along the lines

view plaincopy to clipboardprint?

| Error 2012-04-23 18:09:50,165 [pool-6-thread-1] ERROR [localhost].[/aflowMyfacesPlugin] - StandardWrapper.Throwable
java.lang.IllegalStateException: No Factories configured for this Application. This happens if the faces-initialization does not work at all - make sure that you properly include all configuration settings necessary for a basic faces application and that all the necessary libs are included. Also check the logging output of your web application and your container for any exceptions!
If you did that and find nothing, the mistake might be due to the fact that you use some special web-containers which do not support registering context-listeners via TLD files and a context listener is not setup in your web.xml.
A typical config looks like this;
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
at javax.faces.FactoryFinder._getFactory(FactoryFinder.java:286)
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:206)
at javax.faces.webapp.FacesServlet.init(FacesServlet.java:116)
at org.apache.myfaces.webapp.MyFacesServlet.init(MyFacesServlet.java:100)
at com.softwood.web.WillsMyfacesServlet.init(WillsMyfacesServlet.groovy)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5015)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5302)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)



how did i get here -

1. i edited BuildConfig to get the v3 headers and add my dependencies like so



this adds the jars to the ivy cache for me

Then in a grails project you dont get a web.xml - grails generates one on the fly somehow - but you can interact with it, so step 2

2. in the plugin descriptor doWithWeb descriptor i add the spring weblow dispatcher servlet and the faces servlet

heres my helper class - called from the closure


in order so i could see if i can get to the code and have a look - this versions has my own extending wrapper on the apache servlet config listener and the faces servlet. I was looking at a another issue posted stack overflow topic. So i modified the gen to add the default javax.faces.webapp.FacesServlet, as well as my extension which extends the MyfacesServlet which implements DelagatingServlet. (this all makes no difference - it fails in weheter i just have the standard faces servlet or both like this - in embedded tomcat mode)

the generated web.xml from my closure looks like this - so this is grails and my additions


i had a quick rummage in the doWithAplicationContext closure - just to get some variables printed - ths is what i dumped out the log. i can read the applicationContext bean file as its in the WEB-INF directory as you can see - but theres no web.xml file its all handled on the fly by grails



i try and serve my default index .gsp and my page is served - so far so good

if i access the /app/home to get the facelets rendered page (simple hello page using the layour i cust and paste from the spring webflow /primefaces example)


then i get my error




I dont know what all that factory stuff is but i cant thie to work in embedded tomcat dev mode - this only happens in embedded mode.

if i try a run-war on the plugin - it says generates the war in /target/<pluginname>.war - but i cant connect to the server at all

lastly - if i deploy that war outside of STS into tomcat v7 using tomcat admin - it works fine, get a note about myfaces already being initialised at the end of the log in the cmd window linke this [code=java]
....
s
WARNING:

*******************************************************************
*** WARNING: Apache MyFaces-2 is running in DEVELOPMENT mode. ***
*** ^^^^^^^^^^^ ***
*** Do NOT deploy to your live server(s) without changing this. ***
*** See Application#getProjectStage() for more information. ***
*******************************************************************

24-Apr-2012 11:25:42 org.apache.myfaces.webapp.StartupServletContextListener con
textInitialized
INFO: MyFaces already initialized
wills my faces : starting faces servlet
24-Apr-2012 11:25:42 org.apache.myfaces.webapp.MyFacesServlet init
INFO: MyFacesServlet for context 'C:\Users\802518659\apache-tomcat-7.0.26\webapp
s\aflowMyfacesPlugin\' initialized.
[code]

i'm really stumped - i want to use STS in dev mode - its the natural way to work - but this failure to init faces is critical really and i dont know where to go next . had this on the grails forum but no response to all my threads on this

anyone here know what this Faces factory set of issues is really trying to tell me ??

yours in desperation
william Woodman
Greenhorn

Joined: Apr 23, 2012
Posts: 12
still struggling - heres were i have got to

1. works fina if i do a grails WAR and manually load into external tomcat
2. fails with errors when accessing the same facelet page in embedded tomcat dev mode

if you look at the error its from spring mvc calling into faces to do a Lifecycle factory lookup

with root cause
java.lang.IllegalStateException: No Factories configured for this Application. This happens if the faces-initialization does not work at all - make sure that you properly include all configuration settings necessary for a basic faces application and that all the necessary libs are included. Also check the logging output of your web application and your container for any exceptions!
If you did that and find nothing, the mistake might be due to the fact that you use some special web-containers which do not support registering context-listeners via TLD files and a context listener is not setup in your web.xml.
A typical config looks like this;
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
at javax.faces.FactoryFinder._getFactory(FactoryFinder.java:286)
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:206)
at org.springframework.faces.mvc.JsfView.createFacesLifecycle(JsfView.java:108)
at org.springframework.faces.mvc.JsfView.afterPropertiesSet(JsfView.java:53)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:386)
at org.springframework.web.servlet.view.UrlBasedViewResolver.applyLifecycleMethods(UrlBasedViewResolver.java:442)
at org.springframework.web.servlet.view.UrlBasedViewResolver.loadView(UrlBasedViewResolver.java:437)
at org.springframework.web.servlet.view.AbstractCachingViewResolver.createView(AbstractCachingViewResolver.java:186)
at org.springframework.web.servlet.view.UrlBasedViewResolver.createView(UrlBasedViewResolver.java:401)
at org.springframework.web.servlet.view.AbstractCachingViewResolver.resolveViewName(AbstractCachingViewResolver.java:103)
at org.springframework.web.servlet.DispatcherServlet.resolveViewName(DispatcherServlet.java:1211)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1160)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:950)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)


so heres what i tried to do

i have written some extension classes in plugin project that extend the myfaces classes - just so i could see whether my code was getting called

- i've add a WillsMyfacesServlet, WillsStartupServletContextListener and WillsJsfLifecycleFactoryImpl

for the latter i added a line in my faces-config to register the WillsJsfLifecycleFactoryImpl like this

<lifecycle-factory>
com.softwood.web.WillsJsfLifecycleFactoryImpl
</lifecycle-factory>


my StartupContextListner is registered in the web.xml in the plugin doWithWebDescriptor closure

listeners + {
listener {
'listener-class'('com.softwood.web.WillsStartupServletContextListener')
}
}



i can see my debug code printing on startup like this



however when i try and access my facelet at /app/home, i only get this. this first part is my trace print from my servletContextListener.requestInitialised (not sure if it should look liek these values at this time or not)


the the code fails - but it doesnt this time seem to go through my WillsJsfLifecycleFactoryImpl - as i see no debug from my getLifecycle method


[code=java]
request initialised notified to listener
> got content type null
> got dispatcher type REQUEST
> got local name 0.0.0.0
> got char encoding null
> got content length -1
| Error 2012-04-25 11:33:05,901 [http-bio-8080-exec-6] ERROR [/aflowMyfacesPlugin].[springmvc] - Servlet.service() for servlet [springmvc] in context with path [/aflowMyfacesPlugin] threw exception [Request processing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '/home': Invocation of init method failed; nested exception is java.lang.IllegalStateException: No Factories configured for this Application. This happens if the faces-initialization does not work at all - make sure that you properly include all configuration settings necessary for a basic faces application and that all the necessary libs are included. Also check the logging output of your web application and your container for any exceptions!
If you did that and find nothing, the mistake might be due to the fact that you use some special web-containers which do not support registering context-listeners via TLD files and a context listener is not setup in your web.xml.
A typical config looks like this;
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
] with root cause
java.lang.IllegalStateException: No Factories configured for this Application. This happens if the faces-initialization does not work at all - make sure that you properly include all configuration settings necessary for a basic faces application and that all the necessary libs are included. Also check the logging output of your web application and your container for any exceptions!
If you did that and find nothing, the mistake might be due to the fact that you use some special web-containers which do not support registering context-listeners via TLD files and a context listener is not setup in your web.xml.
A typical config looks like this;
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
at javax.faces.FactoryFinder._getFactory(FactoryFinder.java:286)
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:206)
at org.springframework.faces.mvc.JsfView.createFacesLifecycle(JsfView.java:108)
at org.springframework.faces.mvc.JsfView.afterPropertiesSet(JsfView.java:53)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:386)
at org.springframework.web.servlet.view.UrlBasedViewResolver.applyLifecycleMethods(UrlBasedViewResolver.java:442)
at org.springframework.web.servlet.view.UrlBasedViewResolver.loadView(UrlBasedViewResolver.java:437)
at org.springframewor
[code]

that kinda implies to me that there must be another thread in spring somewhere ? which hasnt loaded my class from the faces-config - and is trying to do a lookup using the apches classes and fails for some reason.

kind of seriously lost here - would really appreciate any ones help to try and sort of why it fails in embedded mode and then request a fix from someone (spring?) to fix it

Will
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problems with faces (myfaces and mojarr 2.1.7) and grails 2.03 incompatibility - need some assistanc
 
Similar Threads
Deployment Exception
javax.faces.application.ViewExpiredException
new to forum need some help with Myfaces(and mjorra) and grails 2.03
NullPointerException in AutoScrollPhaseListener
richfaces and problems with navigation