1 2 3 Previous Next 31 Replies Latest reply: Aug 3, 2009 5:11 AM by 843833 Go to original post RSS
      • 15. Re: Running Petstore 2.0 with jboss
        843833
        File $petstore_root/bp-project/build.properties

        1.
        javaee.home=C:\jboss-5.1.0.GA 
        2.
        appserver.instance=default
        File $petstore_root/bp-project/command-line-ant-tasks.xml
        task
        <target name="run" depends="default,deploy,launch" description="builds, packages and runs the application"/>
        now looks like
        <target name="run" depends="default,tools,-pre-deploy" description="builds, packages and runs the application"/>
        File $petstore_root/setup/javadb.properties
        db.import.src=./setup/sql/javadb/cities.del
        Hope that you have downloaded the MySQL scripts from the Wiki - http://wiki.glassfish.java.net/Wiki.jsp?page=Petstore_MySql.

        File $petstore_root/setup/setup.xml
        1. target unsetup now looks like
        <target name="unsetup" depends="delete-resource-local, delete-db" />
        2. in the create-db target update teh first SQL section
        <sql driver="${db.driver}"
        encoding="utf-8"
         url="${db.admin.url}"
        userid="${db.user}"
        password="${db.password}"
        classpathref="db.classpath"
        delimiter="${db.delimiter}"
        autocommit="true"
        onerror="abort" >
        <transaction src="${db.create.src}"/>
        </sql>
        3. Update the second SQL section within the same target
        <sql driver="${db.driver}"
        encoding="utf-8"
        url="${db.url}"
        userid="${db.user}"
        password="${db.password}"
        classpathref="db.classpath"
        delimiter="${db.delimiter}"
        autocommit="true"
        onerror="abort" >
        <transaction src="${db.import.src}"/>
        </sql>
        4. Update the sql section within the delete-db target
        <sql driver="${db.driver}"
        encoding="utf-8"
        url="${db.admin.url}"
        userid="${db.user}"
        password="${db.password}"
        classpathref="db.classpath"
        delimiter="${db.delimiter}"
        autocommit="true"
        onerror="continue" > 
        <transaction src="${db.delete.src}"/>
        </sql>
        5. Target definition create-resource-local now is defined as
        <target name="create-resource-local" depends="tools">
        File $petstore_root/setup/jboss-ds.xml - this file does not exist. Create one. The contents would look like
        <?xml version="1.0" encoding="UTF-8"?>
        
        <!-- See http://www.jboss.org/community/wiki/Multiple1PC for information about local-tx-datasource -->
        <!-- $Id: mysql-ds.xml 88948 2009-05-15 14:09:08Z jesper.pedersen $ -->
        <!-- Datasource config for MySQL using 3.0.9 available from:
        http://www.mysql.com/downloads/api-jdbc-stable.html
        -->
        
        <datasources>
        <local-tx-datasource>
        <jndi-name>PetstoreDB</jndi-name>
        <connection-url>jdbc:mysql://localhost:3306/petstore</connection-url>
        <driver-class>com.mysql.jdbc.Driver</driver-class>
        <user-name>x</user-name>
        <password>y</password>
        <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
        <!-- should only be used on drivers after 3.22.1 with "ping" support
        <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
        -->
        <!-- sql to call when connection is created
        <new-connection-sql>some arbitrary sql</new-connection-sql>
        -->
        <!-- sql to call on an existing pooled connection when it is obtained from pool - MySQLValidConnectionChecker is preferred for newer drivers
        <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
        -->
        
        <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
        <min-pool-size>1</min-pool-size>
        <max-pool-size>10</max-pool-size>
        
        <metadata>
        <type-mapping>mySQL</type-mapping>
        </metadata>
        </local-tx-datasource>
        </datasources>
        Change the user name and password.

        File $petstore_root/src/conf/persistence.xml (need additions for Hibernate which is the JPA implementation in JBoss 5)
        <?xml version="1.0" encoding="UTF-8"?>
        <!-- Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: 
        http://developer.sun.com/berkeley_license.html
        $Id: persistence.xml,v 1.7 2007/04/18 19:26:07 smitha Exp $ -->
        <persistence version="1.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_1_0.xsd">
        <persistence-unit name="PetstorePu">
        <description>Petstore Persistence Unit
        </description>
        <jta-data-source>java:/PetstoreDB</jta-data-source>
         <properties>
        <property name="dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
        </properties>
        </persistence-unit>
        </persistence>
        File $petstore_root/web/WEB-INF/jboss-web.xml - create one. The contents would look like
        <?xml version="1.0" encoding="UTF-8"?>
        <jboss-web>
        <security-domain flushOnSessionInvalidation="false"/>
        <context-root>/petstore</context-root>
        <resource-ref>
        <res-ref-name>jdbc/PetstoreDB</res-ref-name>
        <jndi-name>java:PetstoreDB</jndi-name>
        </resource-ref>
        </jboss-web>
        • 16. Re: Running Petstore 2.0 with jboss
          843833
          Thanks for reply Mani.

          But I am still facing the problems. I am not using MySql, instead I am usinf the javadb provided with petstore itself.

          Also, I have made changes in xml as told by you, but still getting compilation error while making build using ant command.

          Can you be more specific about your folder structures and changes you made in xmls.??

          Does any more xml (other than those two mentioned by you) will undergo change ???
          • 17. Re: Running Petstore 2.0 with jboss
            843833
            What compilation errors do you get. Check the classpath tags in app-server-ant.xml
            <path id="javaee.classpath">
                <pathelement location="${javaee.home}/client/jboss-javaee.jar"/>
                <pathelement location="${javaee.home}/lib/jsf-api.jar"/>
                <pathelement location="${javaee.home}/lib/jsf-impl.jar"/>
                <pathelement location="${javaee.home}/lib/appserv-jstl.jar"/>
                <pathelement location="${javaee.home}/lib/commons-logging.jar"/>
                <pathelement location="${javaee.home}/bin"/>
              </path>
            
              <!-- Construct path to be used for Java DB -->
              <path id="db.classpath">
                <fileset dir="${db.root}/lib">
                  <include name="*.jar"/>
                </fileset>
              </path>
              
            • 18. Re: Running Petstore 2.0 with jboss
              843833
              I have used MySql 5.0 now, but did not get the path : C:/Program Files/MySQL/MySQL Tools for 5.0/java
              Instead I have : C:/Program Files/MySQL/MySQL Server 5.0 (which has no folder like java)

              Also still getting the compliation error on linr 77 of app-server-ant.xml which states :

              66 <target name="bpp-run-secure-app-client" depends="tools">
              67 <echo message="running application client container."/>
              68 <exec executable="${appclient}">
              69 <arg line=" -client ${app-client.jar}"/>
              70 <arg line="-name ${app-client.name}"/>
              71 <arg line="-textauth"/>
              72 <arg line="-user ${file.realm.user.id}"/>
              73 <arg line="-password ${file.realm.user.password}"/>
              74 <arg line="-xml ${javaee.domaindir}/config/sun-acc.xml"/>
              75 <arg line="${appclient.application.args}"/>
              76 </exec>
              77 </target>

              Also I think the files in bin folder as follows will change as per JBoss/bin folder :
              <!-- setup properties for various Java EE tools -->
              <property name="asadmin" value="${javaee.home}/bin/asadmin${javaee-script-suffix}"/>
              <property name="appclient" value="${javaee.home}/bin/appclient${javaee-script-suffix}"/>

              So, tell me what do you say about it... ???
              • 19. Re: Running Petstore 2.0 with jboss
                843833
                Hey, finally I have made the build using ant command.
                But, I am not able to deploy it on Jboss.
                Can you help me in that. I am getting error : deployment failed.
                • 20. Re: Running Petstore 2.0 with jboss
                  843833
                  Hi Mani,

                  I got following error while deploying he build onJBoss 5.0 :

                  Unable to retrieve orbjavax.management.InstanceNotFoundException: jboss:service=CorbaORB is not registered.

                  Any way to come out of it....???
                  • 21. Re: Running Petstore 2.0 with jboss
                    843833
                    Along with above exception, I also get a lot of SQL Exceptions :

                    Failed to execute: CREATE TABLE JBM_ID_CACHE (NODE_ID INTEGER, CNTR INTEGER, JBM_ID VARCHAR(255), PRIMARY KEY(NODE_ID, CNTR))
                    java.sql.SQLException: Table already exists: JBM_ID_CACHE in statement [CREATE TABLE JBM_ID_CACHE]
                         at org.hsqldb.jdbc.Util.sqlException(Unknown Source)

                    Failed to execute: CREATE TABLE JBM_USER (USER_ID VARCHAR(32) NOT NULL, PASSWD VARCHAR(32) NOT NULL, CLIENTID VARCHAR(128), PRIMARY KEY(USER_ID))
                    java.sql.SQLException: Table already exists: JBM_USER in statement [CREATE TABLE JBM_USER]
                         at org.hsqldb.jdbc.Util.sqlException(Unknown Source)

                    Failed to execute INSERT INTO JBM_ROLE (ROLE_ID, USER_ID) VALUES ('subscriber','john')
                    java.sql.SQLException: Violation of unique constraint SYS_PK_93: duplicate value(s) for column(s) $$
                         at org.hsqldb.jdbc.Util.sqlException(Unknown Source)

                    Failed to execute INSERT INTO JBM_ROLE (ROLE_ID, USER_ID) VALUES ('john','guest')
                    java.sql.SQLException: Violation of unique constraint SYS_PK_93: duplicate value(s) for column(s) $$
                         at org.hsqldb.jdbc.Util.sqlException(Unknown Source)

                    org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: com.mysql.jdbc.Driver; - nested throwable: (java.lang.ClassNotFoundException: com.mysql.jdbc.Driver...............

                    Caused by: org.jboss.resource.JBossResourceException: Failed to register driver for: com.mysql.jdbc.Driver; - nested throwable: (java.lang.ClassNotFoundException: com.mysql.jdbc.Driver.................

                    Could not obtain connection metadata
                    org.jboss.util.NestedSQLException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver.....................


                    Caused by: org.jboss.resource.JBossResourceException: Failed to register driver for: com.mysql.jdbc.Driver; - nested throwable: (java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from........

                    and so on......

                    I think I have not set connection properly with database.
                    So, what do you think??

                    Edited by: ronn23 on Jul 30, 2009 12:28 AM
                    • 22. Re: Running Petstore 2.0 with jboss
                      843833
                      Did you run the tasks in the following sequence
                      from petstore root folder
                      ant setup
                      ant run
                      • 23. Re: Running Petstore 2.0 with jboss
                        843833
                        yes, exactly in this sequence only...

                        So, can you tell me where did I went wrong...???

                        Edited by: ronn23 on Aug 3, 2009 3:10 AM
                        • 24. Re: Running Petstore 2.0 with jboss
                          843833
                          Also make sure the db.admin.url in app-server.properties is db.admin.url=jdbc:mysql://${javaee.server.name}:${db.port}/mysql . The value mentioned above is incorrect.
                          • 25. Re: Running Petstore 2.0 with jboss
                            843833
                            Also make sure you create the database petstore. didn't see this in any of the directions
                            • 26. Re: Running Petstore 2.0 with jboss
                              843833
                              To reiterate what ManiOnJava mentioned above. The Sun MySQL script additions added/mentioned here http://forums.sun.com/thread.jspa?threadID=5150386 will be necessary for running on MySQL.
                              Unfortunately, I could not get the cities.del file for mysql to dowload from the Glassfish wiki.
                              • 27. Re: Running Petstore 2.0 with jboss
                                843833
                                Getting closer to getting this to work running on JBoss 5.0 with Eclipse 3.4.2. I had to include the jar files bp-ui-5.jar, lucene jar and shale jar in Eclipse libraries.
                                I also had to copy the persistence.xml file to my web/WEB-INF dir in my Eclipse project.
                                • 28. Re: Running Petstore 2.0 with jboss
                                  843833
                                  I have done all the above changes as told by Mani.
                                  I have try to use MySql here, but it is crating some problem.
                                  To use javadb, can you tell me what changes I hv to do here??
                                  Also, can we use Hsql here, which is inbuilt in Jboss 5.0 ..???
                                  • 29. Re: Running Petstore 2.0 with jboss
                                    843833
                                    ronn23 I have done the above items that Mani mentioned and got as far as getting my MySQL scripts to load. Though it wasn't easy. I made some comments that you may want to reference that were as apparent or highlighted well. There was one mysql script file that would not work, the cities.del, and I tried going to the web link for downloading the attachment as mentioned here http://wiki.glassfish.java.net/Wiki.jsp?page=Petstore_MySql but could not figure out how to download the mysql version of the file. so currently the cities are not loaded.

                                    I'm currently stuck trying to get the project to run in JBoss. I'm trying Eclipse which is my comfort zone, but may try to use the ant script to deploy this.