Error inserting second datasource with GenericDAO - java

Error inserting second datasource with GenericDAO
I'm trying to insert a second base in persistence.xml. I have already configured the datasource in jboss and tested it. When inserting a second persistence-unit in xml and attempting to raise jboss the error below occurs. I tried to set in each DAO class #PersistenceContext(unitName = "unit-name") and #PersistenceUnit, but to no avail. I tried to follow some tutorials, but I did not understand how to fit step by step in my context, nor do I know if this is the case.
I want to know how to configure for my case, I think the biggest difference is that I have an EntityManager coming from a GenericDAO and this is making it difficult for me to understand. If I have to annotate something else in DAOs or entities, what if I have to create another abstract class?
Erro:
The persistent unitName has not been specified and there are
persistent drive definitions 2 in the deployment of the deployment
application "intranet.war". You can either change the deployment of
the application to only have one definition of the persistence unit or
specify the unitName for each reference of a persistence unit.
17: 37: 11,411 INFO [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0006: Undertow HTTP listener default listening on 127.0.0.1:8080
17: 37: 11,491 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) WFLYJCA0001: Data source limit [java: jboss / datasources / ExampleDS]
17: 37: 11,492 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) WFLYJCA0001: Data source limit [java: jboss / datasources / intraDS]
17: 37: 11,491 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-8) WFLYJCA0001: Data source limit [java: jboss / datasources / intrasis]
17: 37: 11,524 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-4) WFLYDS0013: The FileSystemDeploymentService has been started for the directory C: \ Users \ vinicius.cipolli \ Devlopment \ jboss-eap -7.0 \ standalone \ deployments
17: 37: 11,528 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) WFLYSRV0027: c "intranet.war" (runtime-name: "intranet.war")
17: 37: 11,621 INFO [org.infinfin.factories.GlobalComponentRegistry] (MSC service thread 1-8) ISPN000128: Infinispan version: Infinispan 'Mahou' 8.1.2.Final-redhat-1
JBWS022052: Starting JBossWS 5.1.3.SP1-redhat-1 (Apache CXF 3.1.4.redhat-1) 17:37:11,661 INFO [org.jboss.ws.common.management] (MSC service thread 1-6)
17: 37: 12,706 INFO [org.jboss.as.jpa] (MSC service thread 1-5) WFLYJPA0002: Read the persistence.xml for intranet
17: 37: 12,707 INFO [org.jboss.as.jpa] (MSC service thread 1-5) WFLYJPA0002: Read the persistence.xml for intrasis
17: 37: 12,708 WARN [org.jboss.as.ee] (MSC service thread 1-5) WFLYEE0065: Invalid signature for method init annotated with javax.annotation.PostConstruct in br.sp.corpedu.intranet.domain .acod.service.EspecialityService class. The signature must be 'void methodName (InvocationContext ctx)'
17: 37: 12,709 WARN [org.jboss.as.ee] (MSC service thread 1-5) WFLYEE0065: Invalid signature for method init annotated with javax.annotation.PostConstruct in br.sp.corpedu.intranet.expose .resources.CourseResource class. The signature must be 'void methodName (InvocationContext ctx)'
17: 37: 12,709 WARN [org.jboss.as.ee] (MSC service thread 1-5) WFLYEE0065: Invalid signature for method init annotated with javax.annotation.PostConstruct in br.sp.corpedu.intranet.expose .resources.ResourceSpeciality of the class. The signature must be 'void methodName (InvocationContext ctx)'
17: 37: 12,709 WARN [org.jboss.as.ee] (MSC service thread 1-5) WFLYEE0065: Invalid signature for method init annotated with javax.annotation.PostConstruct in br.sp.corpedu.intranet.expose .resources.esto.ItemResource of the class. The signature must be 'void methodName (InvocationContext ctx)'
17: 37: 12,719 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.unit. "Intranet.war" .DEPENDENCIES: org.jboss.msc .service.StartException in service jboss.deployment.unit. "intranet.war" .DEPENDENCIES: WFLYSRV0153: Failed to process DEPENDENCIES phase of deployment "intranet.war"
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start (DeploymentUnitPhaseService.java:154)
    at org.jboss.msc.service.ServiceControllerImpl $ StartTask.startService (ServiceControllerImpl.java:1948)
    at org.jboss.msc.service.ServiceControllerImpl $ StartTask.run (ServiceControllerImpl.java:1881)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor $ Worker.run (ThreadPoolExecutor.java:624)
    at java.lang.Thread.run (Thread.java:748)
Caused by: java.lang.IllegalArgumentException: WFLYJPA0061: The persistent unitName has not been specified and there are persistent drive definitions 2 in the deployment of the deployment application "intranet.war". You can either change the deployment of the application to only have one definition of the persistence unit or specify the unitName for each reference of the persistence unit.
    at org.jboss.as.jpa.container.PersistenceUnitSearch.ambiguousPUError (PersistenceUnitSearch.java:187)
    at org.jboss.as.jpa.container.PersistenceUnitSearch.findWithinDeployment (PersistenceUnitSearch.java:153)
    at org.jboss.as.jpa.container.PersistenceUnitSearch.findPersistenceUnitSupplier (PersistenceUnitSearch.java:75)
    at org.jboss.as.jpa.container.PersistenceUnitSearch.resolvePersistenceUnitSupplier (PersistenceUnitSearch.java:64)
    at org.jboss.as.jpa.processor.JPAAnnotationProcessor.getPersistenceUnit (JPAAnnotationProcessor.java:372)
    at org.jboss.as.jpa.processor.JPAAnnotationProcessor.getBindingSource (JPAAnnotationProcessor.java:296)
    at org.jboss.as.jpa.processor.JPAAnnotationProcessor.processField (JPAAnnotationProcessor.java:171)
    at org.jboss.as.jpa.processor.JPAAnnotationProcessor.processPersistenceAnnotations (JPAAnnotationProcessor.java:138)
    at org.jboss.as.jpa.processor.JPAAnnotationProcessor.deploy (JPAAnnotationProcessor.java:100)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start (DeploymentUnitPhaseService.java:147)
        ... more
    
 
    17:37:12:17 ERROR [org.jboss.as.controller.management-operation]
     (Controller Boot Thread) WFLYCTL0013: Deploy Failure -
     address ([("deployment" = "intranet.war"])) - failure to describe:
     {"WFLYCTL0080: Service Failure" =
     {"jboss.deployment.unit. \" intranet.war \ "DEPENDENCIES" =
     "org.jboss.msc.service.StartException in service
     jboss.deployment.unit. \ "intranet.war \" DEPENDENCIES: WFLYSRV0153:
     Failed to process DEPENDENCIES phase of deployment \ "intranet.war \"
         Caused by: java.lang.IllegalArgumentException: WFLYJPA0061: The persisted unitName has not been specified and there are
    Persistent Drive 2 in Deployment Deployment
    \ "intranet.war \". You can either change the application deployment
    to have only one
    specify the unit for each reference of a unit of
    persistence. "}} 17: 37: 12,752 INFO [org.jboss.as.server]` enter code here`
    (ServerService Thread Pool - 34) WFLYSRV0010: Deployed
    "intranet.war" (runtime-name: "intranet.war")
The persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
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">
<persistence-unit name="intranet" transaction-type="JTA">
<jta-data-source>java:jboss/datasources/intraDS</jta-data-source>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="none" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="false" />
</properties>
</persistence-unit>
<persistence-unit name="intrasis" transaction-type="JTA">
<jta-data-source>java:jboss/datasources/intrasis</jta-data-source>
<properties>
<property name="hibernate.hbm2ddl.auto" value="none" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="false" />
</properties>
</persistence-unit>
</persistence>
The GenericDAO class
public abstract class GenericDAO<T> implements Serializable {
private static final long serialVersionUID = -4843781544193464186L;
private static Logger logger = LogManager.getLogger(GenericDAO.class);
protected Class<T> classe;
#PersistenceContext
protected transient EntityManager entityManager;
protected GenericDAO(final Class<T> classe) {
this.classe = classe;
}
public T save(final T entity) {
try {
entityManager.persist(entity);
entityManager.flush();
} catch (Exception e) {
logger.error("Falha ao persistir a entidade: " + entity.toString(), e);
throw TypeApplicationException.PERSISTENCIA.buildException("Ocorreu uma falha na persistencia");
}
return entity;
}
the class itemDAO that should use the base intrasis. In it I tried to use #PersistenceContext (unitName = "intrasis")
public class ItemDAO extends GenericDAO<Item> {
private static final long serialVersionUID = 1L;
#PersistenceContext(unitName="intrasis")
protected transient EntityManager entityManager;
protected ItemDAO() {
super(Item.class);
}
}
another class that uses the other bank and tbm I tried the PersistenceContext for the other bank.
public class CursoDAO extends GenericDAO<Curso> {
private static final long serialVersionUID = 5659645428769766934L;
#PersistenceContext(unitName="intranet")
protected transient EntityManager entityManager;
protected CursoDAO() {
super(Curso.class);
}
public List<Curso> buscarTodos() {
String jpql = "SELECT e FROM Curso e";
TypedQuery<Curso> typedQuery = entityManager.createQuery(jpql, Curso.class);
return typedQuery.getResultList();
}

1) You have probably an injection point where you don't specify the unit name. If it is not the case try adding this line to your persistence.xml :
<property name="wildfly.jpa.default-unit" value="true"/>
2) In your GenericDAO do not use:
#PersistenceContext
protected transient EntityManager entityManager;
try passing the entity manager througth constructor.

Related

Artifact demo:war: java.lang.Exception: {"WFLYCTL0412: Required services that are not installed:" =>

I am having problems while starting a Java EE 7 project on Wildfly-23.0.1 server.
Below follow piece of start log:
"WFLYCTL0412: Required services that are not installed:" => ["jboss.naming.context.java.module.\"demo-1.0-SNAPSHOT\".\"demo-1.0-SNAPSHOT\".env.jdbc.demoDB"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.\"demo-1.0-SNAPSHOT\".\"demo-1.0-SNAPSHOT\".env.\"com.bambino.demo.HelloServlet\".source is missing [jboss.naming.context.java.module.\"demo-1.0-SNAPSHOT\".\"demo-1.0-SNAPSHOT\".env.jdbc.demoDB]"]
}
22:44:09,005 ERROR [org.jboss.as.server] (management-handler-thread - 1) WFLYSRV0021: Deploy of deployment "demo-1.0-SNAPSHOT.war" was rolled back with the following failure message:
{
"WFLYCTL0412: Required services that are not installed:" => ["jboss.naming.context.java.module.\"demo-1.0-SNAPSHOT\".\"demo-1.0-SNAPSHOT\".env.jdbc.demoDB"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.\"demo-1.0-SNAPSHOT\".\"demo-1.0-SNAPSHOT\".env.\"com.bambino.demo.HelloServlet\".source is missing [jboss.naming.context.java.module.\"demo-1.0-SNAPSHOT\".\"demo-1.0-SNAPSHOT\".env.jdbc.demoDB]"]
}
22:44:09,009 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-5) WFLYJCA0019: Stopped Driver service with driver-name = demo-1.0-SNAPSHOT.war_com.mysql.cj.jdbc.Driver_8_0
22:44:09,010 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 78) WFLYJPA0011: Stopping Persistence Unit (phase 2 of 2) Service 'demo-1.0-SNAPSHOT.war#generalPU'
22:44:09,012 INFO [org.hibernate.orm.beans] (ServerService Thread Pool -- 78) HHH10005004: Stopping BeanContainer : org.hibernate.resource.beans.container.internal.CdiBeanContainerExtendedAccessImpl#5677c4c9
22:44:09,015 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 78) WFLYJPA0011: Stopping Persistence Unit (phase 1 of 2) Service 'demo-1.0-SNAPSHOT.war#generalPU'
22:44:09,039 INFO [org.infinispan.manager.DefaultCacheManager] (ServerService Thread Pool -- 26) Stopping cache manager null on null
22:44:09,045 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0028: Stopped deployment demo-1.0-SNAPSHOT.war (runtime-name: demo-1.0-SNAPSHOT.war) in 39ms
[2021-04-21 10:44:09,084] Artifact demo:war: Error during artifact deployment. See server log for details.
[2021-04-21 10:44:09,084] Artifact demo:war: java.lang.Exception: {"WFLYCTL0412: Required services that are not installed:" => ["jboss.naming.context.java.module.\"demo-1.0-SNAPSHOT\".\"demo-1.0-SNAPSHOT\".env.jdbc.demoDB"],"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.\"demo-1.0-SNAPSHOT\".\"demo-1.0-SNAPSHOT\".env.\"com.bambino.demo.HelloServlet\".source is missing [jboss.naming.context.java.module.\"demo-1.0-SNAPSHOT\".\"demo-1.0-SNAPSHOT\".env.jdbc.demoDB]"]}
persistance.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd"
version="2.2">
<persistence-unit name="generalPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/demoDB</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.schema-generation.database.action" value="create"/>
<property name="eclipselink.logging.level" value="FINEST"/>
<property name="eclipselink.logging.parameters" value="true"/>
<property name="eclipselink.cache.share.default" value="false"/>
<property name="eclipselink.jdbc.sequence-connection-pool" value="true" />
</properties>
</persistence-unit>
</persistence>
can anyone help me to solve this problem ?

Error while starting Wildfly 11 App Server - persistence unit named null

I'm developing a maven based JSF+JPA+EJB 3.2 Project using Eclipse and Wildfly 11.
While starting the App Server am getting the following error :
20:37:27,664 INFO [org.jboss.weld.deployer] (MSC service thread 1-4) WFLYWELD0003: Processing weld deployment erpmini.war
20:37:28,116 INFO [org.hibernate.validator.internal.util.Version] (MSC service thread 1-4) HV000001: Hibernate Validator 5.3.5.Final
20:37:28,552 INFO [org.jboss.as.ejb3.deployment] (MSC service thread 1-4) WFLYEJB0473: JNDI bindings for session bean named 'UserManagementServiceSlsb' in deployment unit 'deployment "erpmini.war"' are as follows:
java:global/erpmini/UserManagementServiceSlsb!com.itsys.erp.server.commonservices.usermgmt.UserManagementService
java:app/erpmini/UserManagementServiceSlsb!com.itsys.erp.server.commonservices.usermgmt.UserManagementService
java:module/UserManagementServiceSlsb!com.itsys.erp.server.commonservices.usermgmt.UserManagementService
java:jboss/exported/erpmini/UserManagementServiceSlsb!com.itsys.erp.server.commonservices.usermgmt.UserManagementService
java:global/erpmini/UserManagementServiceSlsb
java:app/erpmini/UserManagementServiceSlsb
java:module/UserManagementServiceSlsb
20:37:29,879 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC000001: Failed to start service jboss.deployment.unit."erpmini.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."erpmini.war".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment "erpmini.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:172)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:2032)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1955)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYEE0041: Component class com.itsys.erp.server.commonservices.usermgmt.slsbadapter.UserManagementServiceSlsb for component UserManagementServiceSlsb has errors:
WFLYJPA0033: Can't find a persistence unit named null in deployment "erpmini.war"
at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor$1.handle(ModuleJndiBindingProcessor.java:157)
at org.jboss.as.ee.component.ClassDescriptionTraversal.run(ClassDescriptionTraversal.java:54)
at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.processClassConfigurations(ModuleJndiBindingProcessor.java:186)
at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.deploy(ModuleJndiBindingProcessor.java:143)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:165)
... 5 more
20:37:30,098 INFO [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-2) ISPN000128: Infinispan version: Infinispan 'Chakra' 8.2.8.Final
20:37:31,825 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 63) WFLYCLINF0002: Started client-mappings cache from ejb container
20:37:32,131 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "erpmini.war")]) - failure description: {
"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"erpmini.war\".INSTALL" => "WFLYSRV0153: Failed to process phase INSTALL of deployment \"erpmini.war\"
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYEE0041: Component class com.itsys.erp.server.commonservices.usermgmt.slsbadapter.UserManagementServiceSlsb for component UserManagementServiceSlsb has errors:
WFLYJPA0033: Can't find a persistence unit named null in deployment \"erpmini.war\""},
"WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.unit.\"erpmini.war\".beanmanager"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.deployment.unit.\"erpmini.war\".weld.weldClassIntrospector is missing [jboss.deployment.unit.\"erpmini.war\".beanmanager]",
"jboss.deployment.unit.\"erpmini.war\".batch.artifact.factory is missing [jboss.deployment.unit.\"erpmini.war\".beanmanager]"
]
}
I'm injecting the EntityManager in stateless bean:
#Stateless
public class UserManagementServiceSlsb implements UserManagementService {
/** The Entity Manager */
#PersistenceContext(name = "TELCOAppPU")
private EntityManager entityManager;
private UserManagementService userMgmtService;
....
}
Why the Container is not able to find persistence.xml file? persistence.xml is present in META-INF directory. Any help would be appreciated.
Thanks.
UPDATE :
here is Project dir structure , persistence.xml is present in META-INF directory.
Project dir structure
persistence.xml contains Entity classes and MySql database connection details.
<persistence-unit name="TELCOAppPU">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>com.itsys.erp.server.dal.entities.City</class>
<class>com.itsys.erp.server.dal.entities.Machine</class>
<class>com.itsys.erp.server.dal.entities.Product</class>
<class>com.itsys.erp.server.dal.entities.ProductType</class>
<class>com.itsys.erp.server.dal.entities.ProductionLog</class>
...
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/erpdb" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="root" />
<property name="hibernate.show_sql" value="true" />
</properties>
</persistence-unit>
Solved it by adding resources folder (as source folder) to the path src/main/resources and moving the META-INF folder to resources folder, which in turn tells maven to put all files under resources directory to target/classes and in WEB-INF/classes in the WAR.
Try placing your persistance.xml file inside WEB-INF (src/main/webapp/WEB-INF) directory, Since in case of a war, that is where you are supposed to place your persisntence.xml file.

Unable to locate persistence units

In IntelliJ Idea I created a project with JPA 2.1 and hibernate 4.3.10 final. After I created a datasource (Test connection : Success) I generated persistence mapping from database. Project compiles without error. When I tried to test in JPA Console with a simple Select * query, it returns following exception:
[2015-05-21 16:01:27] javax.persistence.PersistenceException: Unable to locate persistence units
[2015-05-21 16:01:27] java.lang.RuntimeException: javax.persistence.PersistenceException: Invalid persistence.xml.
Error parsing XML [line : -1, column : -1] : cvc-elt.1: Cannot find the declaration of element 'persistence'.
at org.hibernate.jpa.boot.internal.PersistenceXmlParser.validate(PersistenceXmlParser.java:377)
at org.hibernate.jpa.boot.internal.PersistenceXmlParser.loadUrl(PersistenceXmlParser.java:310)
at org.hibernate.jpa.boot.internal.PersistenceXmlParser.parsePersistenceXml(PersistenceXmlParser.java:114)
at org.hibernate.jpa.boot.internal.PersistenceXmlParser.doResolve(PersistenceXmlParser.java:104)
at org.hibernate.jpa.boot.internal.PersistenceXmlParser.locatePersistenceUnits(PersistenceXmlParser.java:86)
at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:97)
at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:88)
at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:69)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at com.intellij.jpa.remote.impl.JpaFacadeImpl.createEntityManagerFactory(JpaFacadeImpl.java:16)
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 sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$254(TCPTransport.java:683)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler$$Lambda$2/4400315.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
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)
Here is the persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence 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"
version="2.1">
<persistence-unit name="NewPersistenceUnit">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>model.DepartmentEntity</class>
<class>model.UserEntity</class>
<properties>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/svgroup"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.archive.autodetection" value="class"/>
<property name="hibernate.connection.username" value="root"/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hbm2ddl.auto" value="update"/>
</properties>
</persistence-unit>
</persistence>
Can someone tell me how to fix this error? I was searching and reading for about 10 hours without success
EDIT
If I try to deploy the app on wildfly without creating entities from database it will deploy the app. However, if I try to deploy the app after the entities are created i get the following error:
2015-05-21 18:13:01,697 INFO [org.hibernate.Version] (ServerService Thread Pool -- 15) HHH000412: Hibernate Core {4.3.7.Final}
2015-05-21 18:13:01,704 INFO [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 15) HHH000206: hibernate.properties not found
2015-05-21 18:13:01,711 INFO [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 15) HHH000021: Bytecode provider name : javassist
2015-05-21 18:13:02,183 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC000001: Failed to start service jboss.deployment.unit."SVGZad4_ejb_exploded.rar".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."SVGZad4_ejb_exploded.rar".INSTALL: JBAS018733: Failed to process phase INSTALL of deployment "SVGZad4_ejb_exploded.rar"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:166) [wildfly-server-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_71]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_71]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_71]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: org.jboss.jca.common.api.validator.ValidateException: IJ010075: The resource adapter metadata must contain either an outbound or inbound configuration
at org.jboss.as.connector.deployers.ra.processors.ParsedRaDeploymentProcessor.process(ParsedRaDeploymentProcessor.java:237)
at org.jboss.as.connector.deployers.ra.processors.ParsedRaDeploymentProcessor.deploy(ParsedRaDeploymentProcessor.java:130)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:159) [wildfly-server-8.2.0.Final.jar:8.2.0.Final]
... 5 more
Caused by: org.jboss.jca.common.api.validator.ValidateException: IJ010075: The resource adapter metadata must contain either an outbound or inbound configuration
at org.jboss.jca.common.metadata.ra.common.ResourceAdapter1516Impl.validate(ResourceAdapter1516Impl.java:352)
at org.jboss.jca.common.metadata.ra.common.ConnectorAbstractmpl.validate(ConnectorAbstractmpl.java:334)
at org.jboss.as.connector.deployers.ra.processors.ParsedRaDeploymentProcessor.process(ParsedRaDeploymentProcessor.java:206)
... 7 more
2015-05-21 18:13:02,207 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 3) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "SVGZad4_ejb_exploded.rar")]) - failure description: {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"SVGZad4_ejb_exploded.rar\".INSTALL" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"SVGZad4_ejb_exploded.rar\".INSTALL: JBAS018733: Failed to process phase INSTALL of deployment \"SVGZad4_ejb_exploded.rar\"
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: org.jboss.jca.common.api.validator.ValidateException: IJ010075: The resource adapter metadata must contain either an outbound or inbound configuration
Caused by: org.jboss.jca.common.api.validator.ValidateException: IJ010075: The resource adapter metadata must contain either an outbound or inbound configuration"}}
2015-05-21 18:13:02,216 ERROR [org.jboss.as.server] (management-handler-thread - 3) JBAS015870: Deploy of deployment "SVGZad4_ejb_exploded.rar" was rolled back with the following failure message:
{"JBAS014671: Failed services" => {"jboss.deployment.unit.\"SVGZad4_ejb_exploded.rar\".INSTALL" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"SVGZad4_ejb_exploded.rar\".INSTALL: JBAS018733: Failed to process phase INSTALL of deployment \"SVGZad4_ejb_exploded.rar\"
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: org.jboss.jca.common.api.validator.ValidateException: IJ010075: The resource adapter metadata must contain either an outbound or inbound configuration
Caused by: org.jboss.jca.common.api.validator.ValidateException: IJ010075: The resource adapter metadata must contain either an outbound or inbound configuration"}}
2015-05-21 18:13:02,301 INFO [org.hibernate.validator.internal.util.Version] (MSC service thread 1-1) HV000001: Hibernate Validator 5.1.3.Final
2015-05-21 18:13:02,626 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 15) JBAS011410: Stopping Persistence Unit (phase 1 of 2) Service 'SVGZad4_ejb_exploded.rar#NewPersistenceUnit'
2015-05-21 18:13:02,637 INFO [org.jboss.as.server.deployment] (MSC service thread 1-6) JBAS015877: Stopped deployment SVGZad4_ejb_exploded.rar (runtime-name: SVGZad4_ejb_exploded.rar) in 422ms
2015-05-21 18:13:02,640 INFO [org.jboss.as.controller] (management-handler-thread - 3) JBAS014774: Service status report
JBAS014777: Services which failed to start: service jboss.deployment.unit."SVGZad4_ejb_exploded.rar".INSTALL
I think your Jars (JPA / Hibernate) are probably older.
What Jars are you using?
Usually when you download something like Hibernate, they allow you to download sample projects which have the example of such persistence.xml and other files.
Update
Maybe the app isn't picking up the expected persistence.xml file?
Try to add some obviously incorrect, invalid text in your persistence.xml file. This way, the exception will printed out with the complete name of the persitence.xml that is being looked at.
I think you have to change your persistence.xml
The following line
<property name = "hbm2ddl.auto" value = "update" />
must probably be changed to
<property name = "hibernate.hbm2ddl.auto" value = "update" />
Then I suppose you do not have any password in your database
<property name = "hibernate.connection.password" value = "?" />
Otherwise, I see nothing strange.

Wildfly configuration with DataSource

this is the first time I am trying to setup datasource in my Wildfly server. I tried to follow some tutorials which I found on Google but it still doesn't work.
I am working on a web service but I keep getting some errors when I deploy my .war file.
Here is the latest log when app is deployed:
22:16:33,049 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015877: Stopped deployment IslamicPostsWS.war (runtime-name: IslamicPostsWS.war) in 7ms
22:16:33,184 INFO [org.jboss.as.server] (XNIO-1 task-2) JBAS018558: Undeployed "IslamicPostsWS.war" (runtime-name: "IslamicPostsWS.war")
22:16:33,186 INFO [org.jboss.as.controller] (XNIO-1 task-2) JBAS014774: Service status report
JBAS014777: Services which failed to start: service jboss.deployment.unit."IslamicPostsWS.war".POST_MODULE
22:16:35,518 INFO [org.jboss.as.server.deployment] (MSC service thread 1-6) JBAS015877: Stopped deployment IslamicPostsWS (runtime-name: IslamicPostsWS) in 7ms
22:16:35,660 INFO [org.jboss.as.server] (XNIO-1 task-6) JBAS018558: Undeployed "IslamicPostsWS" (runtime-name: "IslamicPostsWS")
22:16:38,358 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 2) JBAS015018: Deployment IslamicPostsWS was previously deployed by this scanner but has been removed from the server deployment list by another management tool. Marker file C:\Users\Ilhami\workspace-services\.metadata\.plugins\org.jboss.ide.eclipse.as.core\WildFly_8.0_Runtime_Server1396040937545\deploy\IslamicPostsWS.undeployed is being added to record this fact.
22:17:00,406 INFO [org.jboss.as.server.deployment] (MSC service thread 1-7) JBAS015876: Starting deployment of "IslamicPostsWS.war" (runtime-name: "IslamicPostsWS.war")
22:17:00,540 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 2) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "IslamicPostsWS.war")]) - failure description: {
"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.IslamicPostsWS.IslamicPostsWS.DefaultDataSource is missing [jboss.naming.context.java.jboss.datasources.ExampleDS]"],
"JBAS014879: One or more services were unable to start due to one or more indirect dependencies not being available." => {
"Services that were unable to start:" => [
"jboss.deployment.unit.\"IslamicPostsWS.war\".component.\"com.sun.faces.config.ConfigureListener\".START",
"jboss.deployment.unit.\"IslamicPostsWS.war\".component.\"javax.faces.webapp.FacetTag\".START",
"jboss.deployment.unit.\"IslamicPostsWS.war\".component.\"javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV\".START",
"jboss.deployment.unit.\"IslamicPostsWS.war\".component.\"javax.servlet.jsp.jstl.tlv.ScriptFreeTLV\".START",
"jboss.deployment.unit.\"IslamicPostsWS.war\".component.\"org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher\".START",
"jboss.deployment.unit.\"IslamicPostsWS.war\".component.\"org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap\".START",
"jboss.deployment.unit.\"IslamicPostsWS.war\".deploymentCompleteService",
"jboss.deployment.unit.\"IslamicPostsWS.war\".jndiDependencyService",
"jboss.naming.context.java.module.IslamicPostsWS.IslamicPostsWS.env.jdbc.TestDB",
"jboss.undertow.deployment.default-server.default-host./IslamicPostsWS",
"jboss.undertow.deployment.default-server.default-host./IslamicPostsWS.UndertowDeploymentInfoService"
],
"Services that may be the cause:" => [
"jboss.jdbc-driver.com_mysql_jdbc_Driver",
"jboss.naming.context.java.jboss.datasources.ExampleDS"
]
}
}
22:17:00,683 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "IslamicPostsWS.war" (runtime-name : "IslamicPostsWS.war")
22:17:00,683 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014775: New missing/unsatisfied dependencies:
service jboss.naming.context.java.jboss.datasources.ExampleDS (missing) dependents: [service jboss.naming.context.java.module.IslamicPostsWS.IslamicPostsWS.DefaultDataSource]
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" 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">
<persistence-unit name="JPADB">
<jta-data-source>java:jboss/datasources/DBTest</jta-data-source>
<properties>
<property name="showSql" value="true"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
</properties>
</persistence-unit>
</persistence>
Just tell me if you need more files.
Go into your wildfly console (something like localhost:9990) and edit the Configuration->Container->EE->Default Bindings section. Set the default datasource to the JNDI name of some valid datasource.
I removed the default one that was there and just pointed it to my main datasource since the server exists to run one app only.
You probably have the ds declaration "java:jboss/datasources/ExampleDS" missing in your standalone.xml xmlns "urn:jboss:domain:datasources:2.0" section, just and it will work (here's the example from the default configuration):
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>
Or you can also add through the UI as mentioned by other response.
can you post your datasource definition?
I think it would be the best to test the datasource deployment 'standalone'. I mean separated from an actual application deployment, just to test whether your datasource works or not.
You can test this f.i. using the web console (localhost:9990/console).
It also looks like there are problems with the pre-configured example DS of wildfly. Did you remove this DS? In standalone.xml there is also a reference on ExampleDS which might be broken.
Assuming you are using a MySQL DB, you can create a DS in the following way:
(1) Download the mysql driver from here:
http://dev.mysql.com/downloads/connector/j/
(2) Copy the mysql driver to:
WILDFLY_HOME/modules/system/layers/base/com/mysql/main
(3) From the JBoss (or Wildfly) console, run the command:
/subsystem=datasources/jdbc-driver=mysql:add(driver-name=mysql, driver-module-name=com.mysql, driver-class-name=com.mysql.jdbc.Driver)
(4) Then, again from the JBoss (or Wildfly) console, run command:
/subsystem=datasources/data-source=YourDS:add(driver-name=mysql, user-name=USERNAME, password=PASSWORD, connection-url=jdbc:mysql://localhost:3306/YOURDATABASE, min-pool-size=5, max-pool-size=15, jndi-name=java:jboss/datasources/YourDS, enabled=true, validate-on-match=true, valid-connection-checker-class-name=org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker, exception-sorter-class-name=org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter)
Voila. Now you have a Datasource with a JNDI path of:
java:jboss/datasources/YourDS
Check if default-bindings configuration references to correct datasource: https://docs.jboss.org/author/display/WFLY8/Default+EE+Bindings+Configuration
I had
service jboss.naming.context.java.jboss.datasourservice jboss.naming.context.java.jboss.datasources.ExampleDS (missing) dependents:...
on wildfly-8.1.0.Final.
IMHO
in standalone/configuration/standalone-full.xml it had
<default-bindings ... datasource="java:jboss/datasources/ExampleDS" ...
and
<datasource jndi-name="java:/datasources/ExampleDS"...
jndi-name mismatch!
I created ExampleDS2 with jndi-name="java:jboss/datasources/ExampleDS". This solved my problem.

spring mvc 3 with hibernate (and hibernate.hbm2ddl.auto)

I've a problem setting up spring mvc 3 and hibernate with the auto dll
this is my folder structure:
And these are my libraries:
AbstractUser
package org.andreadorigo.abstracts;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.validation.constraints.Size;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotEmpty;
/**
* Generic user
* #author andreadorigo
*
*/
public abstract class AbstractUser {
#Id
#Column(name="id")
#GeneratedValue
private Integer id;
#NotEmpty
#Email
#Column(name="email")
public String email;
#NotEmpty
#Size(min = 6, max = 14)
#Column(name="password")
public String password;
/**
*
*/
public AbstractUser() {
super();
}
//Getters and setters
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
CustomerUser
package org.andreadorigo.entities;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.andreadorigo.abstracts.AbstractUser;
#Entity
#Table(name="customerUser")
public class CustomerUser extends AbstractUser{
}
dispatcher-servlet.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="org.andreadorigo" />
<mvc:annotation-driven />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
<property name="prefix">
<value>/WEB-INF/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<bean
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
id="entityManagerFactory">
<property
name="persistenceUnitName"
value="jtdb" />
<property
name="dataSource"
ref="dataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property
name="showSql"
value="true" />
<property
name="generateDdl"
value="true" />
<property
name="databasePlatform"
value="org.hibernate.dialect.MySQLDialect" />
</bean>
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">create</prop>
</props>
</property>
</bean>
</beans>
hibernate.cfg.xml
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:mysql://localhost:3306/test</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.username">root</property>
<property name="connection.password"></property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="transaction.factory_class">org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory</property>
<property name="hibernate.hbm2ddl.auto">create</property>
</session-factory>
</hibernate-configuration>
persistence.xml
<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="CustomerUser">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>org.andreadorigo.entities.CustomerUser</class>
<properties>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
</properties>
</persistence-unit>
</persistence>
But when I run jboss 7 I get these warnings/errors:
15:48:57,442 WARN [org.jboss.modules] (MSC service thread 1-3) Failed to define class org.springframework.orm.jpa.AbstractEntityManagerFactoryBean in Module "deployment.SpringTest.war:main" from Service Module Loader: java.lang.LinkageError: Failed to link org/springframework/orm/jpa/AbstractEntityManagerFactoryBean (Module "deployment.SpringTest.war:main" from Service Module Loader)
15:48:58,322 INFO [org.hibernate.validator.util.Version] (MSC service thread 1-2) Hibernate Validator 4.2.0.Final
15:48:59,172 WARN [org.jboss.modules] (MSC service thread 1-3) Failed to define class org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in Module "deployment.SpringTest.war:main" from Service Module Loader: java.lang.LinkageError: Failed to link org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBean (Module "deployment.SpringTest.war:main" from Service Module Loader)
15:48:59,614 INFO [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-2) Monitoring jndi:/default-host/GenericProject/WEB-INF/faces-config.xml for modifications
15:49:00,295 WARN [org.jboss.modules] (MSC service thread 1-3) Failed to define class org.springframework.orm.jpa.AbstractEntityManagerFactoryBean in Module "deployment.SpringTest.war:main" from Service Module Loader: java.lang.LinkageError: Failed to link org/springframework/orm/jpa/AbstractEntityManagerFactoryBean (Module "deployment.SpringTest.war:main" from Service Module Loader)
15:49:00,405 INFO [org.jboss.web] (MSC service thread 1-2) JBAS018210: Registering web context: /GenericProject
15:49:01,010 WARN [org.jboss.modules] (MSC service thread 1-3) Failed to define class org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in Module "deployment.SpringTest.war:main" from Service Module Loader: java.lang.LinkageError: Failed to link org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBean (Module "deployment.SpringTest.war:main" from Service Module Loader)
15:49:01,271 WARN [org.jboss.modules] (MSC service thread 1-3) Failed to define class org.springframework.orm.jpa.AbstractEntityManagerFactoryBean in Module "deployment.SpringTest.war:main" from Service Module Loader: java.lang.LinkageError: Failed to link org/springframework/orm/jpa/AbstractEntityManagerFactoryBean (Module "deployment.SpringTest.war:main" from Service Module Loader)
15:49:01,529 WARN [org.jboss.modules] (MSC service thread 1-3) Failed to define class org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in Module "deployment.SpringTest.war:main" from Service Module Loader: java.lang.LinkageError: Failed to link org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBean (Module "deployment.SpringTest.war:main" from Service Module Loader)
15:49:01,778 INFO [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor] (MSC service thread 1-3) JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
15:49:01,795 WARN [org.jboss.modules] (MSC service thread 1-3) Failed to define class org.springframework.orm.jpa.AbstractEntityManagerFactoryBean in Module "deployment.SpringTest.war:main" from Service Module Loader: java.lang.LinkageError: Failed to link org/springframework/orm/jpa/AbstractEntityManagerFactoryBean (Module "deployment.SpringTest.war:main" from Service Module Loader)
15:49:02,061 WARN [org.jboss.modules] (MSC service thread 1-3) Failed to define class org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in Module "deployment.SpringTest.war:main" from Service Module Loader: java.lang.LinkageError: Failed to link org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBean (Module "deployment.SpringTest.war:main" from Service Module Loader)
15:49:02,310 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] (MSC service thread 1-3) Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#55e3c942: defining beans [registerController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0,org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0,viewResolver,entityManagerFactory]; root of factory hierarchy
15:49:02,374 WARN [org.jboss.modules] (MSC service thread 1-3) Failed to define class org.springframework.orm.jpa.AbstractEntityManagerFactoryBean in Module "deployment.SpringTest.war:main" from Service Module Loader: java.lang.LinkageError: Failed to link org/springframework/orm/jpa/AbstractEntityManagerFactoryBean (Module "deployment.SpringTest.war:main" from Service Module Loader)
15:49:02,749 WARN [org.jboss.modules] (MSC service thread 1-3) Failed to define class org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in Module "deployment.SpringTest.war:main" from Service Module Loader: java.lang.LinkageError: Failed to link org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBean (Module "deployment.SpringTest.war:main" from Service Module Loader)
15:49:03,126 WARN [org.jboss.modules] (MSC service thread 1-3) Failed to define class org.springframework.orm.jpa.AbstractEntityManagerFactoryBean in Module "deployment.SpringTest.war:main" from Service Module Loader: java.lang.LinkageError: Failed to link org/springframework/orm/jpa/AbstractEntityManagerFactoryBean (Module "deployment.SpringTest.war:main" from Service Module Loader)
15:49:03,505 WARN [org.jboss.modules] (MSC service thread 1-3) Failed to define class org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in Module "deployment.SpringTest.war:main" from Service Module Loader: java.lang.LinkageError: Failed to link org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBean (Module "deployment.SpringTest.war:main" from Service Module Loader)
15:49:03,839 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] (MSC service thread 1-3) Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#55e3c942: defining beans [registerController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0,org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0,viewResolver,entityManagerFactory]; root of factory hierarchy
15:49:03,875 ERROR [org.springframework.beans.factory.support.DefaultListableBeanFactory] (MSC service thread 1-3) Destroy method on bean with name 'org.springframework.web.servlet.handler.MappedInterceptor#0' threw an exception: java.lang.NoClassDefFoundError: org/springframework/transaction/support/TransactionSynchronization
15:49:04,031 ERROR [org.springframework.beans.factory.support.DefaultListableBeanFactory] (MSC service thread 1-3) Destroy method on bean with name '(inner bean)' threw an exception: java.lang.NoClassDefFoundError: org/springframework/transaction/support/TransactionSynchronization
15:49:04,182 ERROR [org.springframework.beans.factory.support.DefaultListableBeanFactory] (MSC service thread 1-3) Destroy method on bean with name 'org.springframework.format.support.FormattingConversionServiceFactoryBean#0' threw an exception: java.lang.NoClassDefFoundError: org/springframework/transaction/support/TransactionSynchronization
15:49:04,381 ERROR [org.springframework.beans.factory.support.DefaultListableBeanFactory] (MSC service thread 1-3) Destroy method on bean with name 'registerController' threw an exception: java.lang.NoClassDefFoundError: org/springframework/transaction/support/TransactionSynchronization
15:49:04,530 ERROR [org.springframework.web.servlet.DispatcherServlet] (MSC service thread 1-3) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean] for bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean from [Module "deployment.SpringTest.war:main" from Service Module Loader]
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean] for bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean from [Module "deployment.SpringTest.war:main" from Service Module Loader]
15:49:04,868 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/SpringTest]] (MSC service thread 1-3) StandardWrapper.Throwable: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean] for bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean from [Module "deployment.SpringTest.war:main" from Service Module Loader]
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean] for bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean from [Module "deployment.SpringTest.war:main" from Service Module Loader]
15:49:05,194 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/SpringTest]] (MSC service thread 1-3) Servlet /SpringTest threw load() exception: java.lang.ClassNotFoundException: org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean from [Module "deployment.SpringTest.war:main" from Service Module Loader]
There are at least 2 things wrong here
You are mixing spring versions 3.0.3 and 3.1.1, never mix different spring versions (well actually that goes for all frameworks).
You are at least missing the spring-tx.jar and spring-aop.jar.
I strongly suggest using Maven or Gradle for managing your dependencies, saves you a lot of headaches searching for jars around the internet.
Next to that make up your mind on what you want to use for configuration, you have your entitymanager configured through a hibernate.cfg.xml, spring context file and persistence.xml. Why? Remove at least the hibernate.cfg.xml and put the needed config in persistence.xml.
You seem to be missing the spring-tx jar from your classpath given this line
15:49:04,031 ERROR [org.springframework.beans.factory.support.DefaultListableBeanFactory]
(MSC service thread 1-3) Destroy method on bean with name '(inner bean)'
threw an exception: java.lang.NoClassDefFoundError: org/springframework/transaction/support/TransactionSynchronization
You can get it here.
You actually seem to be missing much more than that.
java.lang.ClassNotFoundException: org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
Get all the spring jars from the here.

Categories

Resources