Deploying MedRec from the Development Environment
This tutorial describes how to deploy an application from a WebLogic split development directory using the wldeploy ant task and weblogic.Deployer utilities. You can use these techniques to deploy an application quickly to a development environment without having to package the application or otherwise modify your build environment.
The tutorial includes the following sections:
Before starting this tutorial, complete tutorials 5 through 8 to create the project directory and perform the intermediate build steps for the Physician Application. If you completed tutorial 5 but skipped one or more of the subsequent tutorials, you can catch up by moving to the c:\medrec_tutorial\src\physicianEar subdirectory, setting the environment, and executing the Ant command:
ant -f build.xml
By now you have seen how the split development directory structure helps you easily build Enterprise Applications with WebLogic Server. But deploying Enterprise Applications sometimes seems like as much work as building them - you usually need to combine the compiled Java classes with modifiable deployment descriptors to create an exploded EAR directory or a compressed EAR file, which you then deploy. This process generally involves copying files from one place to another and changing their directory structures before deploying (not to mention repeating this process each time you rebuild the application or change a deployment descriptor).
With the split development directory, compiled files in the build directory are neatly separated from modifiable source files and descriptors in the source directory. WebLogic Server can deploy applications directly from a split development directory - you only need to target the build directory to deploy your work. In this procedure you use the split development directory to deploy physicianEar, which has now been built to the point where it is deployable:
- First start the MedRecServer if it is not already running:
- Open a new command shell:
start cmd- Start the MedRec server by running its start script:
c:\bea\user_projects\domains\medrecdomain\startweblogic.cmd- Open another command shell and set your environment:
c:\bea\user_projects\domains\medrecdomain\setenv.cmd- Move to the physicianEar subdirectory if you are not already there:
cd c:\medrec_tutorial\src\physicianEar- Use a text editor to create a new file, deploy.xml:
notepad deploy.xmlNote: If you do not want to create the deploy.xml file manually in this tutorial, copy the file named wldeploy_tutorial.xml to a new file named deploy.xml and follow along.
- Start the deploy.xml file by defining a project named physiciandeploy:
<project name="tutorial" default="deploy">- Define the main target for deploying the application:
<target name="deploy">
<wldeploy user="weblogic" password="weblogic" adminurl="t3://127.0.0.1:7101" action="deploy" name="tutorial_deployment" source="c:\medrec_tutorial\build\physicianEar"/>
</target>- Complete the deploy.xml file by closing the project element:
</project>- Your file contents should now resemble the following:
<project name="tutorial" default="deploy">
<target name="deploy">
<wldeploy user="weblogic" password="weblogic" adminurl="t3://127.0.0.1:7101" action="deploy" name="tutorial_deployment" source="c:\medrec_tutorial\build\physicianEar" />
</target>
</project>Save the file and exit your text editor.
- In the same command shell, enter the commands to execute the build script:
ant -f deploy.xmlYou should receive the following output from the wldeploy task:
Buildfile: deploy.xml
deploy:
[wldeploy] weblogic.Deployer -noexit -name tutorial_deployment -source C:\medrec_tutorial\build\physicianEar -adminurl t3://127.0.0.1:7101 -user weblogic -password weblogic -deploy
[wldeploy] Initiated Task: [0] [Deployer:149026]Deploy application tutorial_deployment on MedRecServer.
[wldeploy] Task 0 completed: [Deployer:149026]Deploy application tutorial_deployment on MedRecServer.
[wldeploy] Deployment completed on Server MedRecServer
[wldeploy]
BUILD SUCCESSFUL
Total time: 12 secondsIf you do not receive the above output, MedRecServer may not have finished starting up, or you may have made a typo in creating the deploy.xml file. If this occurs, wait until the server has finished starting up, and try to deploy using the installed tutorial file:
ant -f wldeploy_tutorial.xml- To verify that the application deployed, open a new browser window and enter the URL, http://127.0.0.1:7101/physician. You should receive the Physician Application's login page. You cannot do much more than look at the page right now, because the rest of the MedRec application suite is not available.
- The wldeploy task works using the same options as those available with the weblogic.Deployer command line utility. Before moving on to the next tutorial, undeploy the Physician application using weblogic.Deployer. In the same command-line window, enter the command:
java weblogic.Deployer -adminurl t3://127.0.0.1:7101 -user weblogic -password weblogic -undeploy -name tutorial_deploymentThe utility displays the following output messages:
Initiated Task: [1] [Deployer:149026]Remove application tutorial_deployment on MedRecServer.
Task 1 completed: [Deployer:149026]Remove application tutorial_deployment on MedRecServer.
Deployment completed on Server MedRecServer
Best Practices
- You can use the either the weblogic.Deployer tool or its associated Ant task, wldeploy to target the build directory to a server running in development mode. You cannot use the Administration Console to deploy from a split development directory.
- The split development directory structure enables you to deploy applications directly from your development environment without packaging or otherwise copying any files.
- In most cases, you need to deploy and redeploy frequently during the development phase of an Enterprise Application. You should generally add deploy and redeploy targets to your build files to your project build scripts to facilitate these functions. To redeploy using the wldeploy task, simply replace action="deploy" with action="redeploy", and omit the source definition; wldeploy uses the deployment name to redeploy the application.
How does wldeploy work with the split directory? The contents of c:\medrec_tutorial\build\physicianEar look similar to an exploded EAR directory, but there are no deployment descriptors. WebLogic Server finds the correct deployment descriptors to use by examining the c:\medrec_tutorial\build\physicianEar\.beabuild.txt file, which references the application's source directory, c:\medrec_tutorial\src\physicianEar. The source directory contains the component deployment descriptors needed to deploy the application.
Related Reading