hibernate error when hbm2ddl.auto set to update - java

when i set the hibernate.hbm2ddl.auto value to create i get no errors,
but when i set it to update i get an error.
i need to create the tables and update them so i need the value to be update.
any ideas for what could go wrong?
here is the error:
15:55:19,148 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "WebService.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"WebService.war#swap\"" => "javax.persistence.PersistenceException: [PersistenceUnit: swap] Unable to build Hibernate SessionFactory
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: swap] Unable to build Hibernate SessionFactory
Caused by: org.hibernate.exception.SQLGrammarException: Unable to build DatabaseInformation
Caused by: org.h2.jdbc.JdbcSQLException: Table \"PG_CLASS\" not found; SQL statement:
select relname from pg_class where relkind='S' [42102-193]"}}
15:55:19,154 INFO [org.jboss.as.server] (ServerService Thread Pool -- 37) WFLYSRV0010: Deployed "WebService.war" (runtime-name : "WebService.war")
15:55:19,155 INFO [org.jboss.as.server] (ServerService Thread Pool -- 37) WFLYSRV0010: Deployed "test.war" (runtime-name : "test.war")
15:55:19,155 INFO [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0186: Services which failed to start: service jboss.persistenceunit."WebService.war#swap": javax.persistence.PersistenceException: [PersistenceUnit: swap] Unable to build Hibernate SessionFactory
and here is my persistence xml file:
<?xml version="1.0" encoding="UTF-8"?>
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
org.hibernate.jpa.HibernatePersistenceProvider
<class>org.Swap.WebService.Model.User</class>
<class>org.Swap.WebService.Model.BaseEntity</class>
<properties>
<!-- Hibernate properties -->
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.connection.zeroDateTimeBehavior" value="convertToNull" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
<!-- Database properties -->
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" /> <!-- DB Driver -->
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://127.0.0.1:5432/swap" /> <!-- BD Mane -->
<property name="javax.persistence.jdbc.user" value="hidden" /> <!-- DB User -->
<property name="javax.persistence.jdbc.password" value="hidden" /> <!-- DB Password -->
</properties>
</persistence-unit>
Edit:
if i start the wildfly with
<property name="hibernate.hbm2ddl.auto" value="create"/>
then setting it up to update and publishing it will work until i restart wildfly.
can it be a problem with wildfly loading?
EDIT2:
here is the datasouces from my standalone xml:
<datasources>
<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>
<datasource jta="false" jndi-name="java:jboss/datasources/swap" pool-name="swap" enabled="true" use-java-context="true">
<connection-url>jdbc:postgresql://127.0.0.1:5432/swap?useUnicode=yes&characterEncoding=UTF-8</connection-url>
<driver>org.postgresql</driver>
<security>
<user-name>postgres</user-name>
<password>postgres</password>
</security>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name="org.postgresql" module="org.postgresql">
<driver-class>org.postgresql.Driver</driver-class>
<xa-datasource-class>org.postgresql.Driver</xa-datasource-class>
</driver>
</drivers>
</datasources>

The problem is about dialect and driver set.
Your hibernate uses H2 driver with Postgres dialect.
Caused by: org.h2.jdbc.JdbcSQLException:
you can see in hibernate logs, what driver and dialect it uses.
Here is fragment showing how hibernate logs should look like:
INFO [Version] - HHH000412: Hibernate Core {4.3.7.Final}
INFO [Environment] - HHH000206: hibernate.properties not found
INFO [Environment] - HHH000021: Bytecode provider name : javassist
INFO [MppNamingStrategy] - using naming strategy: MppNamingStrategy
INFO [Version] - HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
DEBUG [JdbcServicesImpl] - Driver ->
name : H2 JDBC Driver
version : 1.4.196 (2017-06-10)
major : 1
minor : 4
DEBUG [JdbcServicesImpl] - JDBC version : 4.0
INFO [Dialect] - HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
INFO [ASTQueryTranslatorFactory] - HHH000397: Using ASTQueryTranslatorFactory
INFO [Version] - HV000001: Hibernate Validator 4.3.2.Final
INFO [SchemaValidator] - HHH000229: Running schema validator
You can see in this example that hibernate uses
H2 JDBC Driver
org.hibernate.dialect.H2Dialect
In your stacktrace we can see that your hibernate uses postgres dialect (OK), but with H2 driver (bad)

Thanks to przemek hertel i managed to get it to work.
i remove the h2 from the datasource and driver
<datasources>
<datasource jndi-name="java:jboss/datasources/swap" pool-name="swap" enabled="true" use-java-context="true">
<connection-url>jdbc:postgresql://127.0.0.1:5432/swap?useUnicode=yes&characterEncoding=UTF-8</connection-url>
<driver>org.postgresql</driver>
<security>
<user-name>postgres</user-name>
<password>postgres</password>
</security>
</datasource>
<drivers>
<driver name="org.postgresql" module="org.postgresql">
<driver-class>org.postgresql.Driver</driver-class>
<xa-datasource-class>org.postgresql.Driver</xa-datasource-class>
</driver>
</drivers>
</datasources>
and i removed this line:
<default-bindings context-service="java:jboss/ee/concurrency/context/default" datasource="java:jboss/datasources/ExampleDS" managed-executor-service="java:jboss/ee/concurrency/executor/default" managed-scheduled-executor-service="java:jboss/ee/concurrency/scheduler/default" managed-thread-factory="java:jboss/ee/concurrency/factory/default"/>
and now it is working!
thank you all for the help.

Related

Wildfly server doesn't work, errors WFLYCTL0412 & WFLYCTL0180

I am trying to add a mysql datasource to my wildfly 26 server and when I deploy it I encounter the following error:
I saved a copy of my standalone and tried to redo it, since I've heard the xml can be quite tricky, however that didn't change anything. Also looked for blankspaces in the beginning of each xml document as per another stackoverflow post - but no bueno.
13:07:14,521 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "ISProjectEAR.ear")]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => ["jboss.naming.context.java.jboss.datasources.jdbc.dsLabs"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.persistenceunit.\"ISProjectEAR.ear/ISEJBProject.jar#LabEJBSql\" is missing [jboss.naming.context.java.jboss.datasources.jdbc.dsLabs]",
"jboss.persistenceunit.\"ISProjectEAR.ear/ISEJBProject.jar#LabEJBSql\".__FIRST_PHASE__ is missing [jboss.naming.context.java.jboss.datasources.jdbc.dsLabs]"
]
}
13:07:14,675 INFO [org.jboss.as.server] (ServerService Thread Pool -- 45) WFLYSRV0010: Deployed "ISProjectEAR.ear" (runtime-name : "ISProjectEAR.ear")
13:07:14,727 INFO [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0184: New missing/unsatisfied dependencies:
service jboss.naming.context.java.jboss.datasources.jdbc.dsLabs (missing) dependents: [service jboss.persistenceunit."ISProjectEAR.ear/ISEJBProject.jar#LabEJBSql", service jboss.persistenceunit."ISProjectEAR.ear/ISEJBProject.jar#LabEJBSql".__FIRST_PHASE__]
WFLYCTL0448: 33 additional services are down due to their dependencies being missing or failed
13:07:14,864 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
13:07:14,873 ERROR [org.jboss.as] (Controller Boot Thread) WFLYSRV0026: WildFly Full 26.0.0.Final (WildFly Core 18.0.0.Final) started (with errors) in 16170ms - Started 607 of 832 services (43 services failed or missing dependencies, 347 services are lazy, passive or on-demand)
13:07:14,878 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
13:07:14,879 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
Here's my module.xml
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="com.microsoft.sqlserver.jdbc">
<resources>
<resource-root path="sqljdbc4.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true"/>
</dependencies>
</module>
This is the datasource from my standalone.xml
<datasources>
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true" statistics-enabled="${wildfly.datasources.statistics-enabled:${wildfly.statistics-enabled:false}}">
<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>
<datasource jta="true" jndi-name="java:jboss/datasources/jdbc/dsLabs" pool-name="MysqlDS" enabled="true" use-ccm="false" statistics-enabled="true">
<connection-url>jdbc:sqlserver://localhost:1433; databaseName=T4Lab;</connection-url>
<driver>sqljdbc4</driver>
<security>
<user-name>Din anvandare</user-name>
<password>Ditt password</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
<background-validation-millis>1</background-validation-millis>
</validation>
<statement>
<prepared-statement-cache-size>0</prepared-statement-cache-size>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name="sqljdbc4" module="com.microsoft.sqlserver.jdbc">
<xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
Here's the persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="LabEJBSql">
<jta-data-source>java:jboss/datasources/jdbc/dsLabs</jta-data-source>
<non-jta-data-source>java:jboss/datasources/jdbc/dsLabs</non-jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"></property>
<property name="hibernate.hbm2ddl.auto" value="update"/>
</properties>
</persistence-unit>
</persistence>

Hibernate/JPA not creating tables

I'm running an Java EE application on Wildfly 15.0.1. I'm trying to use JPA without creating datasource on wildfly, because I want all the dependencies to be packed in application source code. I am using Maven to build the WAR.
I am using PostgreSQL and it's up and running on http://localhost:5432 I create db called testing for this project.
So, I added this dependency to my pom.xml:
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.5</version>
</dependency>
My persistence.xml is in src/main/resources/META-INF/persistence.xml:
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.2"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
<persistence-unit name="pu1">
<!-- classes -->
<class>myapp.model.Address</class>
<class>myapp.model.Transaction</class>
<properties>
<!-- database connection -->
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/testing" />
<property name="javax.persistence.jdbc.user" value="postgres" />
<property name="javax.persistence.jdbc.password" value="postgres" />
<!-- hibernate -->
<property name="hibernate.hbm2ddl.auto" value="create"/>
</properties>
</persistence-unit>
I have #Entity annotation on both my Address and Transaction classes. But, nothing happens. Here's the log snippet:
22:58:05,759 INFO [org.hibernate.jpa.internal.util.LogHelper] (ServerService Thread Pool -- 103) HHH000204: Processing PersistenceUnitInfo [
name: pu1
...]
22:58:05,760 INFO [org.jboss.weld.deployer] (MSC service thread 1-5) WFLYWELD0003: Processing weld deployment myapp.backend-1.0.war
22:58:05,791 WARN [org.jboss.as.jaxrs] (MSC service thread 1-3) WFLYRS0018: Explicit usage of Jackson annotation in a JAX-RS deployment; the system will disable JSON-B processing for the current deployment. Consider setting the 'resteasy.preferJacksonOverJsonB' property to 'false' to restore JSON-B.
22:58:05,796 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) WFLYJCA0005: Deploying non-JDBC-compliant driver class org.postgresql.Driver (version 42.2)
22:58:05,810 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-8) WFLYJCA0018: Started Driver service with driver-name = myapp.backend-1.0.war_org.postgresql.Driver_42_2
22:58:05,816 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 103) WFLYJPA0010: Starting Persistence Unit (phase 2 of 2) Service 'myapp.backend-1.0.war#pu1'
22:58:05,817 INFO [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 103) HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL94Dialect
22:58:05,820 INFO [org.hibernate.type.BasicTypeRegistry] (ServerService Thread Pool -- 103) HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType#6543510a
22:58:05,822 INFO [org.hibernate.envers.boot.internal.EnversServiceImpl] (ServerService Thread Pool -- 103) Envers integration enabled? : true
22:58:05,858 INFO [org.hibernate.tool.schema.internal.SchemaCreatorImpl] (ServerService Thread Pool -- 103) HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl#4cc01a34'
22:58:05,858 INFO [org.hibernate.hql.internal.QueryTranslatorFactoryInitiator] (ServerService Thread Pool -- 103) HHH000397: Using ASTQueryTranslatorFactory
JPA specification:
8.2.1.2 transaction-type
The transaction-type attribute is used to specify whether the entity
managers provided by the entity manager factory for the persistence
unit must be JTA entity managers or resource-local entity managers.
The value of this element is JTA or RESOURCE_LOCAL. A transaction-type
of JTA assumes that a JTA data source will be provided—either as
specified by the jta-data-source element or provided by the container.
In general, in Java EE environments, a transaction-type of
RESOURCE_LOCAL assumes that a non-JTA datasource will be provided. In
a Java EE environment, if this element is not specified, the default
is JTA. In a Java SE environment, if this element is not specified,
the default is RESOURCE_LOCAL.
JTA is default transaction type in EE application server. To use it you need a datasource configured in WildFly. Then add it to persistence.xml:
<persistence-unit name="pu1" transaction-type="JTA">
<!-- classes -->
<class>myapp.model.Address</class>
<class>myapp.model.Transaction</class>
<properties>
<jta-data-source>jdbc/jndi_name_of_datasource</jta-data-source>
<!-- hibernate -->
<property name="hibernate.hbm2ddl.auto" value="create"/>
</properties>
</persistence-unit>

jboss error: java.lang.NoSuchMethodError: org.hibernate.internal.CoreMessageLogger.debugf(Ljava/lang/String;I)V

I'm trying to create a simple hello world java web application that is using JPA through hibernate and using JBoss 6.4.0 as application Server. The application has been created through maven. Furthermore I'm using Intellij as an IDE. However when I run the application Server I receive the following error:
16:09:04,772 INFO [org.hibernate.Version] (ServerService Thread Pool -- 25) HHH000412: Hibernate Core {5.3.7.Final}
16:09:04,774 INFO [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 25) HHH000206: hibernate.properties not found
16:09:04,970 INFO [org.hibernate.annotations.common.Version] (ServerService Thread Pool -- 25) HCANN000001: Hibernate Commons Annotations {5.0.4.Final}
16:09:05,141 WARN [org.hibernate.orm.connections.pooling] (ServerService Thread Pool -- 25) HHH10001002: Using Hibernate built-in connection pool (not for production use!)
16:09:05,145 INFO [org.hibernate.orm.connections.pooling] (ServerService Thread Pool -- 25) HHH10001005: using driver [com.mysql.cj.jdbc.Driver] at URL [jdbc:mysql://localhost:3306/testdb]
16:09:05,146 INFO [org.hibernate.orm.connections.pooling] (ServerService Thread Pool -- 25) HHH10001001: Connection properties: {user=smattes, password=****}
16:09:05,147 INFO [org.hibernate.orm.connections.pooling] (ServerService Thread Pool -- 25) HHH10001003: Autocommit mode: false
16:09:05,150 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 25) MSC000001: Failed to start service jboss.persistenceunit.javahelloworld#NewPersistenceUnit: org.jboss.msc.service.StartException in service jboss.persistenceunit.javahelloworld#NewPersistenceUnit: java.lang.NoSuchMethodError: org.hibernate.internal.CoreMessageLogger.debugf(Ljava/lang/String;I)V
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:103)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [rt.jar:1.8.0_191]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [rt.jar:1.8.0_191]
at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_191]
at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.2.Final-redhat-1.jar:2.1.2.Final-redhat-1]
Caused by: java.lang.NoSuchMethodError: org.hibernate.internal.CoreMessageLogger.debugf(Ljava/lang/String;I)V
at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections.<init>(DriverManagerConnectionProviderImpl.java:276)
at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections.<init>(DriverManagerConnectionProviderImpl.java:260)
at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections$Builder.build(DriverManagerConnectionProviderImpl.java:401)
at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.buildPool(DriverManagerConnectionProviderImpl.java:112)
at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:75)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:100)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:246)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.buildJdbcConnectionAccess(JdbcEnvironmentInitiator.java:145)
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:66)
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:94)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:152)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:179)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:119)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:904)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:935)
at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:141)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:200)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$600(PersistenceUnitServiceImpl.java:57)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:99)
... 4 more
16:09:05,164 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 2) JBAS014612: Operation ("deploy") failed - address: ([("deployment" => "javahelloworld")]) - failure description: {"JBAS014671: Failed services" => {"jboss.persistenceunit.javahelloworld#NewPersistenceUnit" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.javahelloworld#NewPersistenceUnit: java.lang.NoSuchMethodError: org.hibernate.internal.CoreMessageLogger.debugf(Ljava/lang/String;I)V
Caused by: java.lang.NoSuchMethodError: org.hibernate.internal.CoreMessageLogger.debugf(Ljava/lang/String;I)V"}}
16:09:05,179 ERROR [org.jboss.as.server] (management-handler-thread - 2) JBAS015870: Deploy of deployment "javahelloworld.war" was rolled back with the following failure message:
{"JBAS014671: Failed services" => {"jboss.persistenceunit.javahelloworld#NewPersistenceUnit" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.javahelloworld#NewPersistenceUnit: java.lang.NoSuchMethodError: org.hibernate.internal.CoreMessageLogger.debugf(Ljava/lang/String;I)V
Caused by: java.lang.NoSuchMethodError: org.hibernate.internal.CoreMessageLogger.debugf(Ljava/lang/String;I)V"}}
16:09:05,211 INFO [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015877: Stopped deployment javahelloworld (runtime-name: javahelloworld.war) in 42ms
16:09:05,213 INFO [org.jboss.as.controller] (management-handler-thread - 2) JBAS014774: Service status report
The persistence.xml file is the following:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" version="2.1">
<persistence-unit name="NewPersistenceUnit">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>jpa.AuthorsEntity</class>
<class>jpa.UserEntity</class>
<properties>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/testdb"/>
<property name="hibernate.connection.driver_class" value="com.mysql.cj.jdbc.Driver"/>
<property name="hibernate.connection.username" value="myusername"/>
<property name="hibernate.connection.password" value="mypassword"/>
<property name="hibernate.archive.autodetection" value="class"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hbm2ddl.auto" value="update"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.DB2400Dialect"/>
</properties>
</persistence-unit>
</persistence>
and the jpa.AuthorsEntity and jpa.UserEntity are two java Entity classes that correspond to the tables authors and user correspondingly.
Any help would be appreciated.
Such errors are typically caused by having different versions of a library on the compile time and runtime classpath.
Application servers - such as JBoss - typically provide their own versions of the Hibernate libraries at runtime. This version is then most likely incompatible with the compile time version specified in your POM.
JBoss AS 6.4 only supports JPA spec 2. You can then either roll-back the compile time Hibernate version in your POM to be compatible with the runtime dependency supplied by JBoss or, if you really need JPA 2.1 features, tell JBoss you are bundling the Hibernate libraries with your app.
For the former approach, this document indicates EAP 6.4 supports Hibarnate 4.2.18.Final
https://access.redhat.com/articles/112673#EAP_6
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.2.18.Final</version>
<!-- Don't bundle in the WAR as provided by the server -->
<scope>provided</scope>
</dependency>
Check there are no hibernate libs in the deployed war (as a result of transitive dependencies for example).
For the latter approach see here:
https://issues.jboss.org/browse/WFCORE-209?_sscc=t
for future readers, recently i had this issues, i had in the project the hibernate version 5.1 with glassfish 4.1 and it is generated this issues, for resolved i agregated in the WEB-INF folder the file glassfish-web.xml
as i showing to continuation
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app error-url="">
<class-loader delegate="false"/>
</glassfish-web-app>

WildFly jdbc connection with Sybase

I'm trying to migrate from Glassfish to WildFly 10, my app connects whit Sybase ASE database. I put jconn3.jar in WILDFLY_HOME\modules\system\layers\base\com\sybase\sybase\main, created modules.xml with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.sybase.sybase">
<resources>
<resource-root path="jconn3.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
and inserted to the standalone.xml:
<datasources>
<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>
<datasource jndi-name="java:jboss/datasources/FRAME_IBS" pool-name="FRAME_IBS" enabled="true" use-java-context="true">
<connection-url>jdbc:sybase:Tds:localhost:5000/Banksys;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
<driver>sybase</driver>
<pool>
<min-pool-size>5</min-pool-size>
<max-pool-size>100</max-pool-size>
<prefill>true</prefill>
</pool>
<driver-class>
com.sybase.jdbc3.jdbc.SybDriver
</driver-class>
<security>
<user-name>admin</user-name>
<password>admin</password>
</security>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name="sybase" module="com.sybase.sybase">
<datasource-class>com.sybase.jdbc3.jdbc.SybDataSource</datasource-class>
<xa-datasource-class>com.sybase.jdbc3.jdbc.SybXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
I got this error in server.log file when I started WF:
2017-02-17 12:48:56,297 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "FRAME_IBS")
]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => ["jboss.jdbc-driver.sybase"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.driver-demander.java:jboss/datasources/FRAME_IBS is missing [jboss.jdbc-driver.sybase]",
"org.wildfly.data-source.FRAME_IBS is missing [jboss.jdbc-driver.sybase]"
]
}
2017-02-17 12:48:56,297 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "FRAME_IBS")
]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => [
"jboss.jdbc-driver.sybase",
"jboss.jdbc-driver.sybase"
],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.driver-demander.java:jboss/datasources/FRAME_IBS is missing [jboss.jdbc-driver.sybase]",
"org.wildfly.data-source.FRAME_IBS is missing [jboss.jdbc-driver.sybase]",
"org.wildfly.data-source.FRAME_IBS is missing [jboss.jdbc-driver.sybase]"
]
}
2017-02-17 12:48:56,453 INFO [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0184: New missing/unsatisfied dependencies:
service jboss.jdbc-driver.sybase (missing) dependents: [service org.wildfly.data-source.FRAME_IBS, service jboss.driver-demander.java:jboss/datasources/FRAME_IBS]
I googled it and tried all that I found but still have this error. Please, help me.
Excuse if my english it´s not correct, it's not my native language.
I rename module and move it to WILDFLY_HOME\modules following Leozeo and Mark recommendations, and still have the same message. I remove my datasource from standalone.xml, run WF again, and I se this message:
ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 33) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("jdbc-driver" => "sybase")
File module.xml and .jar are both present now in WILDFLY_HOME\modules
Make sure you have driver installed properly. Check for driver jar and modules.xml file is present at under WILDFLY_HOME\modules\system\layers\base\com\sybase\main directory.
update value of name attribute
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.sybase">
<resources>
<resource-root path="jconn3.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>

Unable to fill pool: when starting jboss application

My project jboss project is based on spring mvc. When I run the app I get the following error:
Unable to fill pool
Datasource configuration
<!-- JNDI setup -->
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:jboss/datasources/SSDiaryDS</value>
</property>
</bean>
mysql mapping in jboss standalone.xml
<datasource jndi-name="java:jboss/datasources/SSDiaryDS" pool-name="SSDiaryDSPool">
<connection-url>jdbc:mysql://localhost:3306/schooldairy</connection-url>
<driver>com.mysql</driver>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>100</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>root</user-name>
<password>password</password>
</security>
<statement>
<prepared-statement-cache-size>32</prepared-statement-cache-size>
<share-prepared-statements>true</share-prepared-statements>
</statement>
</datasource>
I encountered the same problem with the following stacktrace:
00:18:41,862 WARN [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (JCA PoolFiller) IJ000610: Unable to fill pool: javax.resource.ResourceException: Could not create connection
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:277)
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:235)
at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.createConnectionEventListener(SemaphoreArrayListManagedConnectionPool.java:761) [ironjacamar-core-impl-1.0.9.Final.jar:1.0.9.Final]
at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.fillToMin(SemaphoreArrayListManagedConnectionPool.java:706) [ironjacamar-core-impl-1.0.9.Final.jar:1.0.9.Final]
at org.jboss.jca.core.connectionmanager.pool.mcp.PoolFiller.run(PoolFiller.java:97) [ironjacamar-core-impl-1.0.9.Final.jar:1.0.9.Final]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_79]
Caused by: java.sql.SQLException: I/O Error: Connection reset
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2311)
at net.sourceforge.jtds.jdbc.TdsCore.login(TdsCore.java:603)
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:345)
at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:249)
... 5 more
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:196) [rt.jar:1.7.0_79]
at java.net.SocketInputStream.read(SocketInputStream.java:122) [rt.jar:1.7.0_79]
at java.io.DataInputStream.readFully(DataInputStream.java:195) [rt.jar:1.7.0_79]
at java.io.DataInputStream.readFully(DataInputStream.java:169) [rt.jar:1.7.0_79]
at net.sourceforge.jtds.jdbc.SharedSocket.readPacket(SharedSocket.java:846)
at net.sourceforge.jtds.jdbc.SharedSocket.getNetPacket(SharedSocket.java:727)
at net.sourceforge.jtds.jdbc.ResponseStream.getPacket(ResponseStream.java:466)
at net.sourceforge.jtds.jdbc.ResponseStream.read(ResponseStream.java:103)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2206)
... 10 more
My solution was to terminate other java processes in my machine.
This can be caused by many things, I was wrong with this because of the mysql docker version. I changed the version from 8.0 to 5.7, it worked.
I suggest you check hostname, port, user, password and versions again.

Categories