-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 
Author Message
 Post subject: Preparing JBOSS JDBC DataSource for use with Hibernate
PostPosted: Sun Mar 27, 2005 4:46 pm 
Regular
Regular

Joined: Thu Aug 05, 2004 11:15 pm
Posts: 50
In the Hibernate tutorial at hibernate.org/66.html
the first step is to:

Preparing JBOSS JDBC DataSource for use with Hibernate

And the process to complete this step was:

Please refer to JBoss docs, or examples included in JBoss distribution.

Now I am not sure what to do or how to get started on this step.

Any help appreciated.

Thank you,
John


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 27, 2005 5:31 pm 
Senior
Senior

Joined: Fri May 14, 2004 9:37 am
Posts: 122
Location: Cologne, Germany
Hi John,

Download a JBoss Dist in JBOSS_HOME/docs/examples/jca you'll find an example datasource for nearly every Database vendor. Pick the ds.xml of the database of your choice and modify it to your needs then copy it to the servers deploy directory (JBOSS_HOME/server/app_name/deploy) you want to use. I normally make a copy of the default dir and then rename it to the app_name I'm using. Then also place the JDBC jar in the Lib dir of JBoss (JBOSS_HOME/server/app_name/lib) that's all.

_________________
regards

Olaf

vote if it helped


Top
 Profile  
 
 Post subject: Reply
PostPosted: Sun Mar 27, 2005 5:53 pm 
Regular
Regular

Joined: Thu Aug 05, 2004 11:15 pm
Posts: 50
Hey Thanx for ur help!

Just to check I did it right, so I'm deciding to use MySQL. So in the ds.xml file does:

<jndi-name>MySqlDS</jndi-name>

so does that name mater at all or can I name it anything?

Also the jdbc jar file if I am not mistaken is the
mysql-connector-java-3.0.14-production-bin.jar
right?

Hey thanks a lot,
John


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 27, 2005 6:04 pm 
Regular
Regular

Joined: Thu Aug 05, 2004 11:15 pm
Posts: 50
Another question cuz I am a newbie at this:

In Step 3 it says to prepare a subdirectory like this:

org/mytest/objects/MasterAccount.class
org/mytest/objects/SubAccount.class
org/mytest/objects/Password.class
mappings/MasterAccount.hbm.xml
mappings/SubAccount.hbm.xml
mappings/Password.hbm.xml
META-INF/

This means like create the org/mytest/objects folder and mappings folder and META-INF folder in the {JBOSS_HOME}/server/default folder right? By the way, so every single .class file I have will be in the objects folder and every single mapping file will be in the mappings folder?

Thanx again,
John


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 27, 2005 6:38 pm 
Regular
Regular

Joined: Thu Aug 05, 2004 11:15 pm
Posts: 50
Oh about the question with whether the MySqlDS name matters or not, I guess it is used in Step 4 in the Hibernate service MBean configuration so the name has to macth up if I am not mistaken.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 27, 2005 6:40 pm 
Senior
Senior

Joined: Fri May 14, 2004 9:37 am
Posts: 122
Location: Cologne, Germany
Hi John,

First of all the name inside the ds.xml is the JNDI name it will bound to
I normally build a sar (har if JBoss > 3.2.6 ) file that contains all files required. This can be done by an ant task like the following (It's for JBoss 3.2.5) :
Code:

<target name="build-sar" depends="compile">
      <jar jarfile="${DIST}/hibernate.sar" index="true">
         <metainf dir="${basedir}/conf">
            <include name="jboss-service.xml" />
         </metainf>
         <fileset dir="${basedir}/src/java" includes="mappings/*.hbm.xml" />
         <fileset dir="${LIB}">
            <include name="cglib-full-2.0.2.jar" />
            <include name="asm.jar" />
            <include name="odmg-3.0.jar" />
            <include name="commons-collections-2.1.1.jar" />
            <include name="commons-lang-1.0.1.jar" />
            <include name="commons-logging-1.0.4.jar" />
            <include name="dom4j-1.4.jar" />
            <include name="ehcache-0.9.jar" />
            <include name="hibernate2.jar" />
         </fileset>
         <fileset dir="${basedir}/conf" includes="treecache.xml"/>
         <fileset dir="${BUILD}/classes" includes="org/mytest/objects/*.class" />
      </jar>
   </target>


The jboss-service.xml looks like:
Code:

<server>
<mbean code="org.hibernate.jmx.HibernateService" name="jboss.jca:service=HibernateTicketsystem,name=HibernateService">
   <depends>jboss.jca:service=RARDeployer</depends>
   <!-- the following line must be changed to MySQLDS if the database is MySQL else PostgresDS -->
    <!--depends>jboss.jca:service=LocalTxCM,name=PostgresDS</depends-->
   <!--depends>jboss.jca:service=LocalTxCM,name=MySQLDS</depends-->
    <attribute name="MapResources">mappings/MasterAccount.hbm.xml,          mappings/SubAccount.hbm.xml,
                       ....
    </attribute>
    <attribute name="JndiName">java:/HibernateService</attribute>
   <!-- the following line must be changed to java:/MySQLDS if the database is MySQL else PostgresDS-->
    <attribute name="Datasource">java:/PostgresDS</attribute>
    <!--attribute name="Datasource">java:/MySQLDS</attribute-->
   <!-- the following line must be changed to org.hibernate.dialect.MySQLDialect if the database is MySQL else PostgreSQLDialect-->
    <attribute name="Dialect">org.hibernate.dialect.PostgreSQLDialect</attribute>
    <!--attribute name="Dialect">org.hibernate.dialect.MySQLDialect</attribute-->
    <attribute name="TransactionStrategy">org.hibernate.transaction.JTATransactionFactory</attribute>
    <attribute name="TransactionManagerLookupStrategy">org.hibernate.transaction.JBossTransactionManagerLookup</attribute>
    <attribute name="CacheProvider">org.hibernate.cache.TreeCacheProvider</attribute>   
    <attribute name="DefaultSchema"></attribute>
   <attribute name="JdbcBatchSize">20</attribute>
   <attribute name="MaximumFetchDepth">1</attribute>
    <attribute name="ShowSql">true</attribute>
    <attribute name="QueryCacheEnabled">true</attribute>
   <attribute name="ScrollableResultSetsEnabled">false</attribute>
    <attribute name="UserTransactionName">UserTransaction</attribute>
</mbean>
</server>



For 3.2.6 take a look at the JBoss Wiki there should also be a detailed explaination. ;)

_________________
regards

Olaf

vote if it helped


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 27, 2005 7:19 pm 
Regular
Regular

Joined: Thu Aug 05, 2004 11:15 pm
Posts: 50
Just a few questions on your folder directory structure:

So in you Ant target that builds the SAR file, you have:

${DIST}, ${basedir}, ${LIB}, ${BUILD}

so let's say I am using the {JBoss_Home}/server/default/deploy folder as my directory structure:

would ${basedir} and {DIST} actually just refer to the deploy folder?
The ${LIB} refer to the default/lib folder
The ${BUILD} just refer to a directory named Build that you created in the deploy folder?

Lastly, if I created the structure default/deploy/org/mytest/objects
And same thing for the mapping files, if I had structure like default/deploy/mappings, then do I have to package my classes and mapping files any differently?
So let's say I have my class files and mapping files packaged in a folder called 'Developer' right now. Do I have to create a Developer folder in the org/mytest/objects folder or can I just include the class in the objects folder or do I have to do a: package org.mytest.objects.* . So basically would I have to change the packaging of the class or mapping files in any way?

Thank you,
John


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 28, 2005 5:00 am 
Senior
Senior

Joined: Fri May 14, 2004 9:37 am
Posts: 122
Location: Cologne, Germany
No theses variables point to the directory stucture I'm using in my eclipse project. Where ${basedir} is . and ${DIST} is ${basedir}/dist, ${LIB} is ${basedir}/lib and at least $BUILD is ${basedir}/build/classes.
Lib contains the libaries I need, dist is distribution thats the dir where I create my jar files etc. and build contains the compiled classes.
And your SAR need not to know about the directory stucture of JBoss just build it with the directory structure like described in your first posting in this thread and aftwards copy the SAR file just to the deploy (lets say JBOSS_HOME/server/default/deploy) dir of JBoss.

_________________
regards

Olaf

vote if it helped


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 02, 2005 5:07 pm 
Regular
Regular

Joined: Thu Aug 05, 2004 11:15 pm
Posts: 50
I wrote the ant-target to create the sar file and wrote the jboss.xml file. Is there an easy or simple way to see if the Hibernate Service is deployed or not? Like possibly what could I see in the code or see in the command prompt that would let me know?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.