I have a screen which is implemented in JSF2 and I have validations on some of the fields, and when an error appears for a field that has no
<h:message for="fieldName" />
it always appear on the end of the screen with no style
I want to hide the messages summary even if I don't handle those validations
I guess they are just warnings that you see when your project stage is set to Development.
In web.xml file, change:
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
to:
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param>
and the messages disappear.
It is a feature of JSF 2 that shows you diagnostic messages when you are on Development stage. Actually you should changed that value in web.xml only when you want to put the project in production.
Related
We are currently migrating our application from WAS8 to WAS9. We use JSF 2.2 and Primefaces 4.0. In WAS8 application works fine.But in WAS9 we are getting the following error:
Uncaught service() exception root cause Faces Servlet: javax.servlet.ServletException: /pages/xyz.xhtml - No saved view state could be found for the view identifier: /pages/xyz.xhtml
Our web.xml looks like following :
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.COMPRESS_STATE_IN_CLIENT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>facelets.BUILD_BEFORE_RESTORE</param-name>
<param-value>true</param-value>
</context-param>
Tried changing STATE_SAVING_METHOD to client.But that is not working. Can anyone kindly help me in resolving this error. Thanks in advance.
I'd prefer to comment, but I do not have enough points.
It's hard to say what could be the causing this without more information.
Web.xml seems fine. Otherwise factors that can cause this error is session expiration or an problem with the cookies.
Another possibility is that javax.faces.ViewState may be corrupted?
My idea is that org_apache_myfaces_NUMBER_OF_VIEWS_IN_SESSION may need to be increased?
http://myfaces.apache.org/core20/myfaces-impl/webconfig.html#org_apache_myfaces_NUMBER_OF_VIEWS_IN_SESSION
But please read more about the viewexpiredexception below and I hope that may help you identity the problem.
javax.faces.application.ViewExpiredException: View could not be restored
I try to get the spring web application context from a filter.
I was previously getting it through:
WebApplicationContextUtils.getRequiredWebApplicationContext(request.getServletContext())
It was ok, because I was getting what is called I think the ROOT web application context.
Now, I wanted to move all my spring definition like that in web.xml :
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- Configure DispatcherServlet to use AnnotationConfigWebApplicationContext instead of default XmlWebApplicationContext. -->
<init-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
</init-param>
<!-- Custom web configuration annotated class. -->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>foo.bar.WebConfiguration</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
I removed the "old" definition from web.xml :
<!-- <context-param> -->
<!-- <param-name>contextConfigLocation</param-name> -->
<!-- <param-value>/WEB-INF/dispatcher-servlet.xml</param-value> -->
<!-- </context-param> -->
<!-- <listener> -->
<!-- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> -->
<!-- </listener> -->
Now, I have no more "ROOT" web application context, and the filter cannot get the another web application context.
I saw that there is another call :
WebApplicationContextUtils.getWebApplicationContext(sc, attrName)
it allows to specify as second argument the "attribute", it is in fact the web application context you want.By default, it is "org.springframework.web.context.WebApplicationContext.ROOT".
I think I have to call this method but I don't know what to put as second parameter.
PS : I also tried to use org.springframework.web.filter.DelegatingFilterProxy, but tomcat throwed the error that he dont find the classic (ROOT) web application context :
java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
BUT THERE IS ANOTHER CONTEXT, it is just defined in another way. It is not possible I am the only one trying to get another context that the ROOT.
Thanks to have read so far.
I just read your answer, and yes I figured it out yesterday night ;-)
I added the ROOT context, defining it like that:
<context-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>foo.bar.WebConfiguration</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
And its working, the filter can acces to the service directly with Autowiring.
I still have the feeling that my architecture is dirty because the ROOT and "dispatcher" context are the same, I think it's not a good practice.
Maybe I'll try later to split the "WebConfiguration" in two.
Thank you anyway!
Recently I added JavaMelody plugin to my site, but when I try to load in Firefox I got this message:
Content Encoding Error
The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression.
Please contact the website owners to inform them of this problem.
There is a lot of information about that like clean cookies and cache, change network.http.accept-encoding value to true, etc. but when I run the project in development with Groovy/Grails Tools Suite this error does not appear.
Because that I try different solutions and I found that there is not need to change Firefox properties. You need to follow the web.xml file setup but pay attention where you add this lines.
There are three elements: filter, filter-mapping and listener. You need to add each element in the first position in the relevant section, for example:
<web-app xmlns="http://java.sun.com/xml/ns/javaee" metadata-complete="true" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<display-name>/myweb</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>myweb</param-value>
</context-param>
<context-param>
<param-name>sample</param-name>
<param-value>Sample Value</param-value>
</context-param>
<!-- filter javamelody first -->
<filter>
<filter-name>monitoring</filter-name>
<filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
</filter>
<filter>
<!-- other filters -->
</filter>
<!-- filter-mapping javamelody first -->
<filter-mapping>
<filter-name>monitoring</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<!-- others filter-mappings -->
</filter-mapping>
<!-- listener javamelody first -->
<listener>
<listener-class>net.bull.javamelody.SessionListener</listener-class>
</listener>
<listener>
<!-- others listeners here -->
</listener>
<!-- others lines like servlets, etc -->
I have no more information but I think there is an order reading encoding in differents elements in this web.xml.
I hope it help, but feel free to add more information.
I use intelliJ Idea 10.5. when i use context-param for for spring context and run project Tomcat show me blank page!! when I disable it, page show!
<context-param>
<param-name>contextLocation</param-name>
<param-value>classpath:context/applicationContext-dao.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
You need to enable log4j and see the exception Spring is throwing when you start tomcat.. Also make sure that the context file is in the war file (on the location - WEB-INF/classes/context/applicationContext-dao.xml
Ian.
I'm useing Vaadin and BIRT reporting in my project.I have problem with accessing report with Vaadin,I think its related to my web.xml configuration.Can anyone help me to get out from this problem??
< /servlet-mapping>
<servlet-name>VaadinApplicationServlet</servlet-name>
<url-pattern>/VAADIN/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>VaadinApplicationServlet</servlet-name>
<url-pattern>/MyProject/*</url-pattern>
</servlet-mapping>
If i put url pattern like this.it shows index.jsp page as first page.
< /servlet-mapping>
<servlet-name>VaadinApplicationServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
If I configure the url pattern as "/*" it works fine and load the vaadin UI
but the problem is if I put 2nd configuration I can not load the report to browser,It always redirect to my current vaadin UI page (When I click the button to load the report)
If put first configuration I can access report directly ,But It does not load the vaadin UI.
Can any one help me to solve this problem??
Thank you.
Cheers
The first configuration should be ok, but you have to access your application differently:
Try
http://localhost:8080/[display-name]/MyProject
You should find the display-name right above the first context-param
<display-name>IamTheDisplayName</display-name>
<context-param>
<description>Vaadin production mode</description>
<param-name>productionMode</param-name>
<param-value>false</param-value>
</context-param>