This is a guide to configure WTP in order to execute and debug OpenXava
applications inside Eclipse.
Eclipse Web Tools Platform (
WTP) help you develop J2EE application with Eclipse.
In the case of OpenXava you can use WTP to start Tomcat (or your favorite
Application Server) inside Eclipse, thus you can see the effects of the
changes without redeploy and also you can debug your code.
All OpenXava applications created using OpenXavaTemplate are WTP
compatible.
This document guide you to use WTP for executing the
MySchool
demo application that comes with OpenXava.
Add
Tomcat to your Eclipse
- Go to Windows > Preferences > Server > Installed
Runtimes.
- Click on Add.
- Choose Apache > Apache Tomcat 5.5.
- Click on Next.
- Fill:
- Name: Apache Tomcat v5.5
- Tomcat installation directory: The path of your Tomcat
(you can use the OpenXava Tomcat in openxava-3.0.x/tomcat
folder)
- JRE: Choose a Java 5.
- Click on Finish.
- Click on OK in Preferences Dialog to close it.
Warning! If you use a Tomcat other than one that
comes with OpenXava distribution then you must copy
jta.jar
and
ejb.jar from
openxava-3.0.x/tomcat/common/lib
to the folder
common/lib of your Tomcat.
Create
a Tomcat server
- Go to Server tab. If it does not exist, add it (Windows
> Show view > Other > Server > Servers).
- In tab Server click Right Button > New >
Server.
- Select in Server runtime: Apache Tomcat v5.5.
- Click on Next.
- Add MySchool to Configured projects.
- Click on Finish.
Define
your data sources
Now you have in your workspace a project named
Servers. Inside
this project you have a folder named
Tomcat v5.5 Server @
localhost-config. Put there a file named context.xml with the next
content:
<!-- The contents of this file will be loaded for each web application -->
<Context>
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<Manager pathname="" />
<Resource name="jdbc/OpenXavaDS" auth="Container" type="javax.sql.DataSource"
maxActive="20" maxIdle="5" maxWait="10000"
username="sa" password="" driverClassName="org.hsqldb.jdbcDriver"
url="jdbc:hsqldb:file:/java/openxava-3.0/tomcat/data/openxava-db"/>
<Resource name="jdbc/MySchoolDS" auth="Container" type="javax.sql.DataSource"
maxActive="20" maxIdle="5" maxWait="10000"
username="sa" password="" driverClassName="org.hsqldb.jdbcDriver"
url="jdbc:hsqldb:file:/java/openxava-3.0/tomcat/data/my-school-db"/>
</Context>
Remember to change
/java/openxava-3.0 by the path where your
have OpenXava installed.
Start
the server and test your application
Developing
using WTP
After the above steps if you change Java code then you only need to click
on
Build All (or
Ctrl-B) and go to your browser to see
your updated application. If you touch some XML file you need to execute
the
rebuild ant target, refresh your project and go to the
browser to see the result.
Furthermore, you can start your Tomcat in debug mode and using the Eclipse
debugger.