The jetty servlet container is quick and light enough to run in unit tests (indeed I do to serve up files).
It is possible to install actual servlets into it, programmatically (say in a test) and have it run them?
Yes. We do this on a regular basis with a number of tools. The simpest is probably HTTP-unit. When we deploy in jetty, we usually deploy larger parts of the application and run Selenium. HttpUnit is the simplest, but at some point your application complexity may warrant a more complete deployment. See the documentation section on embedding jetty
Why not use any HttpUnit, HTMLUnit etc.. Create an ANT script to do whatever is needed to run the test.
Related
We have two web applications, which are already developed using Servlets and Jsp'.
generally we build them using ant and deploy on jetty server.
we would like to make build and deploying process easy. so how we can use dropwizard for our purpose or is there any other frame work we can use to make deployment and launching web applications easy.
thanks
in theory, nothing stops you from overwriting the ServerFactory and creating your own servlets there. You can then have that in DropWizard and things should work. (see DefaultServerFactory)
Problem with this is, that you are now using DW as a running container and you don't take any advantage of any features it offers you. So it really makes no sense to use that with your setup I think.
Alternatively, if you want to run and deploy into jetty, may I suggest you look into the maven jetty plugin? http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html
It is not my favourite way of running it, but I have seen a lot of people using it. You essentially configure your application to use this plugin and add configuration on how to set up the connectors for jetty. Afterwards, all you need to do for running is "mvn jetty:run".
I use Eclipse "Dynamic Web Project" to create and test web application. It will publish my application on application server in convenient way. I don't need to write script, just wizard.
However, I am wondering it is a decent way to deploy a web application. What's your opinion? Thanks!
(I used to use Ant script to deploy my application, it's standard way.)
plus: Dynamic Web Project uses its specific directory layout which is different with Maven standard directory layout.
This is fine for deploying to a dev or test server. Its a convenient way to quickly deploy to have a look at changes you've made and to do tests.
I would definitely not allow this for any other environment, eg live, pre-production etc. You should have an established process (eg documented change control) to deploy to these environments.
I have heard it's still recommended to cold deploy and restart the server for not having a trouble with memory leaks, dynamic class loaders. For myself I think comfortable to deploy from Eclipse to most environments. Basically Eclipse WTP server adapter can run the same deploy command as the other processes. When I use clouds like GAE or Beanstalk I do deploy from Eclipse plugin, it is the same like command line.
Currentyl i am working on a Java Web Application something simple JSF + Spring + Hibernate textbook application architecture, but i find my self losting time on uploading my WAR into production every time i have to do it and also in updating MySQL scripts, so
is there any good practice to deployed Java Web Application quickly?
Edit
This is the current Process:
I work on localhost where i quickly
deploy with eclipse
If everything work fines i export a WAR with eclipse
Upload this WAR through FTP into (hosted) production server
Move this into tomcat webapps
Thanks.
Tip. I'm Using eclipse as my IDE and ain't using Maven nor Ant
There are a lot of tools you can use to automate the build and deployment process:
Compile application => deploy to local server => execute unit- and integration tests => upload WAR file to web server if all local tests pass -- this is exactly the kind of functionality that Maven and Ant were invented for!
If you want to get rid of the tedious manual work involved in these tasks, perhaps checking them out once more is not such a bad idea.
Also, there are more advanced Continuous Integration solutions, like Hudson, which help you to better integrate source code management and deployment processes.
But none of those will speed up data delivery.
It seems like your most pressing concern is to find a provider to make your internet connection faster: However you manage your build process, uploading the content to the server will quite probably be the most time-consuming part.
The single most important thing is being able to script the stuff, so you can let the computer automate it.
You may be able to get Netbeans to create build scripts for your eclipse projects so you can just run ant to create your war. If not, keep doing it manually.
Then you need to script the ftp-session. That is easy - many scriptable programs exist (or you can just use a modern Norton Commander clone supporting ftp), so script it.
Then you need to script the MySQL-script changes. This is not easy to suggest, as you did not mention what needs to be done, but you can probably get very far with a Perl script or perhaps a small stand-alone PHP snippet expanding a macro.
THen you need to collect all the steps in a single script you can then easily invoke...
(or you could just figure out how to talk to the Tomcat administrative console which allows you to update WAR files remotely - but that may not be feasible or I would have expected you to do so already)
Currently we have a Java Restlet API with dependencies controlled via Maven. When we update the API we run maven assembly:assembly which does the unit tests etc and produces a single jar file. We then upload this to the production server and run it using nohup.
Is there a better or more automated way of doing this? Is this where something like Hudson would come in?
Thanks
My experience goes with webapp-deployment. But same should hold true here. Use Maven, Cargo, Nexus (or Artifactory), Hudson and probably, Jira in conjunction of product release.
Automated release process are more reliable because there is no human factor involved that may forget a step.
We also use Liquibase for database versioning. And, if you are dealing with database changes in your application deployment. You'll realize Liquibase boosts so much confidence while running alter scripts.
I would suggest to go through the following resources
Automated Deployment with Maven - going the whole nine yards If you can, literally follow this pattern.
Maven 2 Effective Implementation -- this book really helped us a lot.
There are several Maven plugins to help deployment. The most general of them is Cargo, but there are also app server specific plugins for some concrete servers like JBoss.
Most companies I have worked for (actually, all) have had some sort of custom in-house built deployment system; even if build was done using a standard framework (like Maven in use at my current company).
Part of this is because there are many aspects that tie closely to company-specific infrastructure, capacity management and monitoring systems; and so even though there are open-source systems, there is usually something that needs to be tweaked.
It sounds like you are running your app on its own--it isn't part of any application server. If you aren't using an application server, there are probably some ways to get cargo and maven to deploy it for you, but you may be better off just using some shell scripts to deploy and run the application.
However, as your application grows, you may find a need for an application server like Jetty, JBoss, Glassfish, Tomcat, etc. When this happens, take a look at the cargo plugin for Maven because it will allow you to do something like:
mvn cargo:redeploy
That will package up your application, send it to the server and restart the app. If you want Hudson to do this for you automatically you can add it as a target to build.
Cargo can save you a lot of time when you have to frequently update an application server.
I need to do an integration tests on my web application on each build.
Currently I have a set of JUnit tests, which tests various parts of an application before it constructed into war. What I need to do now is to test if application is in good shape after it is deployed into Web container.
The application is written using Spring framework, I've read a lot of docs about Spring integration testing, but all they talk is about testing of integration with databases etc. I've read about Cactus, but the info is pretty scarse as well.
Any pointers for a good tutorials and source code are appreciated.
Details of a software used by app: Spring 2.5, Hibernate 3.2, Maven 2.2, Tomcat 6.0
Many thanks!
You have two tasks to solve: A) Get the container running in an automated (maven based) process and B) run some tests against it.
We use selenium and maven-jetty-plugin for testing a fairly similar application setup. Works like a charm. You might find the same kind of plugins for tomcat, or just run in jetty.
The advantage of selenium is that it allows you to test the application in a very real environment with a real browser. You may find that tools that skip the "real browser" part are simpler to start with.