JBOSS 7 MYSQL missing dependencies error - mysql

There are many threads like this one already for similar errors but none which have solved my problem so after an hour of trying to debug it, I have decide to ask for help.
Background
I am setting up a Java EE project. I have create an enterprise application and have create an EJB project, JPA project and web Project and added EAR's to the enterprise project.
I have also added mysql-connector-java-5.1.0-bin to the JBOSS/standalone/deployments folder. And added to this jar file to the JPA project.
Any advice on how to solve the error would be greatly apprecited.
The main error is:
missing/unavailable dependencies" =>
["jboss.persistenceunit.\"SIMSProject.ear#primary\"jboss.naming.context.java.jboss.datasources.SIMSD
Here is my full error:
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from [Module "org.hibernate:main" from local module loader #32008dad (roots: C:\Users\Bawn92\Desktop\Programs\jboss-as-7.1.1.Final\modules)]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
at java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_07]
at java.lang.Class.forName(Class.java:186) [rt.jar:1.7.0_07]
at org.hibernate.internal.util.ReflectHelper.classForName(ReflectHelper.java:192)
at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:101)
... 23 more
01:50:40,265 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "SIMSProject.ear" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.persistenceunit.\"SIMSProject.ear#SIMSJPA\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"SIMSProject.ear#SIMSJPA\": Failed to start service"},"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"SIMSProject.ear#primary\"jboss.naming.context.java.jboss.datasources.SIMSDBMissing[jboss.persistenceunit.\"SIMSProject.ear#primary\"jboss.naming.context.java.jboss.datasources.SIMSDB]"]}
01:50:40,296 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015877: Stopped deployment SIMSWebProject.war in 31ms
01:50:40,296 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015877: Stopped deployment SIMSEJB.jar in 31ms
01:50:40,309 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015877: Stopped deployment SIMSProject.ear in 44ms
01:50:40,312 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014777: Services which failed to start: service jboss.persistenceunit."SIMSProject.ear#SIMSJPA": org.jboss.msc.service.StartException in service jboss.persistenceunit."SIMSProject.ear#SIMSJPA": Failed to start service
01:50:40,316 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.persistenceunit.\"SIMSProject.ear#SIMSJPA\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"SIMSProject.ear#SIMSJPA\": Failed to start service"},"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"SIMSProject.ear#primary\"jboss.naming.context.java.jboss.datasources.SIMSDBMissing[jboss.persistenceunit.\"SIMSProject.ear#primary\"jboss.naming.context.java.jboss.datasources.SIMSDB]"]}}}
MY -ds.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<datasources xmlns="http://www.jboss.org/ironjacamar/schema">
<datasource jndi-name="java:jboss/datasources/SIMSDB" enabled="true"
use-java-context="true" pool-name="SIMSDB">
<connection-url>jdbc:mysql://localhost:3306/mydb</connection-url>
<driver>mysql-connector-java-5.1.0-bin.jar</driver>
<pool></pool>
<security>
<user-name>root</user-name>
<password>nbuser</password>
</security>
</datasource>
</datasources>
My persistence.xml file is:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="primary">
<jta-data-source>java:jboss/datasources/SIMSDB</jta-data-source>
<properties>
<property name="hibernate.show_sql" value="false" />
</properties>
</persistence-unit>
<persistence-unit name="SIMSJPA">
<class>model.Class</class>
<class>model.Subject</class>
<class>model.Teacher</class>
<properties>
<!-- //i put in dialect line -->
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.connection.username" value="root"/>
<property name="hibernate.connection.password" value="nbuser"/>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/mydb"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
</properties>
</persistence-unit>
</persistence>
The datasourse section of my Standalone file is:
<datasource jndi-name="java:jboss/datasources/SIMSDB" pool-name="SIMSDB">
<connection-url>jdbc:mysql://localhost:3306/mydb</connection-url>
<driver>mysql-connector-java-5.1.0-bin.jar</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>test</user-name>
<password>test</password>
</security>
<statement>
<prepared-statement-cache-size>32</prepared-statement-cache-size>
<share-prepared-statements/>
</statement>
</datasource>
<drivers>
<driver name="com.mysql" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>

You need to create MySQL driver module.
JBoss 7 will be able to use if you create it like this:
download the driver (jar file)
create directory in you server path: {$jboss-home}/modules/com/mysql/main
and paste the driver jar file here
in same folder create and new file module.xml
Insert following code in that module.xml (if your jar file is named mysql.jdbc.jar):
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
<resources>
<resource-root path="mysql.jdbc.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
Make sure the dependencies for your mysql.jdbc.jar are OK.
JBoss 7 is not using -ds.xml any more.
You allready doing setup for your databse in standalon.xml, this the right way.
Just make sure your migration is correct. I see you have diffent user name and password...
EDIT1:
I don't know how hibernate works with JBoss 7.
But I see you should try to change in your persistence.xml
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
to
<property name="hibernate.connection.driver_class" value="com.mysql"/>
because you are using com.mysql as module name. Otherwise you can change module name to com.mysql.jdbc.Driver.
In your standalone.xml
change
<driver>mysql-connector-java-5.1.0-bin.jar</driver>
to
<driver>com.mysql</driver>
because you gave com.mysql as name for your driver:
<driver name="com.mysql" module="com.mysql">

Related

Unable to build Hibernate SessionFactory

in a jakarta - wildfly project when i try to run the project this error message appears.
Deploying on WildFly Application Server
profile mode: false
debug mode: false
force redeploy: true
Undeploying ...
Initial deploying EutopeanDynamics-shop-2022 to C:\Program Files\wildfly-27.0.1.Final\standalone\deployments\WebEshop.war
Completed initial distribution of EutopeanDynamics-shop-2022
Deploying C:\Program Files\wildfly-27.0.1.Final\standalone\deployments\WebEshop.war
"{\"WFLYCTL0080: Failed services\" => {\"jboss.persistenceunit.\\\"WebEshop.war#Persistence\\\"\" => \"jakarta.persistence.PersistenceException: [PersistenceUnit: Persistence] Unable to build Hibernate SessionFactory
Caused by: jakarta.persistence.PersistenceException: [PersistenceUnit: Persistence] Unable to build Hibernate SessionFactory
Caused by: org.hibernate.exception.GenericJDBCException: Unable to open JDBC Connection for DDL execution
Caused by: java.sql.SQLException: jakarta.resource.ResourceException: IJ000453: Unable to get managed connection for java:/MySqlDS
Caused by: jakarta.resource.ResourceException: IJ000453: Unable to get managed connection for java:/MySqlDS
Caused by: jakarta.resource.ResourceException: IJ031084: Unable to create connection
Caused by: java.sql.SQLException: Access denied for user 'admin'#'localhost' (using password: YES)\"}}"
Here is my persistence class
<?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="Persistence" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>java:/MySqlDS</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="validate"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.globally_quoted_identifiers" value="true"/>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
</properties>
</persistence-unit>
</persistence>
I am using wildfly application server. The server is running and from localhost:9990 i created a datasource pointing in an empty database called 'eshop" as shown in the image above
enter image description here

Mysql Driver class com.mysql.jdbc.Driver is not a valid javax.sql.DataSource implementation from wildfly

maybe my setup is quite special, but I do have issues when I define a JDBC Datasource for Java EE container in my web.xml file.
I configured my Datasource in my web.xml as follow:
<data-source>
<name>java:app/myapp/DS</name>
<class-name>com.mysql.jdbc.Driver</class-name>
<url>jdbc:mysql://localhost:3306/database?useSSL=false&allowPublicKeyRetrieval=true</url>
<user>foo</user>
<password>pass</password>
<transactional>true</transactional>
<isolation-level>TRANSACTION_READ_COMMITTED</isolation-level>
<initial-pool-size>2</initial-pool-size>
<max-pool-size>10</max-pool-size>
<min-pool-size>5</min-pool-size>
<max-statements>0</max-statements>
</data-source>
After I use datasource's name as my jta-data-source in my persistence file as follow:
<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="java-rs-with-hibernate" transaction-type="JTA">
<jta-data-source>java:app/myapp/DS</jta-data-source>
<class>com.patrickhub.ch.java_rs_with_hibernate.domain.Product</class>
<properties>
<property name="javax.persistence.schema-generation.database.action" value="none"/>
<property name="javax.persistence.schema-generation.scripts.action" value="none"/>
</properties>
</persistence-unit>
</persistence>
And in my code I used the EntityManager to make request to the database.
But when I deploy it to wildfly 18.0.1, I get the following errors:
at org.jboss.as.connector#18.0.1.Final//org.jboss.as.connector.subsystems.datasources.AbstractDataSourceService.start(AbstractDataSourceService.java:174)
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:1363)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.jboss.jca.deployers.common.DeployException: WFLYJCA0030: unable to deploy
at org.jboss.as.connector#18.0.1.Final//org.jboss.as.connector.subsystems.datasources.AbstractDataSourceService$AS7DataSourceDeployer.deploy(AbstractDataSourceService.java:376)
at org.jboss.as.connector#18.0.1.Final//org.jboss.as.connector.subsystems.datasources.AbstractDataSourceService.start(AbstractDataSourceService.java:160)
... 8 more
Caused by: org.jboss.as.controller.OperationFailedException: WFLYJCA0117: com.mysql.jdbc.Driver is not a valid javax.sql.DataSource implementation [ "WFLYJCA0117: com.mysql.jdbc.Driver is not a valid javax.sql.DataSource implementation" ]
... 10 more
I think that if I replace com.mysql.jdbc.Driver with com.mysql.jc.jdbc.Driver, it will deploy successfully but I still have the same problem and the same message error.
I don't know if I miss something on how to define a mysql JDBC datasource in web.xml file. but I think it is correct.
Please can someone help me.

"WFLYJCA0041: Failed to load module for driver [com.mysql]" on Jboss 7 with MySQL database

I am creating a web application for JBoss EAP 7 and trying to connect to MySQL 8.0 database.
Am getting the error as
[org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 39) WFLYCTL0013: Operation ("add") failed - address: ([("subsystem" => "datasources"),
("jdbc-driver" => "mysql")]) - failure description: "WFLYJCA0041: Failed to load module for driver [com.mysql]"
My module.xml file in \jboss-eap-7.1.0\modules\system\layers\base\com\mysql\main is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-8.0.12" />
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
And placed "mysql-connector-java-8.0.12.jar" in \jboss-eap-7.1.0\modules\system\layers\base\com\mysql\main path where module.xml exist.
Datasource configuraion is:
<datasources>
<datasource jta="true" jndi-name="java:jboss/datasources/jdbc/sdmspool" pool-name="sdmspool" enabled="true" use-java-context="true">
<connection-url>jdbc:sqlserver://database;databaseName = sdms</connection-url>
<driver>mysql-connector-java-8.0.12</driver>
<security>
<user-name>user</user-name>
<password>password</password>
</security>
</datasource>
<drivers>
<driver name="mysql-connector-java-8.0.12" module="com.mysql">
<driver-class>com.mysql.jdbc.Driver</driver-class>
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
Can anyone help me in solving this?
Try creating the module by using jboss-cli as follows:
Run the below commands:
./jboss-cli.sh (this will start cli in disconnected mode,in the same mode run the below command)
module add --name=com.mysql --resources=/path/to/mysql.jar --dependencies=javax.api,javax.transaction.api
and then try adding respective driver in your eap configuration.
You don't have to explicitly define driver-class and xa-datasource-class.
resource root path should be as well mysql-connector-java-8.0.12.jar
please note that the extension (.jar) is missing in your xml config

arquillian, wildfly change datasource to mysql - error missing/unsatisfied dependencies

i have working arquillian tests that use default h2/mem data base. now i want to switch to my sql.
I first copied mysql-connector-java-5.1.33-bin.jar to standalone/deployments. The log confirmed proper deployment. I also tried to setup the mysql datasource via wildfly's admin console and it worked fine (i did connection test but didn't add the datasource).
I want to keep the datasource setup within project's test. So i added the data source to src/test/resources/test-ds.xml:
<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">
<datasource jndi-name="java:jboss/datasources/moritzTimetrackerTestDSmysql"
pool-name="moritzTimetracker-test" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/moritztimetracker</connection-url>
<driver>mysql-connector-java-5.1.33-bin.jar</driver>
<security>
<user-name>user</user-name>
<password>pass</password>
</security>
</datasource>
The src/test/resources/META-INF/test-persistence.xml looks like this:
<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="primary">
<jta-data-source>java:jboss/datasources/moritzTimetrackerTestDSmysql</jta-data-source>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.show_sql" value="false" />
</properties>
</persistence-unit>
</persistence>
But if i run the test i get exception:
org.jboss.arquillian.container.spi.client.container.DeploymentException: Cannot deploy: test.war
...
Caused by: java.lang.Exception: {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.data-source.java:jboss/datasources/moritzTimetrackerTestDSmysql is missing [jboss.jdbc-driver.mysql-connector-java-5_1_33-bin_jar]"]}
The log says:
JBAS014775: New missing/unsatisfied dependencies:
service jboss.data-source.java:jboss/datasources/moritzTimetrackerTestDSmysql (missing) dependents: [service jboss.data-source.reference-factory.java:jboss/datasources/moritzTimetrackerTestDSmysql]
service jboss.data-source.reference-factory.java:jboss/datasources/moritzTimetrackerTestDSmysql (missing) dependents: [service jboss.naming.context.java.jboss.datasources.moritzTimetrackerTestDSmysql]
service jboss.jdbc-driver.mysql-connector-java-5_1_33-bin_jar (missing) dependents: [service jboss.data-source.java:jboss/datasources/moritzTimetrackerTestDSmysql]
service jboss.persistenceunit."test.war#primary".__FIRST_PHASE__ (missing) dependents: [service jboss.deployment.unit."test.war".POST_MODULE]
How to correctly setup mysql as data source?
Your setup seems correct (I mean data source and persistence xml).
But please check whether you are deploying test-ds.xml file along with your app in every test case. I mean:
#Deployment
public static Archive<?> createDeployment() {
return ShrinkWrap.create(WebArchive.class, "test.war")
.addAsResource("META-INF/test-persistence.xml", "META-INF/persistence.xml")
.addAsWebInfResource("test-ds.xml") /* CRUCIAL STEP */
...
}
In this way, your data source definition is deployed with every micro deployment of your EJBs.
Since it is very badly documented i viewed the standalone.xml after i created the data source via the admin web interface. Setting the mysql datasource this way works fine:
<datasource jndi-name="java:jboss/datasources/testDSmysql"
pool-name="test" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/db</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver>mysql-connector-java-5.1.33-bin.jar_com.mysql.jdbc.Driver_5_1</driver>
<security>
<user-name>user</user-name>
<password>pass</password>
</security>
</datasource>
See "drive-class" and "driver" - it is very different than stuff you read in documentation?!

JBoss server exception while connecting to mysql

I have recently tried JPA program with jboss and eclipse. For connecting to MySQL i have put in the required mySQL-connector JAR in the JBoss installation directory path and I have added the configuration in the standalone.xml of jboss and with that if i start the jboss from eclipse it starts up fine and it shows me the configured connection as well.
But if i add my ejb program and start the server it is giving me the following error and when i searched to solve this, each of the forum is giving me different solutions, but nothing seems to address my problem.
ERROR
17:34:17,195 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC00001: Failed to start service
jboss.deployment.unit."FirstEJBProject.jar".INSTALL:
org.jboss.msc.service.StartException in service
jboss.deployment.unit."FirstEJBProject.jar".INSTALL: Failed to process
phase INSTALL of deployment "FirstEJBProject.jar" at
org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119)
[jboss-as-server-7.1.1.Final.jar:7.1.1.Final] at
org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
[jboss-msc-1.0.2.GA.jar:1.0.2.GA] at
org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
[jboss-msc-1.0.2.GA.jar:1.0.2.GA] at
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
[rt.jar:1.7.0_13] at
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
[rt.jar:1.7.0_13] at java.lang.Thread.run(Unknown Source)
[rt.jar:1.7.0_13] Caused by: java.lang.IllegalArgumentException: Empty
name segment is not allowed for java at
org.jboss.msc.service.ServiceName.of(ServiceName.java:85)
[jboss-msc-1.0.2.GA.jar:1.0.2.GA] at
org.jboss.msc.service.ServiceName.append(ServiceName.java:112)
[jboss-msc-1.0.2.GA.jar:1.0.2.GA] at
org.jboss.as.naming.deployment.ContextNames.buildServiceName(ContextNames.java:178)
at
org.jboss.as.naming.deployment.ContextNames$BindInfo.(ContextNames.java:190)
at
org.jboss.as.naming.deployment.ContextNames$BindInfo.(ContextNames.java:181)
at
org.jboss.as.naming.deployment.ContextNames.bindInfoFor(ContextNames.java:124)
at
org.jboss.as.naming.deployment.ContextNames.bindInfoForEnvEntry(ContextNames.java:165)
at
org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.deployPersistenceUnit(PersistenceUnitDeploymentProcessor.java:319)
at
org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.addPuService(PersistenceUnitDeploymentProcessor.java:258)
at
org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.handleJarDeployment(PersistenceUnitDeploymentProcessor.java:145)
at
org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.deploy(PersistenceUnitDeploymentProcessor.java:120)
at
org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113)
[jboss-as-server-7.1.1.Final.jar:7.1.1.Final] ... 5 more
17:34:17,430 INFO [org.jboss.as.server] (DeploymentScanner-threads -
2) JBAS015870: Deploy of deployment "FirstEJBProject.jar" was rolled
back with failure message {"JBAS014671: Failed services" =>
{"jboss.deployment.unit.\"FirstEJBProject.jar\".INSTALL" =>
"org.jboss.msc.service.StartException in service
jboss.deployment.unit.\"FirstEJBProject.jar\".INSTALL: Failed to
process phase INSTALL of deployment
\"FirstEJBProject.jar\""},"JBAS014771: Services with
missing/unavailable dependencies" =>
["jboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic.Validatorjboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogicMissing[jboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic.Validatorjboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic]","jboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic.ValidatorFactoryjboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogicMissing[jboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic.ValidatorFactoryjboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic]"]}
17:34:17,430 INFO [org.jboss.as.server.deployment] (MSC service
thread 1-2) JBAS015877: Stopped deployment FirstEJBProject.jar in 13ms
17:34:17,445 INFO [org.jboss.as.controller]
(DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014775: New missing/unsatisfied dependencies:
service jboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic
(missing) dependents: [service
jboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic.ValidatorFactory,
service
jboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic.Validator]
JBAS014777: Services which failed to start: service
jboss.deployment.unit."FirstEJBProject.jar".INSTALL:
org.jboss.msc.service.StartException in service
jboss.deployment.unit."FirstEJBProject.jar".INSTALL: Failed to process
phase INSTALL of deployment "FirstEJBProject.jar"
17:34:17,461 ERROR [org.jboss.as.server.deployment.scanner]
(DeploymentScanner-threads - 1) {"JBAS014653: Composite operation
failed and was rolled back. Steps that failed:" => {"Operation step-2"
=> {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"FirstEJBProject.jar\".INSTALL" =>
"org.jboss.msc.service.StartException in service
jboss.deployment.unit.\"FirstEJBProject.jar\".INSTALL: Failed to
process phase INSTALL of deployment
\"FirstEJBProject.jar\""},"JBAS014771: Services with
missing/unavailable dependencies" =>
["jboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic.Validatorjboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogicMissing[jboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic.Validatorjboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic]","jboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic.ValidatorFactoryjboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogicMissing[jboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic.ValidatorFactoryjboss.naming.context.java.comp.FirstEJBProject.FirstEJBProject.StudentLogic]"]}}}
persistence.xml
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
version="1.0">
<!-- MySQL DataSource -->
<persistence-unit name="STUD">
<jta-data-source>java:/</jta-data-source>
<properties>
<property name="showSql" value="true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
</properties>
</persistence-unit>
sstandalone.xml
<datasource jndi-name="java:/mydb" pool-name="my_pool" enabled="true" jta="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:mysql://localhost:3306/myschema</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<password>password</password>
</security>
<statement>
<prepared-statement-cache-size>
100
</prepared-statement-cache-size>
<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="mysql" module="com.mysql"/>
</drivers>
</datasources>
Am I missing something here.
I have tried using mySQL-ds.xml and if i use that it is giving a different error as the datasource is unresolvable. It will be helpful if i know the solution for that as well since will packaging my program and deploying there is no need for me to do the SQL connections in the JBoss again.
Thank You.
The problem was with the <jta-data-source>java:/</jta-data-source> I need to fill in the same name as i have provided in <datasource jndi-name="java:/mydb" so finally fixed it myself, thank you for everyones help.
The fixed persistence XML code
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
version="1.0">
<!-- MySQL DataSource -->
<persistence-unit name="STUD">
<jta-data-source>java:/mydb</jta-data-source>
<properties>
<property name="showSql" value="true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
</properties>
</persistence-unit>
Hope this will help
You will need to define <driver>mysql</driver. This is typically done by defining a module. You can find all about it here http://bnlconsulting.com/index.php/blog/item/88-jboss-71-adding-mysql-datasource