Java Reference
In-Depth Information
13.6. Best practices and common deployment issues
After reading this chapter, it may appear that a lot of little pieces are required to deploy
EJB 3 components. That may not be far from the truth. The reality, though, is that you don't
have to keep track of all the pieces yourself; tools provided by the application servers help,
and much of the glue code can be automated. You need to keep in mind some key prin-
ciples, regardless of which components your application makes use of and which server
you plan to deploy it to.
13.6.1. Packaging and deployment best practices
The following list of best practices can make your life easier while you're building and de-
ploying your applications:
Start small . Even if you're an experienced EE developer, start small when working
on packaging your application and deploying it. Don't work for a month, generate
hundreds of beans, and then try to package and deploy your application for the first
time. If there are problems with the packaging, it's easier to solve them on a small
deployment than a larger one.
Use a constant server environment . For many, GlassFish is the choice for EE serv-
ers, but there are a lot of other options out there. When at all possible, make sure
everyone on the team and all of your development environments are consistently
using the same version of the same EE server. If EE servers must be different,
avoid packaging problems by separating code from packaging.
Separate code from configuration packaging . It's common for your applications to
contain both your code and your configuration. It's also common for this to cause
problems because packaging for development, test, and production environments
may all differ. Avoid this headache by creating separate projects for packaging and
move the packaging configuration (deployment descriptors!) to those projects. If
you're using a build tool like Maven, declaring dependencies and combining pro-
jects is made easier. You may think it's overkill to have different projects for pack-
aging to different environments, but it'll save you from packaging problems in the
long run.
Understand your application and its dependencies . Make sure that resources are
configured before you deploy the application in your target environment. If an
application requires a lot of resources, it's a good idea to use the deployment
descriptor to communicate the dependencies for the deployer to resolve before at-
Search WWH ::




Custom Search