This is the readme file for the Tomcat JPA Sample application.
Tomcat Maven Plugin (which), last version 2.2 implies Tomcat 7.
Tomcat 7.0.57, which implies:
- Servlet Spec 3.0
- JSP Spec 2.2
- EL Spec 2.2
- Java 6 and later
Java 1.7.0_67.
H2 in its latest stable version 1.3.176.
Hibernate 4.3 requires Jandex. Jandex is in turn detected by Weld as available on classpath and used. Jandex-related classes in Weld are then not compatible with slf4j, they throw NumberFormatException as they try to push slf4j messages with "{}" possibly to JBoss logging which expects messages with "{0}" formatted for MessageFormat. This occurs on log level trace.
Therefore Hibernate 4.2 is chosen.
JPA provider Hibernate 4.2 in its latest stable version 4.2.17.Final, which implies:
- JPA 2.0
Bean Validation provider Hibernate Validator in its latest stable version 5.1.3.Final.
CDI provider Weld in its latest current version 2.2.8.Final. which implies:
- CDI 1.2
DeltaSpike for CDI extensions:
- JPA Module for declarative transactions.
- Data Module as a
@Repository
pattern provider.
Juplo Hibernate 4 Maven plugin to generate create table sql script.
- Install standalone Tomcat.
- Configure its
conf/tomcat-users.xml
:
<role rolename="manager-gui"/> <role rolename="manager-script"/> <user username="admin" password="" roles="manager-gui,manager-script"/>
- Copy the h2-1.3.176.jar to
lib/
directory. - Configure the
conf/server.xml
, find the<GlobalNamingResources>
and insert into it:
<!-- sample h2 database --> <Resource name="jdbc_sample" auth="Container" type="javax.sql.DataSource" username="sa" password="" driverClassName="org.h2.Driver" url="jdbc:h2:~/data/sample/sample;AUTO_SERVER=TRUE;DB_CLOSE_ON_EXIT=FALSE;MVCC=TRUE" maxActive="10" maxIdle="4" maxWait="10000" />
- Start Tomcat startup.sh.
- Verify the datasource is bound to the global JNDI
jdbc_sample
: Tomcat global JNDI resources. - Execute mvn to build the war and deploy / re-deploy it to the running Tomcat server.
- Access the home page.
- Refresh the home page repeatedly to get new sample values generated.
Execute mvn -Pdb to (re-)generate create table sql script in setup/sql/tomcat-jpa-sample-schema-generated.ddl
file.