CodeCharge Studio
Deploying Java & JSP Applications
Deploying Java projects is relatively straightforward because most modern Java servers support Web Application Archive (WAR) standard for java applications deployment. The details of server configuration and deployment process may vary from server to server. Generally you must only specify the path to the generated war file and context path to the web application. Many servers support auto deployment and you only need to copy the generated war file to the particular directory
one the server and the server will do the remaining job for you.
CodeCharge Studio has several project properties that can affect the application deployment.
- Class Path -
Property that is needed for the compilation of a project. At minimum the Servlets API should present; XML parser library and Regexp library may
also be needed. See Java Application requirements section for more information.
- Runtime libraries - The libraries your application depends on
that will be copied to the WEB-INF/lib directory and eventually added to the
application class path at run time.
- Target server - This defines how your application will be deployed.
Different servers have different deployment options.
- Deploy webapp as - This property has two options:
- "as war file" - Standard WAR will be generated. This options works with most modern application servers and the auto-deployment feature of several servers (see deployment scenarios below).
- "unpacked" - The application will be published to folder unpacked. This option is helpful for changes in one JSP page and its quick publishing (when only one page is published). Some older servers (that do not support WAR archive files) may need this option too.
The last five properties are needed to configure Tomcat 4.0 manager application for remote Tomcat administration (when Target server set to Tomcat 4.0). You may leave them empty for other target servers.
Normally you will have no problems with Java deployment with any Java Application Server that supports Servlets version 2.2 specification from Sun. The details of
the deployment process for several popular Java Application servers follow.
Tomcat 4.0 scenarios
Check that the DB drivers are in the class path of your server. Choose the appropriate scenario and change
the properties marked red.
Scenario 1. Auto-deployment from webapps directory (DataSource extension is not used)
- Before code generation verify that the Use Data Source site property is set to
No.
- Fill in connection properties to indicate Driver class name, Database url, user login and password.
- Ensure that your database driver is in your application server class path.
- Place the generated war file to where appBase attribute of Virtual Host configuration element points to. Generally it is
<tomcat_home>/webapps.
Scenario 2. Deployment through Context configuration (DataSource extension is not used)
Add Context element as a child to Host element in your server.xml configuration file.
</tomcat_home>
<Context path="/JSPPortal"docBase="JSPPortal.war">
</Context>
path - is the context path of your application. docBase is absolute or relative to appBase path to the war file.
Scenario 3. Deployment through Context configuration (DataSource extension is used)
- Before code generation verify that Use Data Source site property is set to
Yes.
- Set connection DataBase URL property to
java:comp/env/jdbc/Connection1
. Where
Connection1 is name of your connection.
- Define Context element as described in previous scenario.
- Add Resource child element with ResourceParams to the Context element:
<Resource name="jdbc/Connection1" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/Connection1">
<parameter>
<name>user</name>
<value>User Name</value>
</parameter>
<parameter>
<name>password</name>
<value>User Password</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>Driver Class Name</value>
</parameter>
<parameter>
<name>driverName</name>
<value>Database Connection URL</value>
</parameter>
</ResourceParams>
name is a JNDI name as indicated in your CCS Connection properties.
Resin 2.0 scenarios
Check that DB drivers are in class path of your server. Choose appropriate scenario and change properties marked red.
Scenario 1. Auto-deployment from webapps directory (DataSource extension is not used)
- Before code generation verify that Use Data Source site property is set to No.
- Fill in connection properties to indicate Driver class name, Database url, user login and password.
- Ensure that your database driver is in your application server class path.
- Place generated war file to where war-dir element of Virtual Host configuration element points to.
Generally it is <RESIN_HOME>/webapps.
Scenario 2. Deployment through web-app configuration (DataSource extension is not used)
Add Context element as a child to Host element in your resin.conf configuration file.
<web-app id="/JSPPortal"
app-dir="c:/projects/Portal/JSPPortal.war"/>
id is the context path of your application. app-dir is absolute or relative to global app-dir path to the war file.
Scenario 3. Deployment through web-app configuration (DataSource extension is used)
- Before code generation verify that Use Data Source site property is set to Yes.
- Set connection DataBase URL property to
java:comp/env/jdbc/Connection1
. Where Connection1 is name of your connection.
- Add resource-ref element as child of web-app element:
<resource-ref>
<res-ref-name>jdbc/Connection1</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<init-param driver-name="Driver Class Name"/>
<init-param url="Database connection URL"/>
<init-param user="User Name"/>
<init-param password="User Password"/>
<init-param max-connections="20"/>
<init-param max-idle-time="30"/>
<init-param enable-transaction="false"/>
</resource-ref>
res-ref-name is a JNDI name as indicated in your CCS Connection properties.
WebLogic 7.0 scenarios
- Check that DB drivers are in class path of your server.
- Choose appropriate scenario and change properties marked red.
Scenario 1. Auto-deployment from applications directory (DataSource extention is not used)
- Before code generation verify that Use Data Source site property is set to No.
- Fill in connection properties to indicate Driver class name, Database url, user login and password.
- You can quickly deploy your application on the administration server if auto-deploy is enabled by copying war file into \applications directory of the administration server.
Scenario 2. Deployment through Administration Console
Set Use Data Source site property appropriately to indicate whether you want to use DataSources in your code.
If you want to work with DataSources and you have not configured it already add and configure JDBC Pool and DataSource to your server as described in (http://e-docs.bea.com/wls/docs70/ConsoleHelp/jdbc.html#1104939
).
Bear in mind that weblogic JNDIName property should be equal to JNDI Name property of CCS connection. Install your application as described in (http://e-docs.bea.com/wls/docs70/ConsoleHelp/applications.html#1104914).
WebLogic 5.1 scenarios
CodeCharge Studio requires SAX 2.0 and JAXP 1.1 libraries to work with generated JSP. However WebLogic 5.1 goes with its own XML parser located in lib/weblogicaux.jar. You have to replace those libraries with the newer ones from<http://xml.apache.org/> or
<http://java.sun.com/xml/>.
To accomplish this you can:
- Specify this libraries in Runtime libraries property of the project or run the following command:
wlconfig.exe -classpath c:\java\xerces-2_0_1\xercesImpl.jar;C:\java\xerces-2_0_1\xmlParserAPIs.jar
- Restart the server.
Websphere 4.0 scenario
Because WebSphere 4.0 doesn't support autodeployment of war files, it is necessary to do the following:
- Fill in all Java Site properties and Connection serverside properties.
- Make sure that JDBC drivers are in application class path.
- Get the latest version of JAXP 1.1 and SAX 2.0 for compilation and runtime execution of JSP files. You can get them from the Ant installation.
- In 'Runtime libs' Site property enlist absolute paths to jar files corresponding to JAXP and SAX libraries spearated by semicolons. For example:
"c:\ant\lib\jaxp.jar;c:\ant\lib\crimson.jar"
. These files will be copied to the WEB-INF\lib directory of the application.
- Select 'WebSphere 4.0' in 'Target server' Site property.
- Specify 'Publishing/Server Path' property and publish your project.
- Install your application through the WebSphere console. On the second screen of the Application Installation Wizard select
No for 'Precompile JSPs' property of your web module.
- Start the new application from the WebSphere Admin console; restart the
server if needed.
Tomcat + Apache scenario
Scenario 1. MOD_JK connector.
- Download mod_jk.dll and libapr.dll and copy them to the
apache/modules
directory.
- Create workers.properties file in the
$CATALINA_HOME/conf/jk/
directory.
workers.tomcat_home=$(CATALINA_HOME)
workers.java_home=$(JAVA_HOME)
ps=\
worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
- At the end of httpd.conf LoadModule section add the following line:
LoadModule jk_module modules/mod_jk.dll
- At the end of httpd.conf AddModule section add the following line:
AddModule mod_jk.c
- At the end of httpd.conf add the following:
JkWorkersFile "$CATALINA_HOME/conf/jk/workers.properties"
JkLogFile "$CATALINA_HOME/logs/mod_jk.log"
JkLogLevel info
<VirtualHost localhost>
ServerName localhost
DocumentRoot $CATALINA_HOME/webapps/
JkMount /*.jsp ajp13
JkMount /*.do ajp13
</VirtualHost>
- If needed uncomment the following delcarations in Tomcat server.xml config file:
<Connector className="org.apache.ajp.tomcat4.Ajp13Connector"
port="8009" minProcessors="5" maxProcessors="75"
acceptCount="10" debug="0"/>
- In CCS set publishing path to $CATALINA_HOME/webapps/ and publish your project.
- Start Tomcat and then Apache.
Scenario 2. WARP connector.
- Download mod_webapp.so and libapr.dll and copy them to the apache/modules directory.
- At the end of httpd.conf LoadModule section add the following line:
LoadModule webapp_module modules/mod_webapp.so
- At the end of httpd.conf AddModule section add the following line:
AddModule mod_webapp.c
- At the end of httpd.conf add the following:
WebAppConnection warpConnection warp localhost:8008
WebAppDeploy JSPPortal warpConnection /Portal/
- If needed uncomment Tomcat-Apache service configuration in Tomcat server.xml config file.
- In CCS set publishing path to $CATALINA_HOME/webapps/ and publish your project.
- Start Tomcat and then Apache.
On-line, printable versions and updates