Tag Archive: Java EE


Example persistence.xml for the use with application-managed EntityManager and extended PersistenceContext (which is the default for application managed EntityManager)

 <persistence xmlns="http://java.sun.com/xml/ns/persistence"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
  version="2.0">
  <persistence-unit name="shenShop" transaction-type="RESOURCE_LOCAL">
    <properties>
      <property name="javax.persistence.jdbc.driver" 
                value="org.apache.derby.jdbc.ClientDriver" />
      <property name="javax.persistence.jdbc.url" 
                value="jdbc:derby://localhost:1527/shenshop;create=true" />
      <property name="javax.persistence.jdbc.user" value="user" />
      <property name="javax.persistence.jdbc.password" value="user" />
      <property name="hibernate.hbm2ddl.auto" value="update" />
      <property name="hibernate.show_sql" value="true" />
    </properties>
  </persistence-unit>
</persistence>

„The scope of the persistence context of an application-managed entity manager is extended. It is the responsibility of the application to manage the lifecycle of the persistence context.“ – Java Persistence 2.1, Final Release, p.88

web.xml for dynamic web project in Eclipse

When creating a dynamic web project with Eclipse for JEE Developers, a standard web.xml (to be placed under WebContent/WEB-INF) looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns="http://java.sun.com/xml/ns/javaee" 
  xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
  id="WebApp_ID" version="3.0">
  <display-name>Servlet exercise</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</web-app>