I'm developing a java base app which has to be deployed in PROD to Google App Engine. I need the set the <secure>true</secure> flag inside web.xml when comes time to deploy to PROD. However I'm testing with my appengine:devserver on my workstation and I'm using http (not https) so I have to set it to <secure>false</secure> or comment it out.
Question: what's the easiest way to automate this? I know it's possible with maven profiles but is there something Google plugin for Eclipse made or another way I'm missing? My project is Maven based and I'm starting the devserver either from command line or within the IDE...
Have you tried SessionCookieConfig and setting it programmatically? (e.g.: depending on environment variables)
I discovered that if I start only the webapp using appengine:devserver we don't need to care about true. So this is not a problem if I simply change the way I start the webapp. The problem occurs only if you start the webapp with Tomcat, jBoss or your own jetty server. However I consider a good practice to be able to run the application from something else than GAE just to be sure we aren't binded to a specific engine (server agnostic pattern)...
Related
I am working on online web logic server which is running on specific link.I have already deployed my Ear/War file on it but I want to make some changes in html/jsp page of deployed application.
If I follow regular approach of deployment then it will take 20 minutes to deploy it.
Is it possible to make changes without redeploying the application or is there any way to resolve this problem ?*
If possible share your explanation .
Instead of the usual "delete"/"install" steps to redeploy an application, you can instead use the "update" button. This updates the deployment while the old version is still running. This works fine for simple webapps.
For more sophisticated solutions refer to the Redeployment Section of the Documentation (here is the 12.1.1 Documentation https://docs.oracle.com/cd/E24329_01/web.1211/e24443/redeploy.htm#DEPGD288 )
I want to get a development experience like I get with Play! framework with JAX-RS (with Jersey for example). More specifically I want to use some kind of background compilation and run the compiled code immediately so that I have almost no waiting time.
My first attempt was to use NetBeans background compilation and Maven with plug-ins for Tomcat and Jetty which are restarting the application in the running container. But restarting took too long. I'm wondering if I need to restart the application if code changed or if something like Grizzly or Netty instead of a Servlet container would help.
Any ideas how to get fast reloads with JAX-RS?
Try this,
you need to add the dependencies. It uses jreloader (open source).
ant archetype
Edit:
People are still visiting this post after two years. Now there's a complete alternative for hot reloading and the project is active again http://dcevm.github.io/
You may need to use this as well https://github.com/HotswapProjects/HotswapAgent
Take a look at gretty: https://github.com/groovypp/gretty
It should work with jersey and you should see fast runtime reloads.
JRebel does this: http://zeroturnaround.com/jrebel/
Usually we start/stop bundles via OSGI console, but for web application, how to do that once it's deployed in a container ?
Regards,
Setya
Also not sure if I got you right, but anyway:
I think it depends on how you deploy a OSGi web application. The only way I already did was that I ran Tomcat within the OSGi context. Then Tomcat scans for bundles with a ".war" ending, so its basically started as soon as it's deployed and you can control it normally via the OSGi console
not sure If I got you right, but...
Mostly applications are started just after deployment(war or eclipse)... you don't need to do anything.
but in case you want to you can do exactly the same thing you do to bundles... go to the web console of your chosen AS and start it there.
Depends what you're using - please update question with container/framework details.
Otherwise, using Karaf you may simply SSH into the framework's shell and execute commands as normal.
Another alternative would be to use WebConsole from Apache Felix - this gives you a lot of control wrt bundles (you can even upload to deploy), and also gives you an embedded shell. It's quite extensible, you can write plugins to create new tabs etc. (AFAIK this will run fine in any framework).
I have several webapps deployed to production. I have used Tomcat as my servlet engine for ~10 years now. I'm considering moving to embedding Jetty model from the deploy-a-war-into-Tomcat model.
These webapps are deployed over several servers and some of the are horizontally scaled (using nginx IP hash based partitioning).
I see some advantages:
I can configure my servlet engine for a particular webapp (instead of having a generic configuration for Tomcat which is running several different webapps)
It's easier to horizontally scale my webapp by running multiple Jetty instances (configured to listen on different ports) on the same host. I could also do this with Tomcat (and I have run multiple tomcat instance on the same host in the past), but I've moved to using Debian packages (.deb archives) for deployment and it's not as easy to run multiple Tomcats using this method.
My deployment package (.deb) is more "complete" at build time i.e. I don't have to be sure the Tomcat instance is configured correctly.
And disadvantages:
More instances of a servlet engine running on a server means more resources being used
I've never used Jetty. I don't think I have any Tomcat-specific stuff going on in my webapps, but I'm not sure.
My main concern is the amount of resources that Jetty will use. If I had one Tomcat instance running 4 webapps, what will the difference in resources (memory/processor) be with four Jetty instances running?
This question is probably too open-ended, but I'm curious to know if I'm overlooking something or if anybody has any experience moving from Tomcat to (embedded) Jetty.
The web container I've found easiest to embed in a jar file (and it is still a valid WAR too) is Winstone (http://winstone.sourceforge.net/).
Jenkins - http://jenkins-ci.org/ - use this container so it has been pretty stress-tested. Note that it is Servlet 2.4 only.
Well I think there is no direct answer;
I might not fully understand the ".deb" part as I'm not a debian freak :)
I prefer having an instance of tomcat with a number of configurations aka CATALINA_HOME folders where you may specify apps and ports running, so you can always have all your configs separately and change the tomcat instance if needed.
Also, see related post:
Jetty: To embed or not to embed?
I also was used to Tomcat, so in my new project I tried using Jetty to learn about it.
In an enterprise environment (where you have production / testing / development servers) I would stick to Tomcat, mainly because it helps you in getting to separate code from configuration files (now I am working in setting the conf files in a separate jar, because that way when I move changes from testing to production they do not have to manually update the jars that I'll pass to sysadmin).
Other issue is that it looks like that Jetty has changed ownership not so long ago, and looking for info often got me to the old version.
Apart from that, using Jetty is not that different from Tomcat; had to run a little through docs for finding where everything is, but structure is (as last what I have seen, I have not tried anything too complicated) more or less like Tomcat.
I used to run Tomcat separately on my machine. I had an Ant script that would rebuild my project, deploy it locally, and restart Tomcat. That all worked ok, but I wasn't able to debug the web app inside Eclipse.
So I learned how to setup Tomcat inside Eclipse and got my web app running. Now the problem is that I don't understand fully how to manage it this way. Eclipse is set to automatically build my project on changes, but those changes don't seem to always be reflected in the web app. Sometimes I have to manually build the project and manually "clean" the server for the changes to be reflected.
Are there rules somewhere about how to manage this setup? For instance, if I only change a JSP then will it automatically be synchronized? If I change a servlet class, then I need to manually rebuild the project? Are these rules consistent, or should I just manually rebuild and clean every time?
I would really appreciate it if someone could give me the best practice rules or point me to a good resource to learn how to manage this environment.
PS. I am using Eclipse 3.4.1 Java EE package and Tomcat v5.5
You can use Eclipse and Tomcat in the way you mention. First the basics of how to set it up:
In the Servers view setup a new Tomcat server pointing to your TOMCAT_HOME
Make sure your project is an Eclipse "web project". You may need to create a dummy one and copy over some of the files in .settings (look at the wst files).
Deploy your project to Tomcat by right clicking on the server in the Servers view and "Add and Remove Projects..." to add your project to the server.
You can run your server and test it out just like you were running Tomcat outside of Eclipse. If you run the server in Debug mode you can set breakpoints and step through the code.
As for when you will need to restart the server Eclipse is usually pretty good about auto-deploying the changes. You will pretty much never need to restart for changes to jsp pages. If you change a class it will auto-deploy the change (usually) if you change the body of a method. If you change the signature of a class (add or remove a method or change args for it) you will almost always need to restart. Any changes to configuration files (web.xml or similar) will also almost always require a restart.
To restart just click on the "Debug" or "Run" button in the Server view. All your changes will be redeployed into Tomcat.
One thing to watch out for is that in the default configuration your "webapp" directory in TOMCAT_HOME will not be used. Instead it will use a folder under your Eclipse workspace directory (WORKSPACE/.metadata/.plugins/org.eclipse.wst.server.core/tmp0).
Normally you should republish the application to get latest changes, don't forget to synchronize with file system first in case your files modified extrernally.
You can specify that your application is automatically reloaded when modified, look for Auto-reload attribute in server.xml of your server configuration project. When set to true, tomcat will automatically reload your application. It's not always a good idea by the way.
Modified JSP's should work automatically, no need to restart the applciation.
If you change the structure of a class that has already been loaded and used (add/remove members, change method signature etc.) your code changes will not be reflected. This is not an eclipse issue but a JVM issue. If you make simple code changes, like logic changes inside an existing method, your changes will take effect after the class is compiled and re-deployed.
Regardless of that, if you change a public constant, you have to rebuild your project(s).
I found two things important to understand:
Eclipse does not automatically realize if files were changed outside of Eclipse. clicking Refresh on a project does that, so does F5. You can also change a setting to refresh automatically, which, however, does not detect changes instantly (my gut feeling says up to 10 secs delay)
Working with servers has the concept of "Publishing" files to Tomcat. This normally happens automatically within a second after any change. Changing many classes can cause many server reloads, which can be a drag if a context reload takes some time (as complex Spring apps certainly do). So I changed a setting to not publish automatically (double-click Server instance)