JBoss WAR Deployment problem (caching problems?) - java

I'm trying to deploy my war file on JBoss 4.2.3. This application was working fine and still is working fine (sans the bugfix that I've put into my code). I have made a new war file with a bug fix in it (which involves passing some extra http request params while requesting another app's servlet). However, when I tried to deploy this seemingly innocuous war file, I see the console logs from Jboss that say the new war file has been deployed etc. However, I don't see my changes reflecting in the browser (i.e, the extra params are not being sent in the request). I've verified that the war file that has gone into /server/default/deploy is exactly the same (cksum's are the same). I tried these few usual tricks to no avail: deleted the old war file from server before deploying the new one, restarted the server to free any cached stuff. Even put a return in my servlet at entry point. But still no difference! The servlet works just like before without the fix. Any suggestions?
I request you to kindly help me. I kinda screwed if this doesn't work.

A couple of thoughts
maybe your browser is 'offline' or using the cache, try clearing the cache / refresh
delete the contents under the server/default/tmp and server/default/work folders also

You could try adding some logging statements to your application, and see if they're output when you redeploy the war...
If it is definitely being redeployed then perhaps, as skaffman says, the fix didn't work.

Related

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.

Apache Tomcat - Access Files Outside Webroot

I had deployed an application in the application server Apache
Tomcat. My GWT application needs to access files in folder "C:
\Storage". In development mode the application runs like a charm but
in an external web server (Apache Tomcat) it does not run, crashes
when it tries to copy files from "C:\Storage" to "\docs". I think this
might be because i'm trying to access files outside the webroot. How
can i solve this situation? Using apache commons libs to deal with
files? Could be permissions? I need some enlightment, some help will
be very apreciated.
Thanks in advance,
João Cavaleiro.
Another (wild) guess: if you deploy wars without unpacking as real files, getRealPath("/doc") will return null. (You have no files inside a war). So you have to configure Tomcat:
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html
upackWAR = true
Thanks you all for the replies. I actually figured out what the problem was: Paths.
"\docs" is the folder located in the root of the app.
Unfortunately Apache didn't wrote any exception on catalina.out log (the code catch the exceptions ocurred).
Simply i didn't create a new File(pathname) with the absolute path of the destination location, i was using only the "docs/filename.txt" assuming that the File classe would recognize the full path, "knowing" the location in the filesystem of the app. I assume that this is a situation to keep in mind with sepecific application servers because with eclipse/Jetty it works but with Apache Tomcat don't (I am developing a GWT application).
But in the matteer of fact, the debbug was not easy, the debbug mode with external server didn't work in the server side in the peace of code where i it's needed to do this io operations strange), and the System.out.println that i managed to help me figure out the problem didn't show up in the catalina.stdout (strange to and yes, i have compiled and deployed it on the Apache Tomcat with that modifications twice).
Thanks to everyone.

Tomcat Deploying 2 Projects

I have a requirement that I need to use a single server machine to run 2 totally different applications.
The server machine has Apache Tomcat 6.0 installed. 1 of the applications is deployed on it and is running successfully for a long time. Initially, the clients used to connect to it by invoking the url "http://machine-name/1stProjectName/initialPage". I have also mentioned the "initialPage" as the Welcome Page in web.xml of this project. But somehow, later some ports or relating things were changed by the server maintenance team, and to connect to the application, now one has to use the url "http://machine-name" or "http://machine-name/initialPage", i.e. the machine name has started behaving like the project name folder because now if I invoke the url "http://machine-name/1stProjectName/initialPage", it gives 404 error saying that "/1stProjectName/1stProjectName/initialPage" resource not available.
Now, when I deploy the WAR of the second application into the webapps folder of Tomcat (just like I did for the first application), it unpacks it properly. But, the issue is how do I connect to this second project. If I use "http://machine-name", it takes me to the 1st application and if I use "http://machine-name/2ndProjectName/initialPage", it gives me an error that "/1stProjectName/2ndProjectName/initialPage" not available.
Kindly help or guide me in some direction.
Thanks in advance.
Your URLs should look like this if you did things properly:
Project 1: http://host:port/war-name-1
Project 2: http://host:port/war-name-2
That means no changes to content.xml to modify the path.
I would talk to your "server maintenance team" and let them know what you are trying to do (since they are the ones who made these changes in the first place). But it sounds to me that they just mapped a path to a specific location, that is your machine-name root is mapped to 1stProjectName.

Deploying an identical war file with a different name causes the old one to stop?

We have an Apache tomcat server that runs a current web service. We were trying to deploy a second version (with a few tweaks) however when we copy the war file over, the first one stops working. Why??
Does your webapp contain context.xml configuration for Tomcat? If the two webapps use the same docbase then they are accessing the same folder.
If your application writes to a database, and another copy of it is competing for the same data in the same database, this can result in such behaviour. Does your application write to a "fixed" database? If so, you will need to create another database, or change the way the application deals with the database.
Is the Context root different in the war files. If not I believe the server will not validate the url correctly.

Getting struts s:url includeparams to work on jboss when deploying as ROOT.war

I'm working on a webapp that uses struts 2, spring, URL Rewrite Filter and a couple of other dependencies that I'm not sure are relevant to this. One of the url's we construct is constructed as follows:
<s:url id="blah" includeParams="get">
This works fine when deploying in jboss as a normal webapp dropped in deploy/. So then all urls are of the form http://localhost:8080/mywebapp/... and when using this tag all the get parameters get included as expected.
However we wish to deploy this code in the root context (so everything ends up under http://localhost:8080/...), so we deployed it as ROOT.war. Suddenly, all the get parameters no longer show up in the URL. I've been looking for a while and can't seem to figure out what might cause this. First I thought it was to do with the URL rewriting but it seems to be working fine. Any tips, pointers, further questions for clarification are welcome. To add to the confusion, this all also works fine when deployed in jetty (where root context is the default).
edit: I've also tried removing ROOT.war and using jboss-web.xml to deploy to root context, this exhibits the exact same problem though.
I tracked this partly down to the url rewriting being misconfigured, the get parameters weren't being added to the urls to be rewritten because 'include-query-string' wasn't set to true on urlrewrite. this meant that 'blah?querystring' wasn't being redirected to 'blah.action?querystring'. It still doesn't seem to work right now because of interrelated problems, but I will separate those out to another question.

Categories