Failed to start service jboss.deployment.unit - java

I am trying to use tutorial: https://balusc.omnifaces.org/2020/04/jsf-23-tutorial-with-eclipse-maven.html
Server Wildfly18
Java 11
Eclipse 2022-03 (4.23.0)
Message Model Class:
public class Message implements Serializable {
private static final long serialVersionUID = 1L;
#Id #GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
#Column(nullable = false) #Lob
private #NotNull String text;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}
MesssageService Class:
public class MessageService {
#PersistenceContext
private EntityManager entityManager;
public void create(Message message) {
entityManager.persist(message);
}
public List<Message> list() {
return entityManager.createQuery("FROM Message m", Message.class).getResultList();
}
}
Bean Class:
#Named
#RequestScoped
public class Bean {
private Message message = new Message();
private List<Message> messages;
#Inject
private MessageService messageService;
#PostConstruct
public void init() {
messages = messageService.list();
}
public void submit() {
messageService.create(message);
messages.add(message);
message = new Message();
}
public Message getMessage() {
return message;
}
public List<Message> getMessages() {
return messages;
}
}
Persistense.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.2"
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
<persistence-unit name="project"
transaction-type="JTA">
<jta-data-source>java:global/DataSourceName</jta-data-source>
<class>pt.example.project.model.Message</class>
<properties>
<property
name="javax.persistence.schema-generation.database.action"
value="drop-and-create" />
</properties>
</persistence-unit>
</persistence>
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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>pt.example</groupId>
<artifactId>project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>project</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>8.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.200</version>
<scope>provided</scope>
</dependency>
</dependencies>
<distributionManagement>
<repository>
<id>Central Maven repository</id>
<name>Central Maven repository https</name>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
</distributionManagement>
</project>
Error log:
12:33:02,320 INFO [org.jboss.as.ejb3.deployment] (MSC service thread 1-1) WFLYEJB0473: JNDI bindings for session bean named 'MessageService' in deployment unit 'deployment "project.war"' are as follows:
12:33:02,320 INFO [org.jboss.as.ejb3.deployment] (MSC service thread 1-1) WFLYEJB0473: JNDI bindings for session bean named 'MessageService' in deployment unit 'deployment "project.war"' are as follows:
java:global/project/MessageService!pt.example.project.service.MessageService
java:app/project/MessageService!pt.example.project.service.MessageService
java:module/MessageService!pt.example.project.service.MessageService
ejb:/project/MessageService!pt.example.project.service.MessageService
java:global/project/MessageService
java:app/project/MessageService
java:module/MessageService
12:33:02,902 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.unit."project.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."project.war".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment "project.war"
at org.jboss.as.server#10.0.3.Final//org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:183)
at org.jboss.msc#1.4.11.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1739)
at org.jboss.msc#1.4.11.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1701)
at org.jboss.msc#1.4.11.Final//org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1559)
at org.jboss.threads#2.3.3.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads#2.3.3.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982)
at org.jboss.threads#2.3.3.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads#2.3.3.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: java.lang.ClassNotFoundException: org.h2.jdbcx.JdbcDataSource from [Module "deployment.project.war" from Service Module Loader]
at org.jboss.as.connector#18.0.1.Final//org.jboss.as.connector.deployers.datasource.DataSourceDefinitionInjectionSource.getResourceValue(DataSourceDefinitionInjectionSource.java:178)
at org.jboss.as.ee#18.0.1.Final//org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.addJndiBinding(ModuleJndiBindingProcessor.java:289)
at org.jboss.as.ee#18.0.1.Final//org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.deploy(ModuleJndiBindingProcessor.java:122)
at org.jboss.as.server#10.0.3.Final//org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:176)
... 8 more
Caused by: java.lang.ClassNotFoundException: org.h2.jdbcx.JdbcDataSource from [Module "deployment.project.war" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:255)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
at org.jboss.as.connector#18.0.1.Final//org.jboss.as.connector.deployers.datasource.DataSourceDefinitionInjectionSource.getResourceValue(DataSourceDefinitionInjectionSource.java:142)
... 11 more
12:33:02,997 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 76) WFLYCLINF0002: Started client-mappings cache from ejb container
12:33:03,069 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "project.war")]) - failure description: {
"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"project.war\".INSTALL" => "WFLYSRV0153: Failed to process phase INSTALL of deployment \"project.war\"
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: java.lang.ClassNotFoundException: org.h2.jdbcx.JdbcDataSource from [Module \"deployment.project.war\" from Service Module Loader]
Caused by: java.lang.ClassNotFoundException: org.h2.jdbcx.JdbcDataSource from [Module \"deployment.project.war\" from Service Module Loader]"},
"WFLYCTL0412: Required services that are not installed:" => [
"jboss.naming.context.java.global.DataSourceName",
"jboss.deployment.unit.\"project.war\".beanmanager",
"jboss.deployment.unit.\"project.war\".WeldStartService"
],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.persistenceunit.\"project.war#project\".__FIRST_PHASE__ is missing [jboss.naming.context.java.global.DataSourceName]",
"jboss.deployment.unit.\"project.war\".batch.artifact.factory is missing [jboss.deployment.unit.\"project.war\".beanmanager]",
"jboss.deployment.unit.\"project.war\".weld.weldClassIntrospector is missing [jboss.deployment.unit.\"project.war\".WeldStartService, jboss.deployment.unit.\"project.war\".beanmanager]"
]
}
12:33:03,325 INFO [org.jboss.as.server] (ServerService Thread Pool -- 44) WFLYSRV0010: Deployed "project.war" (runtime-name : "project.war")
12:33:03,330 INFO [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0184: New missing/unsatisfied dependencies:
service jboss.deployment.unit."project.war".WeldStartService (missing) dependents: [service jboss.deployment.unit."project.war".weld.weldClassIntrospector]
service jboss.deployment.unit."project.war".beanmanager (missing) dependents: [service jboss.deployment.unit."project.war".weld.weldClassIntrospector, service jboss.deployment.unit."project.war".batch.artifact.factory]
service jboss.naming.context.java.global.DataSourceName (missing) dependents: [service jboss.persistenceunit."project.war#project".__FIRST_PHASE__]
WFLYCTL0186: Services which failed to start: service jboss.deployment.unit."project.war".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment "project.war"
WFLYCTL0448: 2 additional services are down due to their dependencies being missing or failed
12:33:03,400 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
12:33:03,402 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
12:33:03,403 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
12:33:03,403 ERROR [org.jboss.as] (Controller Boot Thread) WFLYSRV0026: WildFly Full 18.0.1.Final (WildFly Core 10.0.3.Final) started (with errors) in 9989ms - Started 390 of 610 services (6 services failed or missing dependencies, 371 services are lazy, passive or on-demand)

Related

Unable to build Hibernate SessionFactory - could not instantiate test object

I have a very strange error happening
I have a program developed in Java WEB using Hibernate to connect to the MySQL Database
The program is working correctly on several computers here but there is a computer that the program does not work!
I already tried to change the version of the server, the JDK and even the IDE and even then on this computer the program is not working
The error mentions that "could not instantiate test object" but I'm not doing any tests on any classes / objects on any computer where the project is working
Log
14:42:36,750 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 87) MSC000001: Failed to start service jboss.persistenceunit."SA2021.war#SA2021PU": org.jboss.msc.service.StartException in service jboss.persistenceunit."SA2021.war#SA2021PU": javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
at org.jboss.as.jpa#23.0.2.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:198)
at org.jboss.as.jpa#23.0.2.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:128)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at org.wildfly.security.elytron-private#1.15.3.Final//org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:664)
at org.jboss.as.jpa#23.0.2.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:213)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at java.base/java.lang.Thread.run(Thread.java:832)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
at org.hibernate#5.3.20.Final//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1327)
at org.hibernate#5.3.20.Final//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1253)
at org.hibernate.jipijapa-hibernate5-3#23.0.2.Final//org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44)
at org.jboss.as.jpa#23.0.2.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:170)
... 10 more
Caused by: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister
at org.hibernate#5.3.20.Final//org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:123)
at org.hibernate#5.3.20.Final//org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:77)
at org.hibernate#5.3.20.Final//org.hibernate.metamodel.internal.MetamodelImpl.initialize(MetamodelImpl.java:154)
at org.hibernate#5.3.20.Final//org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:295)
at org.hibernate#5.3.20.Final//org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467)
at org.hibernate#5.3.20.Final//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1250)
... 12 more
Caused by: org.hibernate.InstantiationException: could not instantiate test object : model.entity.Tabcadastro
at org.hibernate#5.3.20.Final//org.hibernate.engine.internal.UnsavedValueFactory.instantiate(UnsavedValueFactory.java:43)
at org.hibernate#5.3.20.Final//org.hibernate.engine.internal.UnsavedValueFactory.getUnsavedIdentifierValue(UnsavedValueFactory.java:68)
at org.hibernate#5.3.20.Final//org.hibernate.tuple.PropertyFactory.buildIdentifierAttribute(PropertyFactory.java:62)
at org.hibernate#5.3.20.Final//org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:136)
at org.hibernate#5.3.20.Final//org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:557)
at org.hibernate#5.3.20.Final//org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:124)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.hibernate#5.3.20.Final//org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:96)
... 17 more
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.hibernate#5.3.20.Final//org.hibernate.engine.internal.UnsavedValueFactory.instantiate(UnsavedValueFactory.java:40)
... 28 more
Caused by: java.lang.RuntimeException:
at deployment.SA2021.war//model.entity.Tabcadastro.<init>(Tabcadastro.java:1)
... 34 more
14:42:36,800 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "SA2021.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"SA2021.war#SA2021PU\"" => "javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
Caused by: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister
Caused by: org.hibernate.InstantiationException: could not instantiate test object : model.entity.Tabcadastro
Caused by: java.lang.reflect.InvocationTargetException
Caused by: java.lang.RuntimeException: "}}
14:42:37,049 INFO [org.jboss.as.server] (ServerService Thread Pool -- 48) WFLYSRV0010: Deployed "SA2021.war" (runtime-name : "SA2021.war")
14:42:37,055 INFO [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0186: Services which failed to start: service jboss.persistenceunit."SA2021.war#SA2021PU": javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
WFLYCTL0448: 142 additional services are down due to their dependencies being missing or failed
14:42:37,196 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
14:42:37,207 ERROR [org.jboss.as] (Controller Boot Thread) WFLYSRV0026: WildFly Full 23.0.2.Final (WildFly Core 15.0.1.Final) started (with errors) in 22372ms - Started 683 of 1011 services (146 services failed or missing dependencies, 365 services are lazy, passive or on-demand)
14:42:37,212 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
14:42:37,212 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
14:42:52,501 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 18) WFLYJPA0011: Stopping Persistence Unit (phase 1 of 2) Service 'SA2021.war#SA2021PU'
14:42:52,503 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-2) WFLYJCA0019: Stopped Driver service with driver-name = SA2021.war_com.mysql.cj.jdbc.Driver_8_0
14:42:52,547 INFO [org.infinispan.manager.DefaultCacheManager] (ServerService Thread Pool -- 18) Stopping cache manager null on null
14:42:52,561 INFO [org.jboss.as.server.deployment] (MSC service thread 1-5) WFLYSRV0028: Stopped deployment SA2021.war (runtime-name: SA2021.war) in 65ms
14:42:52,566 INFO [org.jboss.as.server.deployment] (MSC service thread 1-8) WFLYSRV0027: Starting deployment of "SA2021.war" (runtime-name: "SA2021.war")
14:42:54,989 INFO [org.jboss.as.jpa] (MSC service thread 1-4) WFLYJPA0002: Read persistence.xml for SA2021PU
14:42:55,123 INFO [org.jipijapa] (MSC service thread 1-6) JIPIORMV53020253: Second level cache enabled for SA2021.war#SA2021PU
14:42:55,201 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 18) WFLYJPA0010: Starting Persistence Unit (phase 1 of 2) Service 'SA2021.war#SA2021PU'
14:42:55,201 INFO [org.hibernate.jpa.internal.util.LogHelper] (ServerService Thread Pool -- 18) HHH000204: Processing PersistenceUnitInfo [
name: SA2021PU
...]
14:42:55,463 INFO [org.jboss.weld.deployer] (MSC service thread 1-6) WFLYWELD0003: Processing weld deployment SA2021.war
14:42:56,114 INFO [io.jaegertracing.internal.JaegerTracer] (MSC service thread 1-6) No shutdown hook registered: Please call close() manually on application shutdown.
14:42:56,208 INFO [org.jipijapa] (MSC service thread 1-7) JIPIORMV53020253: Second level cache enabled for SA2021.war#SA2021PU
14:42:56,933 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-7) WFLYJCA0005: Deploying non-JDBC-compliant driver class com.mysql.cj.jdbc.Driver (version 8.0)
14:42:57,250 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-6) WFLYJCA0018: Started Driver service with driver-name = SA2021.war_com.mysql.cj.jdbc.Driver_8_0
14:42:57,294 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 18) WFLYJPA0010: Starting Persistence Unit (phase 2 of 2) Service 'SA2021.war#SA2021PU'
14:42:57,299 INFO [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 18) HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
14:42:57,305 INFO [org.hibernate.envers.boot.internal.EnversServiceImpl] (ServerService Thread Pool -- 18) Envers integration enabled? : true
14:42:57,379 INFO [org.hibernate.orm.beans] (ServerService Thread Pool -- 18) HHH10005004: Stopping BeanContainer : org.hibernate.resource.beans.container.internal.CdiBeanContainerExtendedAccessImpl#26cf2ff5
14:42:57,383 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 18) MSC000001: Failed to start service jboss.persistenceunit."SA2021.war#SA2021PU": org.jboss.msc.service.StartException in service jboss.persistenceunit."SA2021.war#SA2021PU": javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
at org.jboss.as.jpa#23.0.2.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:198)
at org.jboss.as.jpa#23.0.2.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:128)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at org.wildfly.security.elytron-private#1.15.3.Final//org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:664)
at org.jboss.as.jpa#23.0.2.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:213)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at java.base/java.lang.Thread.run(Thread.java:832)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
at org.hibernate#5.3.20.Final//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1327)
at org.hibernate#5.3.20.Final//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1253)
at org.hibernate.jipijapa-hibernate5-3#23.0.2.Final//org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44)
at org.jboss.as.jpa#23.0.2.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:170)
... 10 more
Caused by: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister
at org.hibernate#5.3.20.Final//org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:123)
at org.hibernate#5.3.20.Final//org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:77)
at org.hibernate#5.3.20.Final//org.hibernate.metamodel.internal.MetamodelImpl.initialize(MetamodelImpl.java:154)
at org.hibernate#5.3.20.Final//org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:295)
at org.hibernate#5.3.20.Final//org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467)
at org.hibernate#5.3.20.Final//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1250)
... 12 more
Caused by: org.hibernate.InstantiationException: could not instantiate test object : model.entity.Tabcadastro
at org.hibernate#5.3.20.Final//org.hibernate.engine.internal.UnsavedValueFactory.instantiate(UnsavedValueFactory.java:43)
at org.hibernate#5.3.20.Final//org.hibernate.engine.internal.UnsavedValueFactory.getUnsavedIdentifierValue(UnsavedValueFactory.java:68)
at org.hibernate#5.3.20.Final//org.hibernate.tuple.PropertyFactory.buildIdentifierAttribute(PropertyFactory.java:62)
at org.hibernate#5.3.20.Final//org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:136)
at org.hibernate#5.3.20.Final//org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:557)
at org.hibernate#5.3.20.Final//org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:124)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.hibernate#5.3.20.Final//org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:96)
... 17 more
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.hibernate#5.3.20.Final//org.hibernate.engine.internal.UnsavedValueFactory.instantiate(UnsavedValueFactory.java:40)
... 28 more
Caused by: java.lang.RuntimeException:
at deployment.SA2021.war//model.entity.Tabcadastro.<init>(Tabcadastro.java:1)
... 34 more
14:42:57,426 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 1) WFLYCTL0013: Operation ("full-replace-deployment") failed - address: ([]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"SA2021.war#SA2021PU\"" => "javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
Caused by: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister
Caused by: org.hibernate.InstantiationException: could not instantiate test object : model.entity.Tabcadastro
Caused by: java.lang.reflect.InvocationTargetException
Caused by: java.lang.RuntimeException: "}}
14:42:57,583 INFO [org.jboss.as.server] (DeploymentScanner-threads - 1) WFLYSRV0016: Replaced deployment "SA2021.war" with deployment "SA2021.war"
14:42:57,585 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 1) WFLYCTL0183: Service status report
WFLYCTL0186: Services which failed to start: service jboss.persistenceunit."SA2021.war#SA2021PU": javax.persistence.PersistenceException: [PersistenceUnit: SA2021PU] Unable to build Hibernate SessionFactory
My Tabcadastro class
package model.entity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
#Entity
#Table(name="tabcadastro")
public class Tabcadastro implements Serializable{
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private Integer Id;
#Column
private String nome;
#Column
private String email;
#Column
private Integer cep;
#Column
private Integer cpf;
#Column
private String senha;
public Integer getId() {
return Id;
}
public void setId(Integer Id) {
this.Id = Id;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Integer getCep() {
return cep;
}
public void setCep(Integer cep) {
this.cep = cep;
}
public Integer getCpf() {
return cpf;
}
public void setCpf(Integer cpf) {
this.cpf = cpf;
}
public String getSenha() {
return senha;
}
public void setSenha(String senha) {
this.senha = senha;
}
}
My 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="SA2021PU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>model.entity.Tabcadastro</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/bancodreambk?zeroDateTimeBehavior=CONVERT_TO_NULL"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.cj.jdbc.Driver"/>
<property name="javax.persistence.jdbc.password" value=""/>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
<property name="javax.persistence.schema-generation.database.action" value="create"/>
</properties>
</persistence-unit>
</persistence>
I ran into a similar issue recently, in a web app with relatively basic java code for entity persistence to a database, restful web services, and web UI code and supporting files such as images, for testing the restful services. The code was stable and functioned properly for several years, but after upgrading the environment and dev tools and rebuilding, I started getting an error during deployment to wildfly. The server produced the same stack trace - except originating from a different entity class - during deployment as described in this issue, on both wildfly 22 and 23, and a similar but not identical error on wildfly 11.
Eventually I found that the built-in deploy function in Netbeans fails, but building a war file and deploying it by hand to wildfly 23 succeeds. Specifically, the deploy function in netbeans deploys the project as a folder, projectname.war, and it fails to deploy properly in wildfly. Building the same project sources into war file in netbeans, projectname.war, and then deploying that war file by hand, by simply dropping it in the standalone deployment folder, succeeds. Whether the problem reported in the original post is due a similar issue is difficult to determine.
p.s. Here's the environment for my case:
windows 10
Apache Netbeans 12.3
adoptopenjdk's jdk-11.0.10.9-hotspot
wildfly (multiple versions tested)
postgresql 13 database running on the same box
postgresql jdbc driver 42.2.20
minimal persistence.xml referencing a jndi data source configured in wildfly
Looks like the constructor of Tabcadastro throws a RuntimeException. Did you recompile your code? Are you using some kind of Java Agent that transforms the constructor somehow?

how do I bootstrap a Spring Boot Application in wildfly?

I've built an application in Spring, and would like to get it running in wildfly. It is NOT a webapp, so the packaging is jar.
Upon startup, jboss reports that it has loaded it:
14:50:42,899 INFO [org.jboss.weld.deployer] (MSC service thread 1-2) WFLYWELD0003: Processing weld deployment APPLICATION_cnp.jar
14:50:42,949 INFO [org.jboss.weld.deployer] (MSC service thread 1-2) WFLYWELD0006: Starting Services for CDI deployment: cnp.ear
14:50:43,031 INFO [org.jboss.weld.Version] (MSC service thread 1-2) WELD-000900: 2.2.16 (SP1)
14:50:43,066 INFO [org.jboss.weld.deployer] (MSC service thread 1-3) WFLYWELD0009: Starting weld service for deployment cnp.ear
14:50:45,517 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0010: Deployed "cnp.ear" (runtime-name : "cnp.ear")
The entry point for the application is this class:
//#Configuration
//#ComponentScan
//#EnableAutoConfiguration
//3 above added as per https://stackoverflow.com/questions/35786401/
#SpringBootApplication
//3 below added to try and get java EE to bootstrap the app
//#Startup
//#Singleton
//#ApplicationScoped
public class CNPApplication {
private static final Logger log = LoggerFactory.getLogger(CNPApplication.class);
public static void main(String[] args) throws Exception {
SpringApplication.run(CNPApplication.class);
}
public CNPApplication() {
System.out.println("CNPApplication instantiated");
}
#PostConstruct
public void bootstrap() {
System.out.println("CNPApplication bootstrap");
SpringApplication.run(CNPApplication.class);
}
}
My pom file looks like this:
<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>com.mycompany</groupId>
<artifactId>APPLICATION_cnp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>APPLICATION_cnp</name>
<description>Courtesy Notification Processor</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.1.RELEASE</version>
<relativePath/>
</parent>
<properties>
<java.version>1.8</java.version>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
I've deployed it as part of an EAR. The wildfly admin console shows a deployment called cnp.ear, with a nested deployment APPLICATION_cnp.jar.
The System.out.println calls in the CNPApplication class are not being called. I've tried all the annotations at the top of the class, and I've tried adding a beans.xml. With the beans.xml added, I get a stack trace at startup: Unable to resolve a bean for 'javax.persistence.EntityManager' - This link suggested that I resolve this by removing the beans.xml because it causes JAVA EE CDI to conflict with spring.
How do I actually get the thing to run?

How to configure Wildfly 8 to use Infinispan for caching entities

I am trying to create a local infinispan cache and I know it requires to make change in config.xml of wildfly. I tried doing that and when I try to access that cache it shows cache not available. I don't know what I am doing wrong, can anybody help me on this.
Changes in config.xml are
<subsystem xmlns="urn:jboss:domain:infinispan:2.0">
<cache-container name="web" aliases="standard-session-cache" default-cache="local-web" module="org.wildfly.clustering.web.infinispan">
</cache-container>
<cache-container name="hibernate" default-cache="local-query" module="org.hibernate">
</cache-container>
//This is my local cache
<cache-container name="myCache" default-cache="cachedb">
<local-cache name="cachedb"/>
</cache-container>
</subsystem>
Here is the code to access the cache
#Stateless
public class SimpleCache {
#Resource(lookup="java:jboss/infinispan/container/myCache")
private CacheContainer container;
private org.infinispan.Cache<String, String> cache;
#PostConstruct
public void initCache() {
this.cache = container.getCache();
}
public String get(String key) {
return this.cache.get(key);
}
public void put(String key, String value) {
this.cache.put(key, value);
}
}
Error:
java:global/InfinispanTest/SimpleCache!SimpleCache
java:app/InfinispanTest/SimpleCache!SimpleCache
java:module/SimpleCache!SimpleCache
java:global/InfinispanTest/SimpleCache
java:app/InfinispanTest/SimpleCache
java:module/SimpleCache
17:05:09,721 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "InfinispanTest.war" was rolled back with failure message {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.InfinispanTest.InfinispanTest.env.SimpleCache.containerjboss.naming.context.java.jboss.infinispan.container.myCacheMissing[jboss.naming.context.java.module.InfinispanTest.InfinispanTest.env.SimpleCache.containerjboss.naming.context.java.jboss.infinispan.container.myCache]"]}
17:05:09,769 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015877: Stopped deployment InfinispanTest.war in 45ms
17:05:09,770 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014775: New missing/unsatisfied dependencies:
service jboss.naming.context.java.jboss.infinispan.container.myCache (missing) dependents: [service jboss.naming.context.java.module.InfinispanTest.InfinispanTest.env.SimpleCache.container]
17:05:09,772 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.InfinispanTest.InfinispanTest.env.SimpleCache.containerjboss.naming.context.java.jboss.infinispan.container.myCacheMissing[jboss.naming.context.java.module.InfinispanTest.InfinispanTest.env.SimpleCache.containerjboss.naming.context.java.jboss.infinispan.container.myCache]"]}}}
Have you put infinispan dependencies in your project?
Put in your META_INF/MANIFEST.MF:
dependencies: org.infinispan export

Java Based Configuration of Spring MVC project gives "The requested resource is not available."

Update: The project works in tomcat, I just wasn't browsing to the right url. This seems to be a JBoss problem.
I have been trying to follow the steps in this tutorial: http://www.mkyong.com/spring-security/spring-security-hello-world-annotation-example/
The login/logout page is accessible, and accessing a restricted page redirects to the login page correctly, but when I log in, I get a 404 error and "JBWEB000124: The requested resource is not available." I have tried running the project on JBoss and Tomcat. Here are all the files I'm using:
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.shit</groupId>
<artifactId>thing</artifactId>
<name>SecurityTest</name>
<packaging>war</packaging>
<version>1.0.0-BUILD-SNAPSHOT</version>
<properties>
<jdk.version>1.6</jdk.version>
<spring.version>3.2.8.RELEASE</spring.version>
<spring.security.version>3.2.3.RELEASE</spring.security.version>
<jstl.version>1.2</jstl.version>
</properties>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<!-- Spring 3 dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- Spring Security -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${spring.security.version}</version>
</dependency>
<!-- jstl for jsp page -->
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>${jstl.version}</version>
</dependency>
</dependencies>
</project>
AppConfig.java:
package com.shit.thing.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;
#EnableWebMvc
#Configuration
#ComponentScan({ "com.shit.thing.**" })
#Import({ SecurityConfig.class })
public class AppConfig {
#Bean
public InternalResourceViewResolver viewResolver() {
InternalResourceViewResolver viewResolver
= new InternalResourceViewResolver();
viewResolver.setViewClass(JstlView.class);
viewResolver.setPrefix("/WEB-INF/views/");
viewResolver.setSuffix(".jsp");
return viewResolver;
}
}
SecurityConfig.java:
package com.shit.thing.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
#Configuration
#EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
#Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser("mkyong").password("123456").roles("USER");
auth.inMemoryAuthentication().withUser("admin").password("123456").roles("ADMIN");
auth.inMemoryAuthentication().withUser("dba").password("123456").roles("DBA");
}
#Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/admin/**").access("hasRole('ROLE_ADMIN')")
.antMatchers("/dba/**").access("hasRole('ROLE_ADMIN') or hasRole('ROLE_DBA')")
.and().formLogin();
}
}
SecurityInitializer.java:
package com.shit.thing.core;
import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer;
public class SecurityInitializer extends AbstractSecurityWebApplicationInitializer {
//do nothing
}
SpringMvcInitializer.java:
package com.shit.thing.core;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
import com.shit.thing.config.AppConfig;
public class SpringMvcInitializer
extends AbstractAnnotationConfigDispatcherServletInitializer {
#Override
protected Class<?>[] getRootConfigClasses() {
return new Class[] { AppConfig.class };
}
#Override
protected Class<?>[] getServletConfigClasses() {
return null;
}
#Override
protected String[] getServletMappings() {
return new String[] { "/" };
}
}
HelloController.java:
package com.shit.thing.web;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
#Controller
public class HelloController {
#RequestMapping(value = { "/", "/welcome**" }, method = RequestMethod.GET)
public ModelAndView welcomePage() {
ModelAndView model = new ModelAndView();
model.addObject("title", "Spring Security Hello World");
model.addObject("message", "This is welcome page!");
model.setViewName("hello");
return model;
}
#RequestMapping(value = "/admin**", method = RequestMethod.GET)
public ModelAndView adminPage() {
ModelAndView model = new ModelAndView();
model.addObject("title", "Spring Security Hello World");
model.addObject("message", "This is protected page - Admin Page!");
model.setViewName("admin");
return model;
}
#RequestMapping(value = "/dba**", method = RequestMethod.GET)
public ModelAndView dbaPage() {
ModelAndView model = new ModelAndView();
model.addObject("title", "Spring Security Hello World");
model.addObject("message", "This is protected page - Database Page!");
model.setViewName("admin");
return model;
}
}
admin.jsp:
<%#taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%#page session="true"%>
<html>
<body>
<h1>Title : ${title}</h1>
<h1>Message : ${message}</h1>
<c:if test="${pageContext.request.userPrincipal.name != null}">
<h2>Welcome : ${pageContext.request.userPrincipal.name}
| <a href="<c:url value="/logout" />" > Logout</a></h2>
</c:if>
</body>
</html>
hello.jsp:
<%#page session="false"%>
<html>
<body>
<h1>Title : ${title}</h1>
<h1>Message : ${message}</h1>
</body>
</html>
I'm not really sure how to start debugging this, since I get no descriptive errors.
Startup Logs:
11:16:11,184 INFO [org.jboss.modules] (main) JBoss Modules version 1.3.0.Final-redhat-2
11:16:11,498 INFO [org.jboss.msc] (main) JBoss MSC version 1.0.4.GA-redhat-1
11:16:11,581 INFO [org.jboss.as] (MSC service thread 1-6) JBAS015899: JBoss EAP 6.2.0.GA (AS 7.3.0.Final-redhat-14) starting
11:16:12,679 WARN [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015002: Deployment of 'SpringProject.war' requested, but the deployment is not present
11:16:12,680 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found Rentflix.war in deployment directory. To trigger deployment create a file called Rentflix.war.dodeploy
11:16:12,680 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found SecurityTest.war in deployment directory. To trigger deployment create a file called SecurityTest.war.dodeploy
11:16:12,680 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found Copy of SecurityTest.war in deployment directory. To trigger deployment create a file called Copy of SecurityTest.war.dodeploy
11:16:12,707 INFO [org.xnio] (MSC service thread 1-2) XNIO Version 3.0.7.GA-redhat-1
11:16:12,711 INFO [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http)
11:16:12,717 INFO [org.xnio.nio] (MSC service thread 1-2) XNIO NIO Implementation Version 3.0.7.GA-redhat-1
11:16:12,729 INFO [org.jboss.remoting] (MSC service thread 1-2) JBoss Remoting version 3.2.18.GA-redhat-1
11:16:12,786 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 29) JBAS010280: Activating Infinispan subsystem.
11:16:12,793 INFO [org.jboss.as.security] (ServerService Thread Pool -- 42) JBAS013171: Activating Security Subsystem
11:16:12,802 INFO [org.jboss.as.security] (MSC service thread 1-7) JBAS013170: Current PicketBox version=4.0.19.SP2-redhat-1
11:16:12,810 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 46) JBAS015537: Activating WebServices Extension
11:16:12,873 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 37) JBAS011800: Activating Naming Subsystem
11:16:12,931 INFO [org.jboss.as.jsf] (ServerService Thread Pool -- 35) JBAS012605: Activated the following JSF Implementations: [main, 1.2]
11:16:12,968 INFO [org.jboss.as.connector.logging] (MSC service thread 1-1) JBAS010408: Starting JCA Subsystem (IronJacamar 1.0.23.Final-redhat-1)
11:16:13,013 INFO [org.jboss.as.naming] (MSC service thread 1-1) JBAS011802: Starting Naming Service
11:16:13,019 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 25) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
11:16:13,066 INFO [org.jboss.as.mail.extension] (MSC service thread 1-4) JBAS015400: Bound mail session [java:jboss/mail/Default]
11:16:13,090 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 25) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
11:16:13,096 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 25) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.fabric.jdbc.FabricMySQLDriver (version 5.1)
11:16:13,105 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 25) JBAS014612: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("jdbc-driver" => "mysql")
]): org.jboss.msc.service.DuplicateServiceException: Service jboss.jdbc-driver.mysql is already registered
at org.jboss.msc.service.ServiceRegistrationImpl.setInstance(ServiceRegistrationImpl.java:154) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]
at org.jboss.msc.service.ServiceControllerImpl.startInstallation(ServiceControllerImpl.java:227) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]
at org.jboss.msc.service.ServiceContainerImpl.install(ServiceContainerImpl.java:561) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]
at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:201) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]
at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2228) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]
at org.jboss.msc.service.ServiceBuilderImpl.install(ServiceBuilderImpl.java:307) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]
at org.jboss.as.controller.OperationContextImpl$ContextServiceBuilder.install(OperationContextImpl.java:1413) [jboss-as-controller-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.as.connector.subsystems.datasources.JdbcDriverAdd.startDriverServices(JdbcDriverAdd.java:160)
at org.jboss.as.connector.subsystems.datasources.JdbcDriverAdd.performRuntime(JdbcDriverAdd.java:118)
at org.jboss.as.controller.AbstractAddStepHandler$1.execute(AbstractAddStepHandler.java:76) [jboss-as-controller-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:607) [jboss-as-controller-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.as.controller.AbstractOperationContext.doCompleteStep(AbstractOperationContext.java:485) [jboss-as-controller-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.as.controller.AbstractOperationContext.completeStepInternal(AbstractOperationContext.java:282) [jboss-as-controller-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:277) [jboss-as-controller-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.as.controller.ParallelBootOperationStepHandler$ParallelBootTask.run(ParallelBootOperationStepHandler.java:343) [jboss-as-controller-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_45]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_45]
at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.1.Final-redhat-1.jar:2.1.1.Final-redhat-1]
11:16:13,498 INFO [org.apache.coyote.http11] (MSC service thread 1-3) JBWEB003001: Coyote HTTP/1.1 initializing on : http-localhost/127.0.0.1:8080
11:16:13,515 INFO [org.apache.coyote.http11] (MSC service thread 1-3) JBWEB003000: Coyote HTTP/1.1 starting on: http-localhost/127.0.0.1:8080
11:16:13,766 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) "JBAS014784: Failed executing subsystem datasources boot operations"
11:16:13,790 INFO [org.jboss.ws.common.management] (MSC service thread 1-2) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.2.3.Final-redhat-1
11:16:13,800 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-2) JBAS015012: Started FileSystemDeploymentService for directory C:\Program Files (x86)\EAP-6.2.0\jboss-eap-6.2\standalone\deployments
11:16:13,805 INFO [org.jboss.as.server.deployment] (MSC service thread 1-6) JBAS015876: Starting deployment of "SecurityTest.war" (runtime-name: "SecurityTest.war")
11:16:13,828 INFO [org.jboss.as.remoting] (MSC service thread 1-1) JBAS017100: Listening on 127.0.0.1:4447
11:16:14,051 INFO [org.apache.coyote.http11] (MSC service thread 1-4) JBWEB003001: Coyote HTTP/1.1 initializing on : http-localhost/127.0.0.1:8443
11:16:14,052 INFO [org.apache.coyote.http11] (MSC service thread 1-4) JBWEB003000: Coyote HTTP/1.1 starting on: http-localhost/127.0.0.1:8443
11:16:14,080 INFO [org.jboss.as.remoting] (MSC service thread 1-4) JBAS017100: Listening on 127.0.0.1:9999
11:16:15,228 WARN [org.jboss.as.ee] (MSC service thread 1-6) JBAS011006: Not installing optional component org.springframework.web.context.request.async.StandardServletAsyncWebRequest due to an exception (enable DEBUG log level to see the cause)
11:16:15,389 INFO [org.jboss.web] (ServerService Thread Pool -- 64) JBAS018210: Register web context: /SecurityTest
11:16:15,424 INFO [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/SecurityTest]] (ServerService Thread Pool -- 64) Spring WebApplicationInitializers detected on classpath: [com.shit.thing.core.SpringMvcInitializer#3759b60a, com.shit.thing.core.SecurityInitializer#62be66e9]
11:16:15,555 INFO [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/SecurityTest]] (ServerService Thread Pool -- 64) Initializing Spring root WebApplicationContext
11:16:16,450 INFO [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/SecurityTest]] (ServerService Thread Pool -- 64) Initializing Spring FrameworkServlet 'dispatcher'
11:16:16,533 INFO [org.jboss.as.server] (ServerService Thread Pool -- 26) JBAS018559: Deployed "SecurityTest.war" (runtime-name : "SecurityTest.war")
you can configure your standalone.xml in jboss server
virtual-server name="default-host" enable-welcome-root="false">
use false instead of true in enable-welcome-root, if this doesn't work check out web.xml and look out whether the controller entry is correct over there or not.
use this as web.xml template to initialize application context and to load dispatcher servlet ---
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>security-services</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/application-context.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/application-context.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/service/*</url-pattern>
</servlet-mapping>
</web-app>

producing EntityManager throws __FIRST_PHASE__ is missing

Here's my error
ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 2) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "test.war")]) - failure description: {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"test.war#primary\".__FIRST_PHASE__ is missing [jboss.naming.context.java.jboss.datasources.KitchensinkQuickstartTestDS]"]}
ERROR [org.jboss.as.server] (management-handler-thread - 2) JBAS015870: Deploy of deployment "test.war" was rolled back with the following failure message: {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"test.war#primary\".__FIRST_PHASE__ is missing [jboss.naming.context.java.jboss.datasources.KitchensinkQuickstartTestDS]"]}
and the caused by portion of the stack trace
Caused by: java.lang.Exception: "JBAS014807: Management resource '[(\"deployment\" => \"test.war\")]' not found"
at org.jboss.as.controller.client.helpers.standalone.impl.ServerDeploymentPlanResultFuture.getActionResult(ServerDeploymentPlanResultFuture.java:134) ~[wildfly-controller-client-8.0.0.Final.jar:8.0.0.Final]
at org.jboss.as.controller.client.helpers.standalone.impl.ServerDeploymentPlanResultFuture.getResultFromNode(ServerDeploymentPlanResultFuture.java:123) ~[wildfly-controller-client-8.0.0.Final.jar:8.0.0.Final]
at org.jboss.as.controller.client.helpers.standalone.impl.ServerDeploymentPlanResultFuture.get(ServerDeploymentPlanResultFuture.java:85) ~[wildfly-controller-client-8.0.0.Final.jar:8.0.0.Final]
at org.jboss.as.controller.client.helpers.standalone.impl.ServerDeploymentPlanResultFuture.get(ServerDeploymentPlanResultFuture.java:42) ~[wildfly-controller-client-8.0.0.Final.jar:8.0.0.Final]
and relevant log output
2014-03-25 00:06:26,543 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 3) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "test.war")]) - failure description: {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"test.war#primary\".__FIRST_PHASE__ is missing [jboss.naming.context.java.jboss.datasources.KitchensinkQuickstartTestDS]"]}
2014-03-25 00:06:26,544 ERROR [org.jboss.as.server] (management-handler-thread - 3) JBAS015870: Deploy of deployment "test.war" was rolled back with the following failure message: {"JBAS014771: Services with missing/unavailable dependencies" => jboss.persistenceunit.\"test.war#primary\".__FIRST_PHASE__ is missing [jboss.naming.context.java.jboss.datasources.KitchensinkQuickstartTestDS]"]}
2014-03-25 00:06:26,551 INFO [org.jboss.as.server.deployment] (MSC service thread 1-8) JBAS015877: Stopped deployment test.war (runtime-name: test.war) in 7ms
2014-03-25 00:06:26,552 INFO [org.jboss.as.controller] (management-handler-thread - 3) JBAS014774: Service status report
JBAS014775: New missing/unsatisfied dependencies:
service jboss.naming.context.java.jboss.datasources.KitchensinkQuickstartTestDS (missing) dependents: [service jboss.persistenceunit."test.war#primary".__FIRST_PHASE__]
service jboss.persistenceunit."test.war#primary".__FIRST_PHASE__ (missing) dependents: [service jboss.deployment.unit."test.war".POST_MODULE]
2014-03-25 00:06:26,558 DEBUG [org.jboss.as.controller.management-operation] (management-handler-thread - 4) JBAS014616: Operation ("undeploy") failed - address: ([("deployment" => "test.war")]) - failure description: "JBAS014807: Management resource '[(\"deployment\" => \"test.war\")]' not found"
2014-03-25 00:06:26,586 DEBUG [org.jboss.as.controller.management-operation] (management-handler-thread - 2) Entered VERIFY stage; waiting for service container to settle
2014-03-25 00:06:26,595 INFO [org.jboss.as.controller] (management-handler-thread - 2) JBAS014774: Service status report
JBAS014776: Newly corrected services:
service jboss.naming.context.java.jboss.datasources.KitchensinkQuickstartTestDS (no longer required)
service jboss.persistenceunit."test.war#primary".__FIRST_PHASE__ (no longer required)
Here's the contents of my Jar
ar = 64668e4f-f815-495a-a612-bc1c9c87b4cc.jar:
/com/
/com/lm/
/com/lm/infrastructure/
/com/lm/infrastructure/Regex.class
/com/lm/infrastructure/SystemServices.class
/com/lm/infrastructure/RegexTest.class
/com/lm/infrastructure/JacksonProducer.class
/com/lm/model/
/com/lm/model/Identifiable.class
/com/lm/model/Page.class
/com/lm/model/Entity.class
/com/lm/model/Buildable.class
/com/lm/model/Wirer.class
/com/lm/model/BaseIdentifierDTO.class
/com/lm/model/Factory.class
/com/lm/model/EntityBuilder.class
/com/lm/model/Director.class
/com/lm/model/Builder.class
/com/lm/model/Identifier.class
/com/lm/model/Repository.class
/com/lm/test/
/com/lm/test/TestBase.class
/com/lm/test/UnitTest.class
/com/lm/test/RESTCtrlTestBase.class
/com/lm/test/TestUtil.class
/com/lm/activity/
/com/lm/activity/persistence/
/com/lm/activity/persistence/inmemory/
/com/lm/activity/persistence/inmemory/ActivityInventoryMemUnitTest.class
/com/lm/activity/persistence/inmemory/ActivitiesMemUnitTest.class
/com/lm/activity/persistence/inmemory/ActivityInventoryMem.class
/com/lm/activity/persistence/inmemory/ActivitiesMem.class
/com/lm/activity/UnitTestBaseForActivity.class
/com/lm/activity/SimplyDescriptive.class
/com/lm/activity/Activity$Builder.class
/com/lm/activity/ActivityId.class
/com/lm/activity/ActivitiesRepo.class
/com/lm/activity/FactoryBuilderActivity.class
/com/lm/activity/ActivityInventory.class
/com/lm/activity/Activity$DTO.class
/com/lm/activity/Activity.class
/com/lm/activity/ActivityCompleted.class
/com/lm/activity/Activity_.class
/com/lm/activity/ActivityId$DTO.class
/com/lm/activity/ToDoUnitTest.class
/com/lm/activity/ActivityUnitTest.class
/com/lm/activity/TestBaseForActivity.class
/com/lm/activity/ActivityEvent.class
/com/lm/activity/BuilderActivityPermaURI.class
/com/lm/activity/Descriptive.class
/com/lm/activity/ToDo.class
/com/lm/activity/DomainEvent.class
/com/lm/activity/Individual.class
/META-INF/
/META-INF/logback.xml
/META-INF/test-ds.xml
/META-INF/beans.xml
/META-INF/persistence.xml
here's my 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="primary">
<jta-data-source>java:jboss/datasources/KitchensinkQuickstartTestDS</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.show_sql" value="false" />
</properties>
</persistence-unit>
</persistence>
test-ds.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- This is an unmanaged datasource. It should be used for proofs of concept
or testing only. It uses H2, an in memory database that ships with JBoss
AS. -->
<datasources xmlns="http://www.jboss.org/ironjacamar/schema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd">
<!-- The datasource is bound into JNDI at this location. We reference
this in META-INF/test-persistence.xml -->
<datasource jndi-name="java:jboss/datasources/KitchensinkQuickstartTestDS"
pool-name="kitchensink-quickstart-test" enabled="true"
use-java-context="true">
<connection-url>jdbc:h2:mem:kitchensink-quickstart-test</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
</datasources>
SystemServices class
public class SystemServices {
#SuppressWarnings( "unused" )
#Produces
#PersistenceContext
private EntityManager em;
#Produces
public Logger prLogger( InjectionPoint ip ) {
return LoggerFactory.getLogger(
ip.getMember().getDeclaringClass().getName()
);
}
}
I don't have any entities yet that have any annotations, so I'd think that it should be able to produce the EntityManager without it causing problems.
The error says that jboss is missing your datasource. Which JBoss/Wildfly version are you using?
Please check first whether JBoss can work with your datasource using f.i. the web console (localhost:9090/console -> Profile -> Datasources).
You can also configure your datasource in standalone.xml but whether this is an appropriate approach or not depends on your setup but I would prefer the standalone.xml approach.
I thought the *-ds.xml datasource configuration file has to be deployed separately, not with the jar. Please have a look here for datasource configurations. I think this could cause your problem since JBoss parses the persistence.xml before deploying the datasource definition and failing at the Persistence manager initialization.

Categories