Java enterprise application missing resources? - java

I have a java web app (Java ee) which is Servlet with JSP. Problem im having is that sometimes when i go to browser i wont find the resources that i have added, like some .jsp files will be missing completely and/or missing parts. If i refresh multiple times or if i delete a .jsp file and then add it again with the exact same code it temporarily fixes the problem.
I have tried doing ctr + F5 to clear the cache from browser, but didnt work. I also tried removing cache from intellij IDEA, also didnt work. What is going on?

Related

Tomcat reload jsp

I've this unique scenario :
Say I've some jsp file (a.jsp) and tomcat is serving this page. Suppose i now delete the file a.jsp and add again a.jsp (with little modifications) the tomcat is not taking the newly modified file. It says file is missing even though the file is there at exactly the same location. Otherwise i've to refresh the project in eclipse for the changes to take effect.
I tried adding the following block in tomcat's web.xml but it didn't help much:
<init-param>
<param-name>checkInterval</param-name>
<param-value>1</param-value>
</init-param>
I'd like to know if there is any solution where i don't need to refresh the project and the changes are taken in seamlessly.
The issue here is if i edit the same jsp (it still works fine -- the changes take in effect) but if i delete the jsp file and then add the same jsp file (at the same location) with little modifications the changes does not take in effect
Did you enable Hot-Deploy? If you double-click Tomcat in Eclipse there should be a Publishing-Section. "Publish on Save" is probably disabled.
Take a look at following Question it could be related to your problem:
Integrating tomcat and eclipse as a hot-deploy environment
At some point, another request must have come-in for a.jsp and Tomcat has cached the "not found" result. There have been a bunch of reports of Tomcat caching responses longer than expected, and I haven't gotten a clear answer for why that happens. It usually ends up being some slightly wrong configuration.

gwt application stopped running suddenly

first of all I am sorry on my English.
I have a problem in my Gwt application.
I build Gwt application and I work on application every day
Yesterday I want to still work on my application but is stopped worked and i do not know why and I not get errors
The application compiled and I get the Url to run on browser
I copy the Url to my Firefox browser and not happened nothing.
I put break point in my entry point class and I see the application not arrived to entry point and I do not know why.
I try to open new project to check maybe the problem in eclipse or in Gwt plug in but the new project worked excellent so I understand the problem in specific this project.
I need help
thank you everyone
Okay i have 3 possible suspicions:
You updated your Application, but for some reason some JavaScript stayed inside the Firefox cache. Solution: Go to options and "Clean cache" and always try to press CTRL+F5 instead of just reloading, this will clean the current website's cache saved in your Browser.
Your HDD is full(less likely). You said you work everyday on the app. The caching in dev-mode is very VERY bad(for me it once contained 300GB of cached data). there is a folder called <win_user>/AppData/Local/Temp - delete everything inside if you find a lot of "gwt-<something>" files and check the folder's size. There is nothing valuable inside it(if you didn't place anything inside :D)
P.S. Turns out it was a Firefox Memory-leak that has been fixed in GWT 2.6.0 :)
Your Eclipse messed up some random stuff. As always - Project > Clean...
Then right click on app and let gwt recomile your app(if you have an ant file that uses the gwt-compiler, execute that)
I can't really think of anything else...
The only thing that could be is that YOU changed something, but you said you didn't so...
Hopefully it works,
Laurenz

NullPointerException with Owasp.CsrfGuard.Test

Why do I get:
java.lang.NullPointerException org.owasp.csrfguard.CsrfGuardFilter.doFilter(CsrfGuardFilter.java:53)
when trying to run the 0wasp.CsrfGuard.Test example app on Tomcat 5.5?
I'm using the example app exactly as it came in the download but with the following changes to get around listener errors:
I downloaded the CsrfGuard 3.0.0 package and copied the Owasp.CsrfGuard.jar to WEB-INF/lib to get around the listeners not being found.
I changed the web.xml file to use the listener that comes with the Owasp.CsrfGuard.jar rather than the two listeners in the original web.xml, which don't exist.
When I start the app there are no errors but when I point my browser to the /Owasp.CsrfGuard.Test/index.html page, I get the above error.
Any ideas to try?
Update...
Several hours later and I got it working without error. I don't understand why but the filter errors seem to stick around even after stopping and restarting a webapp (in Tomcat at least). I had to rename that webapp's directory, wait 10 seconds for Tomcat to auto-undeploy it, rename it back to its original directory name, and wait 10 seconds for Tomcat to recognize it as a new webapp. I also removed the "x-requested-with" init-param from the web.xml file since I don't use AJAX. Don't know if that really needed to come out but it works so I'm leaving it out.
Now, the "protect.html" file is indeed protected but it is protected too well. I can't get to it at all. If I try to go directly to the protect.html page, it should not allow that, which it doesn't. However, it should allow me to get there through the proper webpage flow with all the pages getting the proper token(s).
The question now is how can I get to the protect.html page?
Thanks.
Got it! In case someone else has problems, here is what I figured out to get JavaScript DOM Manipulation working.
All of the references in the .properties file MUST BE absolute with reference to the web container (Tomcat in my case). Even if you place the .js and .jar files in a specific webapp and modify that webapp's web.xml file with the proper settings for CSRFGuard (with relative references by the way), the entries in the .properties file must include references to the webapp name. For example, it must be something like:
org.owasp.csrfguard.unprotected.Index=/someapp/index.html
rather than just
org.owasp.csrfguard.unprotected.Index=index.html
This is not intuitive since unless you are dealing with the entire Tomcat container (i.e. the master web.xml file) you can generally drop the webapp name since it is implied for that webapp.
Now I'm going to look into the other CSRFGuard method of JSP Tag Injection since the JavaScript mechanism won't work if the user has JavaScript turned off in their browser.

Website development and testing in Eclipse and Tomcat: javascript is cached

I'm developing a web application with jsp pages in Eclipse 3.7.2 and testing it with Tomcat v6.0.
I've almost the perfect environment as all changes to my jsp or java code are immediately available in the browser within Eclipse, so I can directly test any change.
But... I also use jQuery, who isn't ;-), and changes in my javascript files are not immediately active. Looks like they are cached or copied once and don't get replaced. Even after rebuilding or restarting the tomcat, the old files keep being used.
Any ideas on how to solve this?
Thanks a lot,
Frank
If you are using firebug in your browser, you can switch off the caching by default without adding code to your page:
click the arrow on the right side of the Networking button and select the disable browser cache option.
The files are probably cached by the browser.
ctrl-F5 might help but if you can configure the server to set no cache for js and css that should also help.
Another solution is to load all such files through a loader,
/load.<site extension, ex php>?file=myscript.js
And have that "proxy" set no cache.
We use that along with e-tag to be able to use build number as e-tag, vith every build a new version is forced to clients but then cached until next build.

java apache tomcat is not detecting the jsp file even when it exists

I have come across to a strange problem where apache tomcat server is showing 404 server code. But some of the files are being detected by the system. I am using eclipse for the development.
Any suggestions?!
EDIT 1 :
i have checked the webapps folder of CATALINA_HOME but nothing is there related to the project.
I'd recommending seeing if you can deploy a WAR file successfully in Tomcat without using Eclipse.
Right now it sounds like you don't understand Java web apps or Tomcat very well.
When you throw Eclipse on top of it there's too much ignorance to make progress.
So remove one of the things you don't understand. See if you can make the WAR file, deploy it manually, and see your JSP in the browser by hand. Once that works, you have a baseline for comparing how Eclipse needs to do things.
Another possible issue that might cause similar problems is if you have deployed your application in the root context (i.e. under the name ROOT) and the jsp in question is in a folder like /manager, while you also have the manager application. In this case, Tomcat will give preference to the manager application, rather than the /manager path inside the ROOT application
Eclipse wont always deploy dynamically aka hot deploy and you need to make it re-deploy. So sure shot way of checking is to actually going into the war file, or the root directory and checking if the jsp exists.
Also you have to provided much information as to what kind of a web application it is, for me to understand the problem better. For example, in struts a wrong entry in struts-config.xml will result in 404 even if the intended jsp is present.

Categories