I can configure MySQL DataSource in standalone.xml file and it works fine. But I want to set up a DataSource using the @DataSourceDefinition annotation.
How to configure MySQL data source using @DataSourceDefinition in JBoss AS7?
I have already tried:
@DataSourceDefinition( className = "com.mysql.jdbc.Driver", name = "java:global/jdbc/MyDS", serverName="localhost", portNumber=3306, user = "root", password = "admin", databaseName = "test" ) @Startup public class DBConfig { }
along with this persistence.xml :
<?xml version="1.0" encoding="UTF-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> <persistence-unit name="javaee6-app" transaction-type="JTA"> <jta-data-source>java:global/jdbc/MyDS</jta-data-source> <properties> <property name="hibernate.hbm2ddl.auto" value="update"/> <property name="hibernate.show_sql" value="true"/> </properties> </persistence-unit> </persistence>
I have a mysql connector jar file in WEB-INF/lib .
But when I deploy the application, I get this error:
(DeploymentScanner-threads - 2) {"JBAS014653: The composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014771: services with missing / inaccessible dependencies" => ["jboss.persistenceunit. \" Javaee6-app.war # javaee6-app \ "jboss.naming.context.java.global.jdbc.MyDSMissing [jboss. persistenceunit. \" javaee6-app.war # javaee6-application \ " jboss.naming.context.java.global.jdbc.MyDS] "]}}}
K. Siva Prasad Reddy
source share