0
votes

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.

2

2 Answers

2
votes

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

0
votes

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