faces-config strange configuration problem? - java

I have a seam project (you should not be blocked to answer just because it's seam, consider it beeing a jsf one) and all works great with jboss 5.1 until I add this to the faces-config.xml
<faces-config>
<validator>
<validator-id>passwordValidator</validator-id>
<validator-class>com.mydomain.seam_icefaces_test.action.PasswordValidator</validator-class>
</validator>
.....
</faces-config>
to configure a validator (I know I can use a seam validator but I just want to use a jsf one).
At this moment jboss continuously deploy and undeploy my app automatically - which is very strange of course...
Do you know why?

Is this happening when you deploy using a local server in Eclipse? I used to get this issue of constant deploying & undeploying - it was caused by an Eclipse versioning file in the deployment.
Every time you change a config file (like faces-config.xml) Eclipse creates a versioning file, to revert to if necessary. This screws up JBoss. Simply delete this file - it'll be called faces-config.xxxxx where xxxx is something other than xml.

Related

Deploy tomcat webapp with different web.xml

Is there a way of deploying a tomcat webapp with different web.xml (different name and context)?.
The problem:
I have a web.xml which i constantly have to modify (comment out and uncomment) stuff as i develop things - and this makes it a little annoying. Want i want to have is lets say two files:
web.xml
web-dev.xml
And I want my tomcat on my local machine to use web-dev.xml. Ofcouse for production release (i.e. Hosted server Tomcat will be using normal web.xml - web-dev.xml won't even be published). Its just for the development.
Any ideas where i can specify within tomcat to use web-dev.xml instead of web.xml ?
Thanks
Similarly to #HumbertoPinheiro, I think Maven profiles are a way to go.
Alternatively, this seems like a possible solution (Reference link : Specify a custom web.xml to an embedded tomcat):
Context webContext = tomcat.addWebapp("/yourContextPath", "/web/app/docroot/");
webContext.getServletContext().setAttribute(Globals.ALT_DD_ATTR, "/path/to/custom/web.xml");
Tested on Tomcat 7.0.42.

Preventing ViewExpiredException with JSF 2 after redeploy

I have a problem where every time I redeploy my app, any existing sessions are broken and the requests result in a ViewExpiredException. None of the advice in related questions or outside mailing list / forum posts seems to fix this issue. I can redeploy the same WAR file completely unchanged and the behavior is the same.
I'm using Apache MyFaces 2.2.0, Tomcat 7.0.56 and Primefaces 5.0.
The message of the exception is No saved view state could be found for the view identifier: with whatever page would be requested. Primefaces' menubar is used for navigation, which seems to be implemented as a <form> with POST requests. These messages occur both with those navigation options and other AJAX that uses POST.
I have tried:
Setting explicit org.apache.myfaces.SECRET and org.apache.myfaces.MAC_SECRET values, as seen in this document.
Both client and server values for the javax.faces.STATE_SAVING_METHOD parameter.
Ensuring all beans and their transitive fields are serializable. No serialization errors are reported in the logs.
Using a filter to add no-cache headers, e.g. as suggested in this answer.
Session persistence is not disabled, that is my context.xml has <Manager pathname="" /> commented out.
try with:
<Manager className="org.apache.catalina.session.PersistentManager" saveOnRestart="true"/>
It seems that losing sessions is a "feature" of Tomcat since at least version 6 and continuing to version 7 when deploying via WAR file. We have to copy an unpacked directory to avoid losing the sessions, because WAR changes cause an undeploy followed by a deploy, as opposed to a reload.
This bug report states:
There are ways to achieve an update to an application without dropping the sessions. The simplest is probably:
- deploy as an exploded directory rather than a WAR
- update the files
- touch web.xml to trigger a reload
The reason for the current behaviour is to prevent problems when WARs are updated in incompatible ways and anything other than a full undeploy followed by (essentially) a new deployment causes conflicts.
This is still the case in the current Tomcat 7.0 documentation:
Currently, application reloading (to pick up changes to the classes or web.xml file) is not supported when a web application is deployed directly from a WAR file. It only works when the web application is deployed from an unpacked directory.

How to configure CXF in TomEE

Is it possible to override settings in TomEE for the embedded CXF JaxRS container? I've been trying to integrate my own in-interceptor for handling rouing of JaxRS services.
What I can't seem to do is get TomEE to load the interceptor when starting my service.
I've read a bunch of stuff that says that I should be able to configure the CXF stuff in TomEE by adding <pojo-deployment> to an openejb-jar.xml file in either META-INF or WEB-INF. When I try using this approach, my interceptor never gets called.
I've also seen references that state that TomEE uses tomee.xml to replace openejb-jar.xml, so I tried to do the pojo-deployment stuff there, but then I get an XML parse error because tomee.xml doesn't seem to understand the pojo-deployment tag.
Can someone point me to some decent docs or better yet a small example of configuring CXF in TomEE?
Thanks
openejb-jar.xml is the way to do it
I blogged about it here http://rmannibucau.wordpress.com/2012/10/04/jax-rsjax-ws-configuration-for-tomee-1-5-0/
only change on recent tomee version is the fact you need to set as class-name the jaxrs application you use (if noone use "jaxrs-application" which means default behavior)
so something like:
<openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
<pojo-deployment class-name="jaxrs-application">
<properties>
cxf.jaxws.in-interceptors = org.superbiz.MyInInterceptor
</properties>
</pojo-deployment>
</openejb-jar>

How do you add a dependency to a JBoss EJB with a generated WebService?

I'm trying to deploy an EJB in JBoss that uses the #WebService annotation. However, the EJB has a dependency on an EJB in another ear. By adding the #Depends annotation, the EJB start is delayed until after the ear is loaded, but it appears the WebService generator is still trying to start up the generated WAR as soon as it sees the annotation.
Is there anything similar to #Depends for the generated JBossWS that I can add?
I think what you may need to do is configure the deployment order that JBoss is using. I know this is possible and I think it is what people I work with have done for dependencies like this. If this link doesn't help, you will want to search for something dealing with JBoss deployment order and how to set the order. I had JBoss training a while back and I know this is a solution that is taught.
JBoss Deployment Order

Does JBoss cache class files?

I'm wrestling with a strange problem: When I make a change to a POJO or Seam Component in my localhost JBoss instance, restart it, and load the page, the change is visible. However, on our server, running the same version of JBoss, when I stop the instance, delete the WAR file, upload the latest version, and restart JBoss, it won't show some of the new server-side functionality.
Specifically, the change is to a POJO class which implements javax.faces.validator.Validator class. It's then used in the XHTML Facelet like this:
<h:inputText value="#{outsideaccount.accountOrganizationEmail}" maxlength="50"
id="txtOrganizationSupportEmail"
validatorMessage="Organization Support Email is not valid. It must be in the pattern 'some_id#some_domain.com'.">
<f:validator validatorId="AnyEmailValidator"/>
</h:inputText>
I'm able to use the email validator on my localhost JBoss correctly; on the development server, it throws a validation error using the same email on the same page. Very strange. Is JBoss caching the class files somewhere? How do I clear everything out of the JBoss development server cache?
I'm using Win XP Pro locally; the development server is using JBoss 4.2.3.GA on JVM Version 1.5.0_16-b02, with Unix SunOS 5.10. Thanks.
JBoss has work and tmp directories that you can delete to make sure everything is clean. Things can get cached there, so you can clear them out on deploy if you are having problems. There is also a setting to force that to happen automatically on JBoss's end. If your problem is a cache clearing problem, this will help solve it.
Another possibility is that you have two copies of that war deployed on JBoss, although that should give you some errors when you deploy in production.

Categories