7 Replies Latest reply on Mar 3, 2013 12:09 PM by Nicklas Karlsson

    mysql and JBOSS 7

    J k Newbie

      Hi

       

      I am working on the jboss-as-quickstarts-greeting project at the moment. Can someone advise me how I can adapt the project to work with mysql rather than the default jboss database? Is there a tutorial that explains all the steps necessary to do this for JBOSS AS 7

       

      Thanks

        • 1. Re: mysql and JBOSS 7
          Nicklas Karlsson Master

          Plenty of guides around if you google. Try e.g. https://docs.jboss.org/author/display/AS71/Developer+Guide (search for mysql)

          • 2. Re: mysql and JBOSS 7
            J k Newbie

            I have worked though some tutorials and added a module to the configuration but I am getting an error when I try to run the Greetings quickstart projeect. I have pasted the logs from the console below.

            Please could anyone advise what is the potential cause of this? I have placed the code from the project on GIT here https://github.com/bosra/greeter

             

            Thanks in advance

             

            18:00:23,093 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 27) JBAS014612: Operation ("enable") failed - address: ([

                ("subsystem" => "datasources"),

                ("data-source" => "my_pool")

            ]): org.jboss.msc.service.DuplicateServiceException: Service jboss.naming.context.java.jboss is already registered

                      at org.jboss.msc.service.ServiceRegistrationImpl.setInstance(ServiceRegistrationImpl.java:154) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                      at org.jboss.msc.service.ServiceControllerImpl.startInstallation(ServiceControllerImpl.java:227) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                      at org.jboss.msc.service.ServiceContainerImpl.install(ServiceContainerImpl.java:560) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                      at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:201) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                      at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2228) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                      at org.jboss.msc.service.ServiceBuilderImpl.install(ServiceBuilderImpl.java:307) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                      at org.jboss.as.controller.OperationContextImpl$ContextServiceBuilder.install(OperationContextImpl.java:921) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

                      at org.jboss.as.connector.subsystems.datasources.DataSourceEnable.addServices(DataSourceEnable.java:242) [jboss-as-connector-7.1.0.Final.jar:7.1.0.Final]

                      at org.jboss.as.connector.subsystems.datasources.DataSourceEnable$1.execute(DataSourceEnable.java:90) [jboss-as-connector-7.1.0.Final.jar:7.1.0.Final]

                      at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:387) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

                      at org.jboss.as.controller.AbstractOperationContext.doCompleteStep(AbstractOperationContext.java:274) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

                      at org.jboss.as.controller.AbstractOperationContext.completeStep(AbstractOperationContext.java:202) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

                      at org.jboss.as.connector.subsystems.datasources.DataSourceEnable$1.execute(DataSourceEnable.java:92) [jboss-as-connector-7.1.0.Final.jar:7.1.0.Final]

                      at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:387) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

                      at org.jboss.as.controller.AbstractOperationContext.doCompleteStep(AbstractOperationContext.java:274) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

                      at org.jboss.as.controller.AbstractOperationContext.completeStep(AbstractOperationContext.java:202) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

                      at org.jboss.as.controller.ParallelBootOperationStepHandler$ParallelBootTask.run(ParallelBootOperationStepHandler.java:311) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_15]

                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_15]

                      at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_15]

                      at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.0.0.GA.jar:2.0.0.GA]

             

            • 3. Re: mysql and JBOSS 7
              Nicklas Karlsson Master

              Two datasources named the same?

              • 4. Re: mysql and JBOSS 7
                J k Newbie

                Hey Nicklas

                 

                Thanks for the reply. I made some more changes and as luck would have it I am getting a new error as pasted below. I have included some shots of the standalone.xml, persistence.xml and the greeter-quickstart-ds.xml. I would be grateful if you could advise where I am making an error

                 

                Thanks

                 

                18:41:05,114 ERROR [org.jboss.as.controller] JBAS014601: Error booting the container: java.lang.RuntimeException: org.jboss.as.controller.persistence.ConfigurationPersistenceException: JBAS014676: Failed to parse configuration

                          at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:161) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

                          at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_15]

                Caused by: org.jboss.as.controller.persistence.ConfigurationPersistenceException: JBAS014676: Failed to parse configuration

                          at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:125) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

                          at org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:187) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

                          at org.jboss.as.server.ServerService.boot(ServerService.java:261) [jboss-as-server-7.1.0.Final.jar:7.1.0.Final]

                          at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:155) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

                          ... 1 more

                Caused by: com.ctc.wstx.exc.WstxParsingException: Illegal processing instruction target ("xml"); xml (case insensitive) is reserved by the specs.

                at [row,col {unknown-source}]: [1,9]

                          at com.ctc.wstx.sr.StreamScanner.constructWfcException(StreamScanner.java:606)

                          at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:479)

                          at com.ctc.wstx.sr.BasicStreamReader.readPIPrimary(BasicStreamReader.java:3891)

                          at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2025)

                          at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1102)

                          at com.ctc.wstx.sr.BasicStreamReader.nextTag(BasicStreamReader.java:1125)

                          at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:67) [staxmapper-1.1.0.Final.jar:1.1.0.Final]

                          at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:117) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

                          ... 4 more

                Standalone file

                 

                     <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</connection-url>

                                    <driver>h2</driver>

                                    <security>

                                        <user-name>sa</user-name>

                                        <password>sa</password>

                                    </security>

                                </datasource>

                                <datasource jta="true" jndi-name="java:jboss/datasources/mysql" pool-name="my_pool" enabled="true" use-java-context="true" use-ccm="true">

                                    <connection-url>jdbc:mysql://localhost:3306/jboss</connection-url>

                                    <driver>mysql</driver>

                                    <security>

                                        <user-name>root</user-name>

                                        <password>root</password>

                                    </security>

                                    <statement>

                                        <prepared-statement-cache-size>100</prepared-statement-cache-size>

                                        <share-prepared-statements>true</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">

                                        <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.mySqlxadatasource</xa-datasource-class>

                                    </driver>

                                </drivers>

                            </datasources>

                persistence.xml

                 

                <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">

                        <!-- If you are running in a production environment, add a managed

                            data source, this example data source is just for development and testing! -->

                        <!-- The datasource is deployed as WEB-INF/greeter-quickstart-ds.xml,

                            you can find it in the source at src/main/webapp/WEB-INF/greeter-quickstart-ds.xml -->

                      

                        <jta-data-source>"java:jboss/datasources/mysql"</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>

                    

                greeter-quickstart-ds.xml

                 

                <datasource jndi-name="java:jboss/datasources/mysql" pool-name="my_pool"

                            enabled="true" use-java-context="true">

                        <connection-url>jdbc:mysql://localhost:3306/jboss</connection-url>

                        <driver-class> com.mysql.jdbc.Driver </driver-class>

                        <driver> mysql-connector-java-5.1.18.jar </driver>

                        <transaction-isolation> TRANSACTION_READ_COMMITTED </transaction-isolation>

                        <pool>

                            <min-pool-size> 200 </min-pool-size>

                            <max-pool-size> 300</max-pool-size>

                            <prefill> true </prefill>

                            <use-strict-min> false </use-strict-min>

                        </pool>

                           <security>

                            <user-name>root</user-name>

                            <password>root</password>

                        </security>    

                    </datasource>

                </datasources>

                • 5. Re: mysql and JBOSS 7
                  Nicklas Karlsson Master

                  Not sure where the xml-reference comes from in the exception but I don't think you should quote the  java:jboss/datasources/mysql

                  • 6. Re: mysql and JBOSS 7
                    J k Newbie

                    Please could someone offer some help advice about this problem. JBoss has completely shut down now

                     

                    Thanks

                    • 7. Re: mysql and JBOSS 7
                      Nicklas Karlsson Master

                      Relax. Have a sip of Glenfarclas (if available). Unzip the AS. Start from scratch. Report errors here.