Deploying to the Glassfish Server…
Ok, so you’ve built your world cracking application, how do you get it onto the production glassfish server? You could ofcourse configure your netbeans to look at the server and just hit Deploy but that isn’t always possible. Sometimes the server is out there on a remote network or behind a firewall. Luckily its not rocket science.
1. Set up your db connections
Easiest way to do this is to run Netbeans and run your project. Then pull up the admin console to your current glassfish server in the web browser:-
Username is normally admin password is adminadmin unless you’ve WISELY changed it to something else (which I always do ESPECIALLY on remote systems).
Now pull up the REMOTE glassfish server and copy the settings (sorry it’s manual!), you’ll need to create a connection pool (this is the thing that connects to the DB) and a JDBC resource to connect. Copy it from your settings, make any changes you need like the database server may be somewhere else.
Now deploy your application.
Click on Applications/Enterprise Applications then DEPLOY then you need to find the “dist” folder in the root of your project, and upload and deploy the file ending in .ear
Ok so what happens when we want to do an update – great news is you don’t have to log everyone out and make them wait for you to drink coffee, have a lunch break and update.
Simply Deploy the project under a different name then you can get them to login to the different URL. You could for instance have a redirect from a URL which you just change to point at the new site. Then as people relog they get the new version.
Ofcourse if you’re clustering just take the server offline you want to update. They will carry on on the other servers, do it one by one….and off you go.
Databases arghghhhghhgggh – If you can make sure your database username/password you used to develop on is the same as the one on your deployment server. Otherwise your Persistance Unit won’t work.
Copying the MYSQL driver to the right place – really it should be included in the setup of glassfish (Sun own MYSQL, Sun own App Server, 1+1=2?). Despite all the stuff around on where to copy that file (which I did) in the end I created a NB project on the server with some MYSQL an published it and that installed the driver and solved the problem.
In the end I have quite a nice set up where I set up my remote glassfish server in NB and published directly to the remote server – once you’ve done that updates are easy.