1 / 20

Tomcat Environment

Tomcat Environment. In this presentation…. Setting up tomcat on your machine Setting up tomcat through MyEclipse Running tomcat through MyEclipse Setting up your project to run in tomcat in development Setting up your project to run in tomcat in test and production

trumand
Download Presentation

Tomcat Environment

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Tomcat Environment

  2. In this presentation… • Setting up tomcat on your machine • Setting up tomcat through MyEclipse • Running tomcat through MyEclipse • Setting up your project to run in tomcat in development • Setting up your project to run in tomcat in test and production • Migrating from JBoss to Tomcat • Tomcat test and production resources • build.properties file for tomcat • build.xml file for tomcat • Setting up tomcat datasources

  3. Why move? • Less of a memory footprint • More reliable test environment • Easier to understand • Development easier and much quicker • SIT Recommendation: Everyone that does not need EJB should move to Tomcat.

  4. Setting up tomcat on your machine • Extract tomcat into your /java/servers directory • https://docs.onestart.iu.edu/dav/MY/channels/Documentation/downloads/jakarta-tomcat-5.0.28.zip • Oracle jars (i.e.: UIS_java_lib/oracle-10.1.0.2.0/ojdbc14.jar) go in tomcat’s common/lib directory

  5. Setting up tomcat through MyEclipse

  6. Running tomcat through MyEclipse • Use the running man icon • Tomcat 5 • Start Tomcat • Stop Tomcat

  7. Setting up your project to run in tomcat in development • Tomcat 5 now uses context.xml files • Runs your application from a specified location • Hot deploy (on save) • Relieves the dependency on MyEclipse for deployment • You need to add: /java/servers/jakarta-tomcat-5.0.28/conf/Catalina/localhost/<app>-<env>.xml

  8. Example context.xml <Context path="/fo-dev" reloadable="true" docBase="c:/java/projects/FISCALOFFICER/fo"> <!-- datasources go here --> </Context>

  9. Setting up your project to run in tomcat in test and prod • Leverage the existing deployment setup used in the JBoss environment • appdeploy ... • Context.xml file changes where the docBase points • Context.xml should go in your META-INF directory and be named context.xml

  10. Cont. • Example <Context path="/<app>-<env>" reloadable="true" docBase="/usr/local/tomcat/<appserver>/webapps/<app>-<env>.war"> </Context> • Your ant dist task should replace the <env> with the correct test or prod environment.

  11. Cont. • Example <replaceregexp match="\b(dev|unt|reg|stg|trn|prd)\b" replace="${build.environment}" byline="true" flags="g"> <fileset dir="."> <include name="${webapp}/META-INF/context.xml" /> </fileset> </replaceregexp>

  12. Migrating from JBoss to Tomcat • Send a request to: j2ee-request@iu.edu

  13. Tomcat test and production resources • Deployment Test Server • x1j2ee • Deployment Prod Server • penguin01 • Test Servers • x3j2ee • x4j2ee • Prod Servers • penguin03 • penguin04

  14. build.properties file for tomcat • /opt/ears/<env>/<app> project.cvs.root=:pserver:anonymous@es01.uits.indiana.edu:/srcctrl/CVS project.cvs.package=SIT/FISCALOFFICER project.cvs.anonpassword=***** project.home=SIT/FISCALOFFICER project.server=sit2 appserver.home=/usr/local/tomcat/default appserver.lib.dir=/usr/local/tomcat/default/common/lib appserver.deploy.dir=/usr/local/tomcat/sit2/webapps

  15. build.xml file for tomcat • dist task only needs to build a war and a web.zip • dist task should also change the <ENV> for context.xml and web.xml • There is a different jsp compiler than for JBoss • See a full example in: SIT/FISCALOFFICER

  16. Setting up tomcat datasources • Creates a database pool managed by Jakarta DBCP • <webapp>/META-INF/context.xml between the <Context> tags • Add a <resource-ref> block to your web.xml • Example on the next page

  17. <!DOCTYPE doc [ <!ENTITY ENDB SYSTEM "file:/opt/sa_forms/java/unt/edu/iu/uis/security/fo/ENDB.xml"> ] > <Context path="/<app>-<env>" reloadable="true" docBase="/usr/local/tomcat/sit2/webapps/fo-unt.war"> <Resource name="jdbc/dev/fo/XA/EDEN" auth="Container" type="javax.sql.DataSource"/> <ResourceParams name="jdbc/dev/fo/XA/EDEN"> <parameter> <name>factory</name> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value> </parameter> <parameter> <name>maxActive</name> <value>100</value> </parameter> <parameter> <name>maxIdle</name> <value>5</value> </parameter> <parameter> <name>maxWait</name> <value>10000</value> </parameter> &ENDB; <!-- rename this to your file --> <parameter> <name>driverClassName</name> <value>oracle.jdbc.driver.OracleDriver</value> </parameter> <parameter> <name>validationQuery</name> <value>select 1 from dual</value> </parameter> </ResourceParams> </Context>

  18. Extract sensitive information /opt/sa_forms/java/<env>/edu/iu/uis/security/<app>/<app><resource>.xml <parameter> <name>username</name> <value>USERNAME</value> </parameter> <parameter> <name>password</name> <value>PASSWORD</value> </parameter> <parameter> <name>url</name> <value>jdbc:oracle:thin:@es01.uits.indiana.edu:1521:GEN1TST</value> </parameter>

  19. web.xml addition <resource-ref> <description>MY Datasource</description> <res-ref-name> jdbc/dev/my/MYDB </res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref>

  20. Questions?

More Related