-
Notifications
You must be signed in to change notification settings - Fork 273
Open
Description
I have been following the steps shown in articles-java-jee
to create EntityManagerFactory
. I have made the necessary changes in persistence.xml
,server.xml
and also put beans.xml
inside WEB-INF
folder. In spite of that when I create EntityManagerFactory
, it becomes null.
@PersistenceContext(name = "jpa-unit") static EntityManagerFactory emf;
static EntityManager em = emf.createEntityManager();
Persistence.xml
<persistence version="2.2"
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
<persistence-unit name="jpa-unit" transaction-type="JTA">
<jta-data-source>jdbc/articlejpadatasource</jta-data-source>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
<property name="eclipselink.ddl-generation.output-mode" value="both" />
</properties>
</persistence-unit>
</persistence>
Server.xml
<library id="DB2JCCLib">
<fileset dir="${shared.resource.dir}/db2jars" includes="jcc*.jar"/>
</library>
<dataSource id="articlejpadatasource"
jndiName="jdbc/articlejpadatasource">
<jdbcDriver libraryRef="DB2JCCLib" />
<properties.db2.jcc databaseName=""
portNumber="50000"
serverName=""
user=""
password="" />
</dataSource>
beans.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
bean-discovery-mode="all">
</beans>
pom.xml
<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>jcc</artifactId>
<version>11.1.4.4</version>
</dependency>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-jcc-dependency</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeArtifactIds>jcc</includeArtifactIds>
<outputDirectory>${project.build.directory}/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
What am I missing?
Metadata
Metadata
Assignees
Labels
No labels