Related
I'm working on a webapp using wildfly and hibernate.
Below is some of my code and config files.
hibernate.cfg.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="">
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.password">removed</property>
<property name="hibernate.connection.url">jdbc:postgresql:reportbuilderwebservices</property>
<property name="hibernate.connection.username">removed</property>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.use_sql_comments">true</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="hibernate.hbm2ddl.auto">create</property>
<mapping class="org.declercq.reportbuilderback.models.User"/>
<mapping class="org.declercq.reportbuilderback.models.Permission"/>
<mapping class="org.declercq.reportbuilderback.models.Role"/>
<mapping class="org.declercq.reportbuilderback.models.Vulnerability"/>
<mapping class="org.declercq.reportbuilderback.models.Finding"/>
</session-factory>
</hibernate-configuration>
My model class User.java with annotations:
package org.declercq.reportbuilderback.models;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
#Entity
#Table(name = "users")
public class User implements Serializable {
private static final long serialVersionUID = 1L;
#Id #GeneratedValue
#Column(name="id")
private int id;
#Column(name="username")
private String userName;
#Column(name="password")
private String password;
#Column(name="email")
private String emailAddress;
public User(String userName, String password, String emailAddress) {
super();
this.userName = userName;
this.password = password;
this.emailAddress = emailAddress;
}
public User() {
super();
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmailAddress() {
return emailAddress;
}
public void setEmailAddress(String emailAddress) {
this.emailAddress = emailAddress;
}
}
My DAO method:
public List<User> getAllUsers(){
System.out.println("0");
Session session=HibernateUtil.getSessionFactory().getCurrentSession();
System.out.println("0,5");
Transaction tx = null;
List<User>allUsers=null;
try{
tx = session.beginTransaction();
System.out.println("1");
allUsers = session.createQuery("from User u").getResultList();
System.out.println("2");
tx.commit();
System.out.println("3");
}
catch(HibernateException e){
if(tx != null){
tx.rollback();
System.out.println("4");
}
return allUsers;
}
finally{
session.close();
System.out.println("5");
return allUsers;
}
}
My hibernate.util:
package org.declercq.reportbuilderback.dao;
import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
try {
Configuration configuration = new Configuration().configure();
configuration.configure("hibernate.cfg.xml");
StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties());
sessionFactory = configuration.buildSessionFactory(ssrb.build());
} catch (Throwable ex) {
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}
My webservice:
package org.declercq.reportbuilderback.webservices;
import java.util.List;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import org.declercq.reportbuilderback.dao.UserDao;
import org.declercq.reportbuilderback.models.User;
#Path("/userwebservice")
public class UserWebService {
#Path("/users")
#GET
#Produces("application/json")
public List<User> listUsers(){
System.out.println("HERE");
List<User>allUsers=new UserDao().getAllUsers();
System.out.println("Now here");
System.out.println("Size: "+allUsers.size());
return allUsers;
}
}
My pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>reportbuilderback</groupId>
<artifactId>org.declercq.reportbuilderback</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxb-provider</artifactId>
<version>3.0.19.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>3.0.19.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>async-http-servlet-3.0</artifactId>
<version>3.0.19.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>3.0.19.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-multipart-provider</artifactId>
<version>3.0.19.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.3.Final</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-all</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4.1211.jre7</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>
My server output:
The strange thing is, if you look at my output in console (where I use the system.out.println), the DAO code jumps from creating a transaction straight to closing the session, it doesn't even build my query.
The result is of course that my database query result is null, hence the nullpointerexception. This I understand, but I have no idea why the DAO code isn't executing correctly...
I'm thinking it's because of my pom configuration, something library at compile versus library from wildfly, but I have no idea...
UPDATE 1:
After changing my code as described below:
#SuppressWarnings({ "unchecked", "deprecation" })
public List<User> getAllUsers(){
System.out.println("0");
Session session=HibernateUtil.getSessionFactory().getCurrentSession();
System.out.println("0,5");
Transaction tx = null;
List<User>allUsers=null;
try{
tx = session.beginTransaction();
System.out.println("1");
//allUsers = session.createQuery("select u from User u").getResultList();
allUsers=session.createCriteria(User.class).list();
System.out.println("2");
tx.commit();
System.out.println("3");
}
catch(HibernateException e){
if(tx != null){
tx.rollback();
System.out.println("4");
}
return allUsers;
}
finally{
session.close();
System.out.println("5");
return allUsers;
}
}
I now get following output:
08:32:37,957 INFO [org.jboss.modules] (main) JBoss Modules version 1.5.2.Final
08:32:38,350 INFO [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final
08:32:38,467 INFO [org.jboss.as] (MSC service thread 1-8) WFLYSRV0049: WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) starting
08:32:41,471 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) WFLYDS0004: Found org.declercq.reportbuilderback-0.0.1-SNAPSHOT.war in deployment directory. To trigger deployment create a file called org.declercq.reportbuilderback-0.0.1-SNAPSHOT.war.dodeploy
08:32:41,641 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
08:32:41,715 INFO [org.xnio] (MSC service thread 1-6) XNIO version 3.4.0.Final
08:32:41,728 INFO [org.xnio.nio] (MSC service thread 1-6) XNIO NIO Implementation Version 3.4.0.Final
08:32:41,856 INFO [org.jboss.remoting] (MSC service thread 1-6) JBoss Remoting version 4.0.21.Final
08:32:41,958 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 38) WFLYCLINF0001: Activating Infinispan subsystem.
08:32:41,990 INFO [org.jboss.as.jsf] (ServerService Thread Pool -- 44) WFLYJSF0007: Activated the following JSF Implementations: [main]
08:32:42,007 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 46) WFLYNAM0001: Activating Naming Subsystem
08:32:42,059 WARN [org.jboss.as.txn] (ServerService Thread Pool -- 54) WFLYTX0013: Node identifier property is set to the default value. Please make sure it is unique.
08:32:42,097 INFO [org.wildfly.extension.io] (ServerService Thread Pool -- 37) WFLYIO001: Worker 'default' has auto-configured to 8 core threads with 64 task threads based on your 4 available processors
08:32:42,123 INFO [org.jboss.as.security] (ServerService Thread Pool -- 53) WFLYSEC0002: Activating Security Subsystem
08:32:42,126 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 56) WFLYWS0002: Activating WebServices Extension
08:32:42,175 INFO [org.jboss.as.connector] (MSC service thread 1-4) WFLYJCA0009: Starting JCA Subsystem (WildFly/IronJacamar 1.3.4.Final)
08:32:42,208 INFO [org.wildfly.extension.undertow] (MSC service thread 1-5) WFLYUT0003: Undertow 1.4.0.Final starting
08:32:42,213 INFO [org.jboss.as.security] (MSC service thread 1-6) WFLYSEC0001: Current PicketBox version=4.9.6.Final
08:32:42,473 INFO [org.jboss.as.naming] (MSC service thread 1-6) WFLYNAM0003: Starting Naming Service
08:32:42,477 INFO [org.jboss.as.mail.extension] (MSC service thread 1-7) WFLYMAIL0001: Bound mail session [java:jboss/mail/Default]
08:32:42,523 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 33) WFLYJCA0004: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
08:32:42,535 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-8) WFLYJCA0018: Started Driver service with driver-name = h2
08:32:42,853 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 55) WFLYUT0014: Creating file handler for path '/home/wouter/wildfly-10.1.0.Final/welcome-content' with options [directory-listing: 'false', follow-symlink: 'false', case-sensitive: 'true', safe-symlink-paths: '[]']
08:32:42,889 INFO [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0012: Started server default-server.
08:32:42,897 INFO [org.wildfly.extension.undertow] (MSC service thread 1-7) WFLYUT0018: Host default-host starting
08:32:43,108 INFO [org.jboss.as.ejb3] (MSC service thread 1-7) WFLYEJB0481: Strict pool slsb-strict-max-pool is using a max instance size of 64 (per class), which is derived from thread worker pool sizing.
08:32:43,109 INFO [org.jboss.as.ejb3] (MSC service thread 1-4) WFLYEJB0482: Strict pool mdb-strict-max-pool is using a max instance size of 16 (per class), which is derived from the number of CPUs on this host.
08:32:43,251 INFO [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0006: Undertow HTTP listener default listening on 127.0.0.1:8080
08:32:43,729 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-8) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
08:32:44,048 WARN [org.jboss.as.domain.management.security] (MSC service thread 1-5) WFLYDM0111: Keystore /home/wouter/wildfly-10.1.0.Final/standalone/configuration/application.keystore not found, it will be auto generated on first use with a self signed certificate for host localhost
08:32:44,093 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-8) WFLYDS0013: Started FileSystemDeploymentService for directory /home/wouter/wildfly-10.1.0.Final/standalone/deployments
08:32:44,112 INFO [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0027: Starting deployment of "org.declercq.reportbuilderback-0.0.1-SNAPSHOT.war" (runtime-name: "org.declercq.reportbuilderback-0.0.1-SNAPSHOT.war")
08:32:44,508 INFO [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-4) ISPN000128: Infinispan version: Infinispan 'Chakra' 8.2.4.Final
08:32:44,547 INFO [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0006: Undertow HTTPS listener https listening on 127.0.0.1:8443
08:32:44,617 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 64) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
08:32:44,614 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 60) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
08:32:44,621 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 60) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
08:32:44,616 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 65) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
08:32:44,623 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 65) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
08:32:44,633 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 64) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
08:32:44,841 INFO [org.jboss.ws.common.management] (MSC service thread 1-5) JBWS022052: Starting JBossWS 5.1.5.Final (Apache CXF 3.1.6)
08:32:47,678 INFO [org.jboss.weld.deployer] (MSC service thread 1-5) WFLYWELD0003: Processing weld deployment org.declercq.reportbuilderback-0.0.1-SNAPSHOT.war
08:32:47,783 INFO [org.hibernate.validator.internal.util.Version] (MSC service thread 1-5) HV000001: Hibernate Validator 5.2.4.Final
08:32:48,163 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-1) WFLYJCA0005: Deploying non-JDBC-compliant driver class org.postgresql.Driver (version 9.4)
08:32:48,236 INFO [org.jboss.weld.Version] (MSC service thread 1-1) WELD-000900: 2.3.5 (Final)
08:32:48,315 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) WFLYJCA0018: Started Driver service with driver-name = org.declercq.reportbuilderback-0.0.1-SNAPSHOT.war_org.postgresql.Driver_9_4
08:32:51,378 INFO [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 64) RESTEASY002225: Deploying javax.ws.rs.core.Application: class org.declercq.reportbuilderback.webservices.ConfigApp
08:32:51,429 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 64) WFLYUT0021: Registered web context: /org.declercq.reportbuilderback-0.0.1-SNAPSHOT
08:32:51,498 INFO [org.jboss.as.server] (ServerService Thread Pool -- 34) WFLYSRV0010: Deployed "org.declercq.reportbuilderback-0.0.1-SNAPSHOT.war" (runtime-name : "org.declercq.reportbuilderback-0.0.1-SNAPSHOT.war")
08:32:51,731 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
08:32:51,731 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
08:32:51,732 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) started in 14785ms - Started 476 of 724 services (404 services are lazy, passive or on-demand)
08:32:57,477 INFO [stdout] (default task-3) HERE
08:32:57,480 INFO [stdout] (default task-3) 0
08:32:57,639 INFO [org.hibernate.Version] (default task-3) HHH000412: Hibernate Core {5.2.3.Final}
08:32:57,641 INFO [org.hibernate.cfg.Environment] (default task-3) HHH000206: hibernate.properties not found
08:32:57,644 INFO [org.hibernate.cfg.Environment] (default task-3) HHH000021: Bytecode provider name : javassist
08:32:58,527 INFO [org.hibernate.annotations.common.Version] (default task-3) HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
08:32:58,725 WARN [org.hibernate.orm.connections.pooling] (default task-3) HHH10001002: Using Hibernate built-in connection pool (not for production use!)
08:32:58,727 INFO [org.hibernate.orm.connections.pooling] (default task-3) HHH10001005: using driver [org.postgresql.Driver] at URL [jdbc:postgresql:reportbuilderwebservices]
08:32:58,729 INFO [org.hibernate.orm.connections.pooling] (default task-3) HHH10001001: Connection properties: {user=reportbuilderwebservices, password=****}
08:32:58,730 INFO [org.hibernate.orm.connections.pooling] (default task-3) HHH10001003: Autocommit mode: false
08:32:58,734 INFO [org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl] (default task-3) HHH000115: Hibernate connection pool size: 10 (min=1)
08:32:58,844 INFO [org.hibernate.dialect.Dialect] (default task-3) HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
08:32:59,106 INFO [org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl] (default task-3) HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
08:32:59,109 INFO [org.hibernate.type.BasicTypeRegistry] (default task-3) HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType#48ea9b0e
08:32:59,449 INFO [org.hibernate.tool.schema.internal.SchemaCreatorImpl] (default task-3) HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl#43b645ed'
08:32:59,632 INFO [stdout] (default task-3) 0,5
08:32:59,636 INFO [stdout] (default task-3) 1
08:32:59,640 WARN [org.hibernate.orm.deprecation] (default task-3) HHH90000022: Hibernate's legacy org.hibernate.Criteria API is deprecated; use the JPA javax.persistence.criteria.CriteriaQuery instead
08:32:59,653 INFO [stdout] (default task-3) 2
08:32:59,657 INFO [stdout] (default task-3) 3
08:32:59,658 INFO [stdout] (default task-3) 5
08:32:59,659 INFO [stdout] (default task-3) Now here
08:32:59,660 INFO [stdout] (default task-3) Size: 0
So, 2 issues here: 1) for some reason, this executes while the previous method of createQuery did not. I really want to know why, since this way (using criteria) apparently is deprecated. 2) Most important reason of all: I print out the size of allUsers at the end, the size is 0, which is absolutely not possible, since there are 3 user accounts added in that users table.
Can someone assist please?
Thanks!
createQuery is returning null, which usually means that there is something wrong with the query string. You could try, for example:
allUsers = session.createQuery("from User").getResultList();
Or JPA compliant way:
allUsers = session.createQuery("select u from User u").getResultList();
Or without hql:
allUsers = session.createCriteria(User.class).list();
I'm building a webapp using hibernate and wildfly.
Below the content of some of my files:
Hibernate model user.java:
package org.declercq.reportbuilderback.models;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
#Entity (name="User")
#Table(name = "users")
public class User {
#Id #GeneratedValue
#Column(name="id")
private int id;
#Column(name="username")
private String userName;
#Column(name="password")
private String password;
#Column(name="email")
private String emailAddress;
public User(String userName, String password, String emailAddress) {
super();
this.userName = userName;
this.password = password;
this.emailAddress = emailAddress;
}
public User() {
super();
}
public int getId() {
return id;
}
}
My hibernate util class:
package org.declercq.reportbuilderback.dao;
import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
//import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
public class HibernateUtil {
private static SessionFactory sessionFactory;
public static SessionFactory getSessionFactory() {
if(sessionFactory == null){
// loads configuration and mappings
Configuration configuration = new Configuration().configure("hibernate.cfg.xml");
ServiceRegistry serviceRegistry
= new StandardServiceRegistryBuilder()
.applySettings(configuration.getProperties()).build();
// builds a session factory from the service registry
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
}
return sessionFactory;
}
}
My DAO method used:
public List<User> getAllUsers(){
System.out.println("0");
Session session=HibernateUtil.getSessionFactory().openSession();
System.out.println("0,5");
Transaction tx = null;
List<User> allUsers=null;
try{
tx = session.beginTransaction();
System.out.println("1");
allUsers = session.createQuery("FROM org.declercq.reportbuilderback.models.User").getResultList();
System.out.println("2");
tx.commit();
System.out.println("3");
return allUsers;
}
catch(HibernateException e){
if(tx != null){
tx.rollback();
System.out.println("4");
}
return allUsers;
}
finally{
session.close();
System.out.println("5");
}
}
This method is called by a web service:
package org.declercq.reportbuilderback.webservices;
import java.util.List;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import org.declercq.reportbuilderback.dao.UserDao;
import org.declercq.reportbuilderback.models.User;
#Path("/userwebservice")
public class UserWebService {
#Path("/users")
#GET
#Produces("application/json")
public List<User> listUsers(){
System.out.println("HERE");
List<User>allUsers=new UserDao().getAllUsers();
System.out.println("Now here");
System.out.println("Size: "+allUsers.size());
return allUsers;
}
}
My hibernate config file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="">
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.password">removed</property>
<property name="hibernate.connection.url">jdbc:postgresql://127.0.0.1:5432/reportbuilderwebservices</property>
<property name="hibernate.connection.username">removed</property>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.use_sql_comments">true</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.hbm2ddl.auto">create</property>
<property name="hibernate.connection.pool_size">20</property>
<mapping class="org.declercq.reportbuilderback.models.User"/>
<mapping class="org.declercq.reportbuilderback.models.Permission"/>
<mapping class="org.declercq.reportbuilderback.models.Role"/>
<mapping class="org.declercq.reportbuilderback.models.Vulnerability"/>
<mapping class="org.declercq.reportbuilderback.models.Finding"/>
</session-factory>
</hibernate-configuration>
When I'm deploying this to wildfly, I'm getting the following in console:
16:47:17,758 INFO [org.jboss.modules] (main) JBoss Modules version 1.5.2.Final
16:47:18,100 INFO [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final
16:47:18,239 INFO [org.jboss.as] (MSC service thread 1-7) WFLYSRV0049: WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) starting
16:47:20,325 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) WFLYDS0004: Found org.declercq.reportbuilderback-0.0.1-SNAPSHOT.war in deployment directory. To trigger deployment create a file called org.declercq.reportbuilderback-0.0.1-SNAPSHOT.war.dodeploy
16:47:20,488 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
16:47:20,532 INFO [org.xnio] (MSC service thread 1-6) XNIO version 3.4.0.Final
16:47:20,568 INFO [org.xnio.nio] (MSC service thread 1-6) XNIO NIO Implementation Version 3.4.0.Final
16:47:20,657 INFO [org.jboss.remoting] (MSC service thread 1-6) JBoss Remoting version 4.0.21.Final
16:47:20,748 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 38) WFLYCLINF0001: Activating Infinispan subsystem.
16:47:20,782 INFO [org.wildfly.extension.io] (ServerService Thread Pool -- 37) WFLYIO001: Worker 'default' has auto-configured to 8 core threads with 64 task threads based on your 4 available processors
16:47:20,881 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 46) WFLYNAM0001: Activating Naming Subsystem
16:47:20,896 WARN [org.jboss.as.txn] (ServerService Thread Pool -- 54) WFLYTX0013: Node identifier property is set to the default value. Please make sure it is unique.
16:47:20,897 INFO [org.jboss.as.jsf] (ServerService Thread Pool -- 44) WFLYJSF0007: Activated the following JSF Implementations: [main]
16:47:20,916 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 33) WFLYJCA0004: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
16:47:20,929 INFO [org.jboss.as.security] (ServerService Thread Pool -- 53) WFLYSEC0002: Activating Security Subsystem
16:47:20,940 INFO [org.jboss.as.connector] (MSC service thread 1-6) WFLYJCA0009: Starting JCA Subsystem (WildFly/IronJacamar 1.3.4.Final)
16:47:20,945 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) WFLYJCA0018: Started Driver service with driver-name = h2
16:47:20,963 INFO [org.jboss.as.security] (MSC service thread 1-3) WFLYSEC0001: Current PicketBox version=4.9.6.Final
16:47:21,244 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 56) WFLYWS0002: Activating WebServices Extension
16:47:21,318 INFO [org.jboss.as.naming] (MSC service thread 1-2) WFLYNAM0003: Starting Naming Service
16:47:21,334 INFO [org.jboss.as.mail.extension] (MSC service thread 1-2) WFLYMAIL0001: Bound mail session [java:jboss/mail/Default]
16:47:21,381 INFO [org.wildfly.extension.undertow] (MSC service thread 1-7) WFLYUT0003: Undertow 1.4.0.Final starting
16:47:21,904 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 55) WFLYUT0014: Creating file handler for path '/home/wouter/wildfly-10.1.0.Final/welcome-content' with options [directory-listing: 'false', follow-symlink: 'false', case-sensitive: 'true', safe-symlink-paths: '[]']
16:47:22,028 INFO [org.jboss.as.ejb3] (MSC service thread 1-8) WFLYEJB0482: Strict pool mdb-strict-max-pool is using a max instance size of 16 (per class), which is derived from the number of CPUs on this host.
16:47:22,029 INFO [org.jboss.as.ejb3] (MSC service thread 1-6) WFLYEJB0481: Strict pool slsb-strict-max-pool is using a max instance size of 64 (per class), which is derived from thread worker pool sizing.
16:47:22,040 INFO [org.wildfly.extension.undertow] (MSC service thread 1-6) WFLYUT0012: Started server default-server.
16:47:22,042 INFO [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0018: Host default-host starting
16:47:22,225 INFO [org.wildfly.extension.undertow] (MSC service thread 1-6) WFLYUT0006: Undertow HTTP listener default listening on 127.0.0.1:8080
16:47:22,744 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-8) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
16:47:23,033 WARN [org.jboss.as.domain.management.security] (MSC service thread 1-4) WFLYDM0111: Keystore /home/wouter/wildfly-10.1.0.Final/standalone/configuration/application.keystore not found, it will be auto generated on first use with a self signed certificate for host localhost
16:47:23,066 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-8) WFLYDS0013: Started FileSystemDeploymentService for directory /home/wouter/wildfly-10.1.0.Final/standalone/deployments
16:47:23,085 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) WFLYSRV0027: Starting deployment of "org.declercq.reportbuilderback-0.0.1-SNAPSHOT.war" (runtime-name: "org.declercq.reportbuilderback-0.0.1-SNAPSHOT.war")
16:47:23,635 INFO [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-6) ISPN000128: Infinispan version: Infinispan 'Chakra' 8.2.4.Final
16:47:23,683 INFO [org.wildfly.extension.undertow] (MSC service thread 1-4) WFLYUT0006: Undertow HTTPS listener https listening on 127.0.0.1:8443
16:47:23,697 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 64) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
16:47:23,722 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 64) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
16:47:23,728 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 58) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
16:47:23,704 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 65) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
16:47:23,734 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 65) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
16:47:23,731 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 58) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
16:47:24,060 INFO [org.jboss.ws.common.management] (MSC service thread 1-5) JBWS022052: Starting JBossWS 5.1.5.Final (Apache CXF 3.1.6)
16:47:26,386 INFO [org.jboss.weld.deployer] (MSC service thread 1-7) WFLYWELD0003: Processing weld deployment org.declercq.reportbuilderback-0.0.1-SNAPSHOT.war
16:47:26,897 INFO [org.hibernate.validator.internal.util.Version] (MSC service thread 1-7) HV000001: Hibernate Validator 5.2.4.Final
16:47:27,312 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-5) WFLYJCA0005: Deploying non-JDBC-compliant driver class org.postgresql.Driver (version 9.4)
16:47:27,364 INFO [org.jboss.weld.Version] (MSC service thread 1-5) WELD-000900: 2.3.5 (Final)
16:47:27,465 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-1) WFLYJCA0018: Started Driver service with driver-name = org.declercq.reportbuilderback-0.0.1-SNAPSHOT.war_org.postgresql.Driver_9_4
16:47:30,321 INFO [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 65) RESTEASY002225: Deploying javax.ws.rs.core.Application: class org.declercq.reportbuilderback.webservices.ConfigApp
16:47:30,383 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 65) WFLYUT0021: Registered web context: /org.declercq.reportbuilderback-0.0.1-SNAPSHOT
16:47:30,419 INFO [org.jboss.as.server] (ServerService Thread Pool -- 34) WFLYSRV0010: Deployed "org.declercq.reportbuilderback-0.0.1-SNAPSHOT.war" (runtime-name : "org.declercq.reportbuilderback-0.0.1-SNAPSHOT.war")
16:47:30,634 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
16:47:30,635 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
16:47:30,637 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) started in 13428ms - Started 476 of 724 services (404 services are lazy, passive or on-demand)
16:51:38,771 INFO [stdout] (default task-3) HERE
16:51:38,774 INFO [stdout] (default task-3) 0
16:51:38,891 INFO [org.hibernate.Version] (default task-3) HHH000412: Hibernate Core {5.2.3.Final}
16:51:38,895 INFO [org.hibernate.cfg.Environment] (default task-3) HHH000206: hibernate.properties not found
16:51:38,898 INFO [org.hibernate.cfg.Environment] (default task-3) HHH000021: Bytecode provider name : javassist
16:51:39,501 INFO [org.hibernate.annotations.common.Version] (default task-3) HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
16:51:39,688 WARN [org.hibernate.orm.connections.pooling] (default task-3) HHH10001002: Using Hibernate built-in connection pool (not for production use!)
16:51:39,690 INFO [org.hibernate.orm.connections.pooling] (default task-3) HHH10001005: using driver [org.postgresql.Driver] at URL [jdbc:postgresql://127.0.0.1:5432/reportbuilderwebservices]
16:51:39,691 INFO [org.hibernate.orm.connections.pooling] (default task-3) HHH10001001: Connection properties: {user=reportbuilderwebservices, password=****}
16:51:39,691 INFO [org.hibernate.orm.connections.pooling] (default task-3) HHH10001003: Autocommit mode: false
16:51:39,695 INFO [org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl] (default task-3) HHH000115: Hibernate connection pool size: 20 (min=1)
16:51:39,803 INFO [org.hibernate.dialect.Dialect] (default task-3) HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
16:51:40,086 INFO [org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl] (default task-3) HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
16:51:40,091 INFO [org.hibernate.type.BasicTypeRegistry] (default task-3) HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType#60f81f2e
16:51:40,453 INFO [org.hibernate.tool.schema.internal.SchemaCreatorImpl] (default task-3) HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl#4788a59c'
16:51:40,642 INFO [stdout] (default task-3) 0,5
16:51:40,649 INFO [stdout] (default task-3) 1
16:51:40,681 WARN [org.hibernate.hql.internal.QuerySplitter] (default task-3) HHH000183: no persistent classes found for query class: FROM org.declercq.reportbuilderback.models.User
16:51:40,684 INFO [org.hibernate.hql.internal.QueryTranslatorFactoryInitiator] (default task-3) HHH000397: Using ASTQueryTranslatorFactory
16:51:40,692 INFO [stdout] (default task-3) 2
16:51:40,693 INFO [stdout] (default task-3) 3
16:51:40,695 INFO [stdout] (default task-3) 5
16:51:40,696 INFO [stdout] (default task-3) Now here
16:51:40,697 INFO [stdout] (default task-3) Size: 0
The problem is in those last few lines of console output.
As you can see in my code (the DAO method and the webservice code), I put some system.out.println statements in between to troubleshoot.
All calls are being executed, no errors are thrown. Nevertheless, when I print the size of the resulting list of the database query, it is empty (size 0).
I put some data in that users table and checked manually that the data is there. Nevertheless my code is not retrieving it...
Also, why am I seeing this:
16:51:40,681 WARN [org.hibernate.hql.internal.QuerySplitter] (default task-3) HHH000183: no persistent classes found for query class: FROM org.declercq.reportbuilderback.models.User
I have a mapping in my hibernate config file, I have the annotations in place in the model class User.java, nevertheless it seems that something is missing?
If I replace the query with "From User", then I get an error stating that User is not mapped, but it is in my configuration file? I am forced to use the full package+class name in my HQL query?
Can anyone shed some light on this for me?
Thanks!
Try
allUsers = session.createQuery("SELECT u FROM User u").getResultList();
Please check this link: Hibernate: no persistent classes found for query class: SELECT p FROM entity.Presentation p
As mentioned name of the entity defaults to the simple class name. It does not contain name of the package.
You should use #Entity on User:
#Entity
public class User {
...
}
https://docs.jboss.org/hibernate/stable/annotations/reference/en/html/entity.html
I'm a bit confused.
I'm #Inject-ing a custom component into a #CDIView.
The component has its PersistenceContext injected
#PersistenceContext
private EntityManager em;
So far everything fine. If I look at it in debug, the EntityManager exists, I can even query the JPAContainer and get a result but when the View loads in my Application I get a javax.naming.NameNotFoundException: env/persistence/em
So I wonder: Why?
Why is there a lookup when I passed a EntityManager in the first place?
Is there some bit of configuration I missed? Is passing a Injected EntityManager in the JPAContainerFactory discouraged?
16:51,367 SEVERE [com.vaadin.server.DefaultErrorHandler] (default task-44) : java.lang.RuntimeException: javax.naming.NameNotFoundException: env/persistence/em -- service jboss.naming.context.java.module."web-0.0.1-SNAPSHOT"."web-0.0.1-SNAPSHOT".env.persistence.em
at com.vaadin.addon.jpacontainer.provider.jndijta.Util.getEntityManager(Util.java:35)
at com.vaadin.addon.jpacontainer.provider.jndijta.CachingMutableEntityProvider.getEntityManager(CachingMutableEntityProvider.java:59)
at com.vaadin.addon.jpacontainer.provider.LocalEntityProvider.doGetEntityManager(LocalEntityProvider.java:226)
at com.vaadin.addon.jpacontainer.provider.LocalEntityProvider.doGetEntityCount(LocalEntityProvider.java:510)
at com.vaadin.addon.jpacontainer.provider.CachingSupport$FilterCacheEntry.getEntityCount(CachingSupport.java:157)
at com.vaadin.addon.jpacontainer.provider.CachingSupport.getEntityCount(CachingSupport.java:826)
at com.vaadin.addon.jpacontainer.provider.CachingMutableLocalEntityProvider.getEntityCount(CachingMutableLocalEntityProvider.java:130)
at com.vaadin.addon.jpacontainer.JPAContainer.size(JPAContainer.java:912)
at com.vaadin.ui.Table.containerItemSetChange(Table.java:4565)
at com.vaadin.addon.jpacontainer.JPAContainer.fireContainerItemSetChange(JPAContainer.java:262)
at com.vaadin.addon.jpacontainer.JPAContainer$1.filtersApplied(JPAContainer.java:179)
at com.vaadin.addon.jpacontainer.filter.util.AdvancedFilterableSupport.fireListeners(AdvancedFilterableSupport.java:99)
at com.vaadin.addon.jpacontainer.filter.util.AdvancedFilterableSupport.applyFilters(AdvancedFilterableSupport.java:222)
at com.vaadin.addon.jpacontainer.filter.util.AdvancedFilterableSupport.removeAllFilters(AdvancedFilterableSupport.java:275)
at com.vaadin.addon.jpacontainer.JPAContainer.removeAllContainerFilters(JPAContainer.java:984)
at org.sportunion.BenutzerView.<init>(BenutzerView.java:207)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at java.lang.Class.newInstance(Class.java:442)
at com.vaadin.navigator.Navigator$ClassBasedViewProvider.getView(Navigator.java:340)
at com.vaadin.navigator.Navigator.navigateTo(Navigator.java:559)
at org.sportunion.MainPanel.<init>(MainPanel.java:21)
at org.sportunion.LogintoStartView.<init>(LogintoStartView.java:55)
at org.sportunion.LoginView$1.buttonClick(LoginView.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:508)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:198)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161)
at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:1008)
at com.vaadin.ui.Button.fireClick(Button.java:364)
at com.vaadin.ui.Button.click(Button.java:353)
at com.vaadin.ui.Button$ClickShortcut.handleAction(Button.java:471)
at com.vaadin.event.ActionManager.handleAction(ActionManager.java:238)
at com.vaadin.event.ConnectorActionManager.handleAction(ConnectorActionManager.java:81)
at com.vaadin.event.ActionManager.handleAction(ActionManager.java:233)
at com.vaadin.event.ActionManager.handleActions(ActionManager.java:216)
at com.vaadin.ui.UI.changeVariables(UI.java:397)
at com.vaadin.server.communication.ServerRpcHandler.changeVariables(ServerRpcHandler.java:603)
at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:422)
at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:273)
at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:79)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1409)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:364)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:86)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:130)
at io.undertow.websockets.jsr.JsrWebSocketFilter.doFilter(JsrWebSocketFilter.java:151)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)
at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85)
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:72)
at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:282)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:261)
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:80)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:172)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:199)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:774)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.naming.NameNotFoundException: env/persistence/em -- service jboss.naming.context.java.module."web-0.0.1-SNAPSHOT"."web-0.0.1-SNAPSHOT".env.persistence.em
at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:106)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:207)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:184)
at org.jboss.as.naming.InitialContext$DefaultInitialContext.lookup(InitialContext.java:237)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:193)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:189)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
at com.vaadin.addon.jpacontainer.provider.jndijta.Util.getEntityManager(Util.java:31)
... 81 more
UPDATE
this is how my web-project persistence.xml looks like:
<?xml version="1.0" encoding="UTF-8"?>
<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="sportunion1">
<jta-data-source>java:/Sportunion1</jta-data-source>
<class>org.sportunion.project.domain.Admins</class>
<class>org.sportunion.project.domain.Log</class>
<class>org.sportunion.project.domain.Users</class>
<class>org.sportunion.project.domain.Nas</class>
</persistence-unit>
</persistence>
and this is how my ejb-project persistence.xml looks like:
<?xml version="1.0" encoding="UTF-8"?>
<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="ejb">
<jta-data-source>java:/Sportunion1</jta-data-source>
<properties>
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.format_sql" value="false"/>
<property name="hibernate.connection.pool_size" value="5"/>
</properties>
</persistence-unit>
</persistence>
and this is my log before the error:
2016-04-17 22:44:51,404 INFO [org.jboss.as.repository] (management-handler-thread - 41) WFLYDR0001: Content added at location C:\jboss\wildfly-9.0.2.Final\standalone\data\content\dd\2b865703eb79c7de40d506b137977cea1a84bf\content
2016-04-17 22:44:51,428 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-7) WFLYJCA0019: Stopped Driver service with driver-name = web-0.0.1-SNAPSHOT.war_com.mysql.fabric.jdbc.FabricMySQLDriver_5_1
2016-04-17 22:44:51,428 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-5) WFLYJCA0019: Stopped Driver service with driver-name = web-0.0.1-SNAPSHOT.war_com.mysql.jdbc.Driver_5_1
2016-04-17 22:44:51,428 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 191) WFLYUT0022: Unregistered web context: /web-0.0.1-SNAPSHOT
2016-04-17 22:44:51,694 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 201) WFLYJPA0011: Stopping Persistence Unit (phase 2 of 2) Service 'web-0.0.1-SNAPSHOT.war#sportunion1'
2016-04-17 22:44:51,709 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 200) WFLYJPA0011: Stopping Persistence Unit (phase 2 of 2) Service 'web-0.0.1-SNAPSHOT.war#ejb'
2016-04-17 22:44:51,725 INFO [org.jboss.weld.deployer] (MSC service thread 1-5) WFLYWELD0010: Stopping weld service for deployment web-0.0.1-SNAPSHOT.war
2016-04-17 22:44:51,725 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 200) WFLYJPA0011: Stopping Persistence Unit (phase 1 of 2) Service 'web-0.0.1-SNAPSHOT.war#sportunion1'
2016-04-17 22:44:51,725 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 201) WFLYJPA0011: Stopping Persistence Unit (phase 1 of 2) Service 'web-0.0.1-SNAPSHOT.war#ejb'
2016-04-17 22:44:52,631 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) WFLYSRV0028: Stopped deployment web-0.0.1-SNAPSHOT.war (runtime-name: web-0.0.1-SNAPSHOT.war) in 1212ms
2016-04-17 22:44:52,641 INFO [org.jboss.as.server.deployment] (MSC service thread 1-7) WFLYSRV0027: Starting deployment of "web-0.0.1-SNAPSHOT.war" (runtime-name: "web-0.0.1-SNAPSHOT.war")
2016-04-17 22:45:04,982 INFO [org.jboss.as.jpa] (MSC service thread 1-7) WFLYJPA0002: Read persistence.xml for sportunion1
2016-04-17 22:45:04,986 INFO [org.jboss.as.jpa] (MSC service thread 1-7) WFLYJPA0002: Read persistence.xml for ejb
2016-04-17 22:45:05,767 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) WFLYSRV0028: Stopped deployment web-0.0.1-SNAPSHOT.war (runtime-name: web-0.0.1-SNAPSHOT.war) in 13133ms
2016-04-17 22:45:05,783 INFO [org.jboss.as.server.deployment] (MSC service thread 1-7) WFLYSRV0027: Starting deployment of "web-0.0.1-SNAPSHOT.war" (runtime-name: "web-0.0.1-SNAPSHOT.war")
2016-04-17 22:45:13,482 INFO [org.jboss.as.jpa] (MSC service thread 1-4) WFLYJPA0002: Read persistence.xml for sportunion1
2016-04-17 22:45:13,494 INFO [org.jboss.as.jpa] (MSC service thread 1-4) WFLYJPA0002: Read persistence.xml for ejb
2016-04-17 22:45:14,057 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 204) WFLYJPA0010: Starting Persistence Unit (phase 1 of 2) Service 'web-0.0.1-SNAPSHOT.war#ejb'
2016-04-17 22:45:14,057 INFO [org.hibernate.jpa.internal.util.LogHelper] (ServerService Thread Pool -- 204) HHH000204: Processing PersistenceUnitInfo [
name: ejb
...]
2016-04-17 22:45:14,057 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 205) WFLYJPA0010: Starting Persistence Unit (phase 1 of 2) Service 'web-0.0.1-SNAPSHOT.war#sportunion1'
2016-04-17 22:45:14,073 INFO [org.hibernate.jpa.internal.util.LogHelper] (ServerService Thread Pool -- 205) HHH000204: Processing PersistenceUnitInfo [
name: sportunion1
...]
2016-04-17 22:45:14,182 INFO [org.jboss.weld.deployer] (MSC service thread 1-1) WFLYWELD0003: Processing weld deployment web-0.0.1-SNAPSHOT.war
2016-04-17 22:45:14,213 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-1) JNDI bindings for session bean named AdminsService in deployment unit deployment "web-0.0.1-SNAPSHOT.war" are as follows:
java:global/web-0.0.1-SNAPSHOT/AdminsService!org.sportunion.project.AdminsService
java:app/web-0.0.1-SNAPSHOT/AdminsService!org.sportunion.project.AdminsService
java:module/AdminsService!org.sportunion.project.AdminsService
java:global/web-0.0.1-SNAPSHOT/AdminsService
java:app/web-0.0.1-SNAPSHOT/AdminsService
java:module/AdminsService
2016-04-17 22:45:14,213 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-1) JNDI bindings for session bean named UsersService in deployment unit deployment "web-0.0.1-SNAPSHOT.war" are as follows:
java:global/web-0.0.1-SNAPSHOT/UsersService!org.sportunion.project.UsersService
java:app/web-0.0.1-SNAPSHOT/UsersService!org.sportunion.project.UsersService
java:module/UsersService!org.sportunion.project.UsersService
java:global/web-0.0.1-SNAPSHOT/UsersService
java:app/web-0.0.1-SNAPSHOT/UsersService
java:module/UsersService
2016-04-17 22:45:14,229 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-1) JNDI bindings for session bean named NasService in deployment unit deployment "web-0.0.1-SNAPSHOT.war" are as follows:
java:global/web-0.0.1-SNAPSHOT/NasService!org.sportunion.project.NasService
java:app/web-0.0.1-SNAPSHOT/NasService!org.sportunion.project.NasService
java:module/NasService!org.sportunion.project.NasService
java:global/web-0.0.1-SNAPSHOT/NasService
java:app/web-0.0.1-SNAPSHOT/NasService
java:module/NasService
2016-04-17 22:45:14,229 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-1) JNDI bindings for session bean named LogService in deployment unit deployment "web-0.0.1-SNAPSHOT.war" are as follows:
java:global/web-0.0.1-SNAPSHOT/LogService!org.sportunion.project.LogService
java:app/web-0.0.1-SNAPSHOT/LogService!org.sportunion.project.LogService
java:module/LogService!org.sportunion.project.LogService
java:global/web-0.0.1-SNAPSHOT/LogService
java:app/web-0.0.1-SNAPSHOT/LogService
java:module/LogService
2016-04-17 22:45:14,791 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) WFLYJCA0005: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
2016-04-17 22:45:14,798 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) WFLYJCA0005: Deploying non-JDBC-compliant driver class com.mysql.fabric.jdbc.FabricMySQLDriver (version 5.1)
2016-04-17 22:45:14,798 INFO [org.jboss.weld.deployer] (MSC service thread 1-4) WFLYWELD0006: Starting Services for CDI deployment: web-0.0.1-SNAPSHOT.war
2016-04-17 22:45:14,814 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-2) WFLYJCA0018: Started Driver service with driver-name = web-0.0.1-SNAPSHOT.war_com.mysql.jdbc.Driver_5_1
2016-04-17 22:45:14,814 INFO [org.jboss.weld.deployer] (MSC service thread 1-2) WFLYWELD0009: Starting weld service for deployment web-0.0.1-SNAPSHOT.war
2016-04-17 22:45:14,814 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-8) WFLYJCA0018: Started Driver service with driver-name = web-0.0.1-SNAPSHOT.war_com.mysql.fabric.jdbc.FabricMySQLDriver_5_1
2016-04-17 22:45:14,892 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 204) WFLYJPA0010: Starting Persistence Unit (phase 2 of 2) Service 'web-0.0.1-SNAPSHOT.war#ejb'
2016-04-17 22:45:14,908 INFO [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 204) HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2016-04-17 22:45:14,939 INFO [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (ServerService Thread Pool -- 204) HHH000397: Using ASTQueryTranslatorFactory
2016-04-17 22:45:15,033 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 206) WFLYJPA0010: Starting Persistence Unit (phase 2 of 2) Service 'web-0.0.1-SNAPSHOT.war#sportunion1'
2016-04-17 22:45:15,064 INFO [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 206) HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2016-04-17 22:45:15,080 INFO [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (ServerService Thread Pool -- 206) HHH000397: Using ASTQueryTranslatorFactory
2016-04-17 22:45:15,924 INFO [io.undertow.servlet] (ServerService Thread Pool -- 208) Initializing AtmosphereFramework
2016-04-17 22:45:16,047 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) Installed AtmosphereHandler com.vaadin.server.communication.PushAtmosphereHandler mapped to context-path: /*
2016-04-17 22:45:16,047 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) Installed the following AtmosphereInterceptor mapped to AtmosphereHandler com.vaadin.server.communication.PushAtmosphereHandler
2016-04-17 22:45:16,063 INFO [org.atmosphere.util.IOUtils] (ServerService Thread Pool -- 208) META-INF/services/org.atmosphere.cpr.AtmosphereFramework not found in class loader
2016-04-17 22:45:16,110 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) Atmosphere is using org.atmosphere.util.VoidAnnotationProcessor for processing annotation
2016-04-17 22:45:16,141 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) Installed WebSocketProtocol org.atmosphere.websocket.protocol.SimpleHttpProtocol
2016-04-17 22:45:16,172 INFO [org.atmosphere.container.JSR356AsyncSupport] (ServerService Thread Pool -- 208) JSR 356 Mapping path /{path}
2016-04-17 22:45:16,172 INFO [io.undertow.websockets.jsr] (ServerService Thread Pool -- 208) UT026005: Adding programmatic server endpoint class org.atmosphere.container.JSR356Endpoint for path /{path}
2016-04-17 22:45:16,172 INFO [io.undertow.websockets.jsr] (ServerService Thread Pool -- 208) UT026005: Adding programmatic server endpoint class org.atmosphere.container.JSR356Endpoint for path /{path}/{path0}
2016-04-17 22:45:16,172 INFO [io.undertow.websockets.jsr] (ServerService Thread Pool -- 208) UT026005: Adding programmatic server endpoint class org.atmosphere.container.JSR356Endpoint for path /{path}/{path0}/{path1}
2016-04-17 22:45:16,172 INFO [io.undertow.websockets.jsr] (ServerService Thread Pool -- 208) UT026005: Adding programmatic server endpoint class org.atmosphere.container.JSR356Endpoint for path /{path}/{path0}/{path1}/{path2}
2016-04-17 22:45:16,172 INFO [io.undertow.websockets.jsr] (ServerService Thread Pool -- 208) UT026005: Adding programmatic server endpoint class org.atmosphere.container.JSR356Endpoint for path /{path}/{path0}/{path1}/{path2}/{path3}
2016-04-17 22:45:16,172 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) Installing Default AtmosphereInterceptors
2016-04-17 22:45:16,172 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) org.atmosphere.interceptor.CorsInterceptor : CORS Interceptor Support
2016-04-17 22:45:16,188 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) org.atmosphere.interceptor.CacheHeadersInterceptor : Default Response's Headers Interceptor
2016-04-17 22:45:16,188 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) org.atmosphere.interceptor.PaddingAtmosphereInterceptor : Browser Padding Interceptor Support
2016-04-17 22:45:16,188 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) org.atmosphere.interceptor.AndroidAtmosphereInterceptor : Android Interceptor Support
2016-04-17 22:45:16,188 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) Dropping Interceptor org.atmosphere.interceptor.HeartbeatInterceptor
2016-04-17 22:45:16,188 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) org.atmosphere.interceptor.SSEAtmosphereInterceptor : SSE Interceptor Support
2016-04-17 22:45:16,188 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) org.atmosphere.interceptor.JSONPAtmosphereInterceptor : JSONP Interceptor Support
2016-04-17 22:45:16,204 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) org.atmosphere.interceptor.JavaScriptProtocol : Atmosphere JavaScript Protocol
2016-04-17 22:45:16,204 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) org.atmosphere.interceptor.WebSocketMessageSuspendInterceptor : org.atmosphere.interceptor.WebSocketMessageSuspendInterceptor
2016-04-17 22:45:16,204 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) org.atmosphere.interceptor.OnDisconnectInterceptor : Browser disconnection detection
2016-04-17 22:45:16,204 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) org.atmosphere.interceptor.IdleResourceInterceptor : org.atmosphere.interceptor.IdleResourceInterceptor
2016-04-17 22:45:16,204 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) Set org.atmosphere.cpr.AtmosphereInterceptor.disableDefaults to disable them.
2016-04-17 22:45:16,204 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) Using EndpointMapper class org.atmosphere.util.DefaultEndpointMapper
2016-04-17 22:45:16,204 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) Using BroadcasterCache: org.atmosphere.cache.UUIDBroadcasterCache
2016-04-17 22:45:16,204 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) Default Broadcaster Class: org.atmosphere.cpr.DefaultBroadcaster
2016-04-17 22:45:16,219 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) Broadcaster Polling Wait Time 100
2016-04-17 22:45:16,219 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) Shared ExecutorService supported: true
2016-04-17 22:45:16,219 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) Messaging Thread Pool Size: Unlimited
2016-04-17 22:45:16,219 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) Async I/O Thread Pool Size: 200
2016-04-17 22:45:16,219 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) Using BroadcasterFactory: org.atmosphere.cpr.DefaultBroadcasterFactory
2016-04-17 22:45:16,219 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) Using WebSocketProcessor: org.atmosphere.websocket.DefaultWebSocketProcessor
2016-04-17 22:45:16,235 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) Invoke AtmosphereInterceptor on WebSocket message true
2016-04-17 22:45:16,235 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) HttpSession supported: true
2016-04-17 22:45:16,235 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) Atmosphere is using DefaultAtmosphereObjectFactory for dependency injection and object creation
2016-04-17 22:45:16,235 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) Atmosphere is using async support: org.atmosphere.container.JSR356AsyncSupport running under container: WildFly 1.0.2.Final - 1.2.9.Final using javax.servlet/3.0 and jsr356/WebSocket API
2016-04-17 22:45:16,235 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) Atmosphere Framework 2.2.7.vaadin1 started.
2016-04-17 22:45:16,235 INFO [org.atmosphere.cpr.AtmosphereFramework] (ServerService Thread Pool -- 208) Installed AtmosphereInterceptor Track Message Size Interceptor using | with priority BEFORE_DEFAULT
2016-04-17 22:45:16,250 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 208) WFLYUT0021: Registered web context: /web-0.0.1-SNAPSHOT
2016-04-17 22:45:16,391 INFO [org.jboss.as.server] (management-handler-thread - 41) WFLYSRV0013: Redeployed "web-0.0.1-SNAPSHOT.war"
2016-04-17 22:45:16,391 INFO [org.jboss.as.server] (management-handler-thread - 41) WFLYSRV0016: Replaced deployment "web-0.0.1-SNAPSHOT.war" with deployment "web-0.0.1-SNAPSHOT.war"
2016-04-17 22:45:16,407 INFO [org.jboss.as.repository] (management-handler-thread - 41) WFLYDR0002: Content removed from location C:\jboss\wildfly-9.0.2.Final\standalone\data\content\cf\25dce1c34f9d240c649dd8fe101db0b3929e9b\content
and here a picture of my project structure:
Since monday the error occurs, that the data schema is no longer exported correctly. The database tables are not created, even though there are no errors visible in the console log. This error also occures in earlier versions that ran perfectly fine before monday. Also newly created projects with maven have the same problem.
Furthermore, I installed the local WildFly server anew and also tried older versions (WildFly 8.x and 9.x).
The database in use is a mySQL database, but I also tried with other database types like H2 without any success.
The persistence.xml is as follows:
<persistence-unit name="primary">
<jta-data-source>java:jboss/datasources/chargingTransactionWarehouse</jta-data-source>
<properties>
<property name="hibernate.archive.autodetection" value="class, hbm"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.globally_quoted_identifiers" value="true" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
</properties>
</persistence-unit>
The console output:
19:09:30,499 INFO [org.jboss.modules] (main) JBoss Modules version 1.4.3.Final
19:09:30,705 INFO [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final
19:09:30,781 INFO [org.jboss.as] (MSC service thread 1-6) WFLYSRV0049: WildFly Full 9.0.2.Final (WildFly Core 1.0.2.Final) starting
19:09:31,946 INFO [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 21) WFLYCTL0028: Attribute 'job-repository-type' in the resource at address '/subsystem=batch' is deprecated, and may be removed in future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
19:09:31,954 INFO [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 7) WFLYCTL0028: Attribute 'enabled' in the resource at address '/subsystem=datasources/data-source=ExampleDS' is deprecated, and may be removed in future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
19:09:31,968 INFO [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 7) WFLYCTL0028: Attribute 'enabled' in the resource at address '/subsystem=datasources/data-source=java:jboss/datasources/chargingTransactionWarehouse' is deprecated, and may be removed in future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
19:09:31,969 INFO [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 7) WFLYCTL0028: Attribute 'enabled' in the resource at address '/subsystem=datasources/data-source=java:jboss/datasources/ChargingTransactionWarehouse' is deprecated, and may be removed in future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
19:09:31,972 INFO [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 7) WFLYCTL0028: Attribute 'enabled' in the resource at address '/subsystem=datasources/data-source=CrowdStrom' is deprecated, and may be removed in future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
19:09:31,992 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) WFLYDS0004: Found chargingTransactionWarehouse.war in deployment directory. To trigger deployment create a file called chargingTransactionWarehouse.war.dodeploy
19:09:32,026 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
19:09:32,064 INFO [org.xnio] (MSC service thread 1-6) XNIO version 3.3.1.Final
19:09:32,073 INFO [org.xnio.nio] (MSC service thread 1-6) XNIO NIO Implementation Version 3.3.1.Final
19:09:32,127 INFO [org.jboss.as.jsf] (ServerService Thread Pool -- 44) WFLYJSF0007: Activated the following JSF Implementations: [main]
19:09:32,143 INFO [org.wildfly.extension.io] (ServerService Thread Pool -- 37) WFLYIO001: Worker 'default' has auto-configured to 8 core threads with 64 task threads based on your 4 available processors
19:09:32,146 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 38) WFLYCLINF0001: Activating Infinispan subsystem.
19:09:32,149 WARN [org.jboss.as.txn] (ServerService Thread Pool -- 54) WFLYTX0013: Node identifier property is set to the default value. Please make sure it is unique.
19:09:32,151 INFO [org.jboss.as.security] (ServerService Thread Pool -- 53) WFLYSEC0002: Activating Security Subsystem
19:09:32,152 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 56) WFLYWS0002: Activating WebServices Extension
19:09:32,161 INFO [org.jboss.as.security] (MSC service thread 1-8) WFLYSEC0001: Current PicketBox version=4.9.2.Final
19:09:32,186 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 46) WFLYNAM0001: Activating Naming Subsystem
19:09:32,215 INFO [org.jboss.as.connector] (MSC service thread 1-2) WFLYJCA0009: Starting JCA Subsystem (IronJacamar 1.2.5.Final)
19:09:32,253 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 33) WFLYJCA0004: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
19:09:32,265 INFO [org.jboss.as.mail.extension] (MSC service thread 1-4) WFLYMAIL0001: Bound mail session [java:jboss/mail/Default]
19:09:32,267 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) WFLYJCA0018: Started Driver service with driver-name = h2
19:09:32,275 INFO [org.jboss.as.naming] (MSC service thread 1-2) WFLYNAM0003: Starting Naming Service
19:09:32,274 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0003: Undertow 1.2.9.Final starting
19:09:32,294 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 55) WFLYUT0003: Undertow 1.2.9.Final starting
19:09:32,748 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 55) WFLYUT0014: Creating file handler for path C:\Users\crowdstrom\wildfly-9.0.2.Final/welcome-content
19:09:32,758 INFO [org.jboss.remoting] (MSC service thread 1-6) JBoss Remoting version 4.0.9.Final
19:09:32,784 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0012: Started server default-server.
19:09:32,835 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0018: Host default-host starting
19:09:32,989 INFO [org.wildfly.extension.undertow] (MSC service thread 1-6) WFLYUT0006: Undertow HTTP listener default listening on localhost/127.0.0.1:8080
19:09:33,102 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-4) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
19:09:33,192 INFO [org.jboss.as.server.deployment] (MSC service thread 1-7) WFLYSRV0027: Starting deployment of "mysql-connector-java-5.1.38-bin.jar" (runtime-name: "mysql-connector-java-5.1.38-bin.jar")
19:09:33,192 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) WFLYSRV0027: Starting deployment of "chargingTransactionWarehouse.war" (runtime-name: "chargingTransactionWarehouse.war")
19:09:33,244 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-1) WFLYDS0013: Started FileSystemDeploymentService for directory C:\Users\crowdstrom\wildfly-9.0.2.Final\standalone\deployments
19:09:33,431 INFO [org.jboss.ws.common.management] (MSC service thread 1-8) JBWS022052: Starting JBoss Web Services - Stack CXF Server 5.0.0.Final
19:09:33,617 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-7) WFLYJCA0005: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
19:09:33,619 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-7) WFLYJCA0005: Deploying non-JDBC-compliant driver class com.mysql.fabric.jdbc.FabricMySQLDriver (version 5.1)
19:09:33,640 INFO [org.jboss.as.jpa] (MSC service thread 1-8) WFLYJPA0002: Read persistence.xml for primary
19:09:33,642 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-8) WFLYJCA0018: Started Driver service with driver-name = mysql-connector-java-5.1.38-bin.jar_com.mysql.fabric.jdbc.FabricMySQLDriver_5_1
19:09:33,647 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-8) WFLYJCA0018: Started Driver service with driver-name = mysql-connector-java-5.1.38-bin.jar_com.mysql.jdbc.Driver_5_1
19:09:33,660 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-8) WFLYJCA0001: Bound data source [java:jboss/datasources/ChargingTransactionWarehouse]
19:09:33,661 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-8) WFLYJCA0001: Bound data source [java:jboss/datasources/CrowdStrom]
19:09:33,661 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-8) WFLYJCA0001: Bound data source [java:jboss/datasources/chargingTransactionWarehouse]
19:09:33,699 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 58) WFLYJPA0010: Starting Persistence Unit (phase 1 of 2) Service 'chargingTransactionWarehouse.war#primary'
19:09:33,722 INFO [org.hibernate.jpa.internal.util.LogHelper] (ServerService Thread Pool -- 58) HHH000204: Processing PersistenceUnitInfo [
name: primary
...]
19:09:33,725 INFO [org.jboss.weld.deployer] (MSC service thread 1-8) WFLYWELD0003: Processing weld deployment chargingTransactionWarehouse.war
19:09:33,787 INFO [org.hibernate.Version] (ServerService Thread Pool -- 58) HHH000412: Hibernate Core {4.3.10.Final}
19:09:33,790 INFO [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 58) HHH000206: hibernate.properties not found
19:09:33,792 INFO [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 58) HHH000021: Bytecode provider name : javassist
19:09:33,809 INFO [org.hibernate.validator.internal.util.Version] (MSC service thread 1-8) HV000001: Hibernate Validator 5.1.3.Final
19:09:34,043 INFO [org.jboss.weld.deployer] (MSC service thread 1-8) WFLYWELD0006: Starting Services for CDI deployment: chargingTransactionWarehouse.war
19:09:34,081 INFO [org.jboss.weld.Version] (MSC service thread 1-8) WELD-000900: 2.2.16 (SP1)
19:09:34,105 INFO [org.jboss.weld.deployer] (MSC service thread 1-7) WFLYWELD0009: Starting weld service for deployment chargingTransactionWarehouse.war
19:09:34,531 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 58) WFLYJPA0010: Starting Persistence Unit (phase 2 of 2) Service 'chargingTransactionWarehouse.war#primary'
19:09:34,599 INFO [org.hibernate.annotations.common.Version] (ServerService Thread Pool -- 58) HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
19:09:34,946 INFO [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 58) HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
19:09:34,983 INFO [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (ServerService Thread Pool -- 58) HHH000397: Using ASTQueryTranslatorFactory
19:09:35,097 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 58) HHH000227: Running hbm2ddl schema export
19:09:35,103 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 58) HHH000230: Schema export complete
19:09:35,812 INFO [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 61) Mojarra 2.2.12-jbossorg-2 20150729-1131 für Kontext '/chargingTransactionWarehouse' wird initialisiert.
19:09:36,351 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 61) WFLYUT0021: Registered web context: /chargingTransactionWarehouse
19:09:36,408 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0010: Deployed "mysql-connector-java-5.1.38-bin.jar" (runtime-name : "mysql-connector-java-5.1.38-bin.jar")
19:09:36,408 INFO [org.jboss.as.server] (ServerService Thread Pool -- 34) WFLYSRV0010: Deployed "chargingTransactionWarehouse.war" (runtime-name : "chargingTransactionWarehouse.war")
19:09:36,835 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
19:09:36,836 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
19:09:36,836 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 9.0.2.Final (WildFly Core 1.0.2.Final) started in 6618ms - Started 350 of 536 services (229 services are lazy, passive or on-demand)
I would be grateful for any helpful answer
King regards
EDIT:
I also tried to use the <class> tags as well as trying different mySQL dialects.
Found the error!
Due to the new JVM version, the actual error was not posted and the server was started. By installing the previous JVM version, the server failed to start and the chargingTransactionWarehouse.war.failure showed that there was a mapping error...
I am trying to setup a simple project, where I have a REST service query a database using JPA/Hibernate. My platform is Windows, MySQL 5.6, and JBoss (Wildfly) 8 with hibernate 4.3. My project setup:
PersonApp (Eclipse Java Enterprise Project) >PersonApp.ear
-PersonData (Eclipse JPA Project) >PersonData.jar
-PersonRest (Eclipse Dynamic Web Project) >PersonRest.war
PersonData project contains 1 entity class (Person.java), a manager class for peforming the em.find and em.persist through EntityManager (PersonManager.java), and persistance.xml
PersonRest project contains one REST service, with one GET method, which calls the PersonManager class to query all Persons.
PersonApp is just a container project which includes PersonData and PersonRest as modules.
Now for the issue: I deploy PersonApp.ear to Wildfly 8 (JBoss), and navigate to the service URL in a web browser. PersonRest service calls PersonManager class, which calls Persistence.createEntityManagerFactor("PersonData"); This line returns 'null' and I have no idea why.
persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" 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_1.xsd">
<persistence-unit name="PersonData" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>java:jboss/datasources/MySqlDS</jta-data-source>
<class>com.csc.data.Person</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
</properties>
</persistence-unit>
</persistence>
Wildfly startup output (shows app deployment, data source loaded, persistence unit):
14:31:14,607 INFO [org.jboss.modules] (main) JBoss Modules version 1.3.0.Final
14:31:14,841 INFO [org.jboss.msc] (main) JBoss MSC version 1.2.0.Final
14:31:14,919 INFO [org.jboss.as] (MSC service thread 1-6) JBAS015899: WildFly 8.0.0.Final "WildFly" starting
14:31:15,871 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found PersonApp.ear in deployment directory. To trigger deployment create a file called PersonApp.ear.dodeploy
14:31:15,887 INFO [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http)
14:31:15,903 INFO [org.xnio] (MSC service thread 1-8) XNIO version 3.2.0.Final
14:31:15,919 INFO [org.xnio.nio] (MSC service thread 1-8) XNIO NIO Implementation Version 3.2.0.Final
14:31:15,934 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 33) JBAS010280: Activating Infinispan subsystem.
14:31:15,950 INFO [org.jboss.as.security] (ServerService Thread Pool -- 46) JBAS013171: Activating Security Subsystem
14:31:15,966 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 50) JBAS015537: Activating WebServices Extension
14:31:15,997 INFO [org.wildfly.extension.undertow] (MSC service thread 1-6) JBAS017502: Undertow 1.0.0.Final starting
14:31:15,997 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 49) JBAS017502: Undertow 1.0.0.Final starting
14:31:15,997 INFO [org.jboss.as.security] (MSC service thread 1-2) JBAS013170: Current PicketBox version=4.0.20.Final
14:31:15,997 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 41) JBAS011800: Activating Naming Subsystem
14:31:15,997 INFO [org.jboss.as.jsf] (ServerService Thread Pool -- 39) JBAS012615: Activated the following JSF Implementations: [main]
14:31:16,028 INFO [org.jboss.as.connector.logging] (MSC service thread 1-5) JBAS010408: Starting JCA Subsystem (IronJacamar 1.1.3.Final)
14:31:16,075 INFO [org.jboss.as.naming] (MSC service thread 1-5) JBAS011802: Starting Naming Service
14:31:16,075 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 28) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
14:31:16,090 INFO [org.jboss.as.mail.extension] (MSC service thread 1-6) JBAS015400: Bound mail session [java:jboss/mail/Default]
14:31:16,106 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 28) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
14:31:16,106 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) JBAS010417: Started Driver service with driver-name = h2
14:31:16,106 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) JBAS010417: Started Driver service with driver-name = com.mysql
14:31:16,184 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 49) JBAS017527: Creating file handler for path C:\wildfly-8.0.0.Final/welcome-content
14:31:16,200 INFO [org.jboss.remoting] (MSC service thread 1-1) JBoss Remoting version 4.0.0.Final
14:31:16,434 INFO [org.wildfly.extension.undertow] (MSC service thread 1-2) JBAS017525: Started server default-server.
14:31:16,543 INFO [org.wildfly.extension.undertow] (MSC service thread 1-2) JBAS017531: Host default-host starting
14:31:16,605 INFO [org.wildfly.extension.undertow] (MSC service thread 1-6) JBAS017519: Undertow HTTP listener default listening on localhost/127.0.0.1:8080
14:31:16,652 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-4) JBAS010400: Bound data source [java:jboss/datasources/MySqlDS]
14:31:16,730 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "PersonApp.ear" (runtime-name: "PersonApp.ear")
14:31:16,746 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-7) JBAS015012: Started FileSystemDeploymentService for directory C:\wildfly-8.0.0.Final\standalone\deployments
14:31:16,761 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-7) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
14:31:16,824 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015876: Starting deployment of "null" (runtime-name: "PersonRest.war")
14:31:16,855 INFO [org.jboss.ws.common.management] (MSC service thread 1-6) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.2.3.Final
14:31:16,870 INFO [org.jboss.as.jpa] (MSC service thread 1-3) JBAS011401: Read persistence.xml for PersonData
14:31:16,933 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 52) JBAS011409: Starting Persistence Unit (phase 1 of 2) Service 'PersonApp.ear#PersonData'
14:31:16,948 INFO [org.hibernate.jpa.internal.util.LogHelper] (ServerService Thread Pool -- 52) HHH000204: Processing PersistenceUnitInfo [
name: PersonData
...]
14:31:16,996 INFO [org.hibernate.Version] (ServerService Thread Pool -- 52) HHH000412: Hibernate Core {4.3.1.Final}
14:31:17,012 INFO [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 52) HHH000206: hibernate.properties not found
14:31:17,012 INFO [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 52) HHH000021: Bytecode provider name : javassist
14:31:17,152 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 52) JBAS011409: Starting Persistence Unit (phase 2 of 2) Service 'PersonApp.ear#PersonData'
14:31:17,277 INFO [org.hibernate.annotations.common.Version] (ServerService Thread Pool -- 52) HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
14:31:17,511 INFO [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 52) HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
14:31:17,589 INFO [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (ServerService Thread Pool -- 52) HHH000397: Using ASTQueryTranslatorFactory
14:31:17,620 INFO [org.hibernate.validator.internal.util.Version] (ServerService Thread Pool -- 52) HV000001: Hibernate Validator 5.0.3.Final
14:31:17,885 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 52) HHH000227: Running hbm2ddl schema export
14:31:17,932 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 52) HHH000230: Schema export complete
14:31:18,197 INFO [org.jboss.resteasy.spi.ResteasyDeployment] (MSC service thread 1-2) Deploying javax.ws.rs.core.Application: class com.csc.rest.service.PersonRest
14:31:18,197 INFO [org.jboss.resteasy.spi.ResteasyDeployment] (MSC service thread 1-2) Adding singleton resource com.csc.rest.service.PersonService from Application class com.csc.rest.service.PersonRest
14:31:18,323 INFO [org.wildfly.extension.undertow] (MSC service thread 1-2) JBAS017534: Registered web context: /PersonRest
14:31:18,370 INFO [org.jboss.as.server] (ServerService Thread Pool -- 29) JBAS018559: Deployed "PersonApp.ear" (runtime-name : "PersonApp.ear")
14:31:18,417 INFO [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management
14:31:18,417 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
14:31:18,417 INFO [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.0.0.Final "WildFly" started in 4059ms - Started 291 of 351 services (98 services are lazy, passive or on-demand)
Wildfly output on REST service call:
14:32:06,221 INFO [org.hibernate.jpa.internal.util.LogHelper] (default task-2) HHH000204: Processing PersistenceUnitInfo [
name: PersonData
...]
14:32:06,236 INFO [org.hibernate.dialect.Dialect] (default task-2) HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
14:32:06,236 INFO [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (default task-2) HHH000397: Using ASTQueryTranslatorFactory
14:32:06,252 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] (default task-2) HHH000227: Running hbm2ddl schema export
14:32:06,268 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] (default task-2) HHH000230: Schema export complete
14:32:06,300 ERROR [io.undertow.request] (default task-2) UT005023: Exception handling request to /PersonRest/PersonService: org.jboss.resteasy.spi.UnhandledException: java.lang.NullPointerException
at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:76) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:212) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:149) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:372) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51) [resteasy-jaxrs-3.0.6.Final.jar:]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61) [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.0.Final.jar:1.0.0.Final]
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:113) [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
at io.undertow.security.handlers.AuthenticationCallHandler.handleRequest(AuthenticationCallHandler.java:52) [undertow-core-1.0.0.Final.jar:1.0.0.Final]
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45) [undertow-core-1.0.0.Final.jar:1.0.0.Final]
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:61) [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) [undertow-core-1.0.0.Final.jar:1.0.0.Final]
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.0.Final.jar:1.0.0.Final]
at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.0.Final.jar:1.0.0.Final]
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.0.Final.jar:1.0.0.Final]
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:240) [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227) [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73) [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146) [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:168) [undertow-core-1.0.0.Final.jar:1.0.0.Final]
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:687) [undertow-core-1.0.0.Final.jar:1.0.0.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_51]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_51]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_51]
Caused by: java.lang.NullPointerException
at org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.getStatus(JtaStatusHelper.java:76) [hibernate-core-4.3.1.Final.jar:4.3.1.Final]
at org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.isActive(JtaStatusHelper.java:118) [hibernate-core-4.3.1.Final.jar:4.3.1.Final]
at org.hibernate.engine.transaction.internal.jta.CMTTransaction.join(CMTTransaction.java:149) [hibernate-core-4.3.1.Final.jar:4.3.1.Final]
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:1602) [hibernate-entitymanager-4.3.1.Final.jar:4.3.1.Final]
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.postInit(AbstractEntityManagerImpl.java:210) [hibernate-entitymanager-4.3.1.Final.jar:4.3.1.Final]
at org.hibernate.jpa.internal.EntityManagerImpl.<init>(EntityManagerImpl.java:91) [hibernate-entitymanager-4.3.1.Final.jar:4.3.1.Final]
at org.hibernate.jpa.internal.EntityManagerFactoryImpl.internalCreateEntityManager(EntityManagerFactoryImpl.java:345) [hibernate-entitymanager-4.3.1.Final.jar:4.3.1.Final]
at org.hibernate.jpa.internal.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:313) [hibernate-entitymanager-4.3.1.Final.jar:4.3.1.Final]
at com.csc.data.PersonManager.openConnection(PersonManager.java:51) [PersonData.jar:]
at com.csc.rest.service.PersonService.getAllPersons(PersonService.java:21) [classes:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_51]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_51]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_51]
at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_51]
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:137) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:280) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:234) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:221) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:356) [resteasy-jaxrs-3.0.6.Final.jar:]
... 29 more
It looks like Wildfly is able to find persistance.xml, and it is able to connect to the MySQL database (it even drops the table data as expected). It shows in the output that it found the persistence unit PersonData. I even tried changing the provider to something off the wall just to see if it would error. It did error saying it couldn't find the provider class. I changed it back and the error went away, so I assume it is able to find the provider. What am I missing?
I found the solution. In my REST service, I was instantiating the PersonManager class myself. Instead, I needed to inject it with #Inject. After this, it worked, almost. I then had a problem getting CDI to work inside a RESTeasy REST service, but that was a separate issue. More details can be found here in my JBoss community thread: https://community.jboss.org/message/863014#863014