1.3.3. Deploying and testing
To deploy this application for testing we must create a Web ARchive (WAR). First we must define the WAR descriptor as
src/main/webapp/WEB-INF/web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <servlet> <servlet-name>Event Manager</servlet-name> <servlet-class>org.hibernate.tutorial.web.EventManagerServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>Event Manager</servlet-name> <url-pattern>/eventmanager</url-pattern> </servlet-mapping> </web-app>
To build and deploy call
mvn package
in your project directory and copy the hibernate-tutorial.war
file into your $JBOSS_HOME/server/$CONFIG/deploy
directory.
Once deployed and JBoss is running, access the application at
http://localhost:8080/hibernate-tutorial/eventmanager
. Watch the server log (in $JBOSS_HOME/server/$CONFIG/log/server.log
) to see Hibernate initialize when the first request hits your servlet (the static initializer in HibernateUtil
is called) and to get the detailed output if any exceptions occurs.