-->
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.  [ 3 posts ] 
Author Message
 Post subject: Must I use hibernate.cfg.xml if I use Jboss-service.xml?
PostPosted: Fri Sep 17, 2004 10:47 pm 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
Hi everyone:

I had see this article:http://www.hibernate.org/66.html .I directory structure is:
Code:
META-INF/jboss-service.xml
WEB-INF/classes/hibernate.cfg.xml
WEB-INF/classes/mapping.hbm.xml
WEB-INF/classes/org.company.test.TestHiber
................................


My jboss-service.xml is:
Code:
  <mbean code="net.sf.hibernate.jmx.HibernateService" name="jboss.jca:service=HibernateFactory,
                            name=HibernateFactory">
    <depends>jboss.jca:service=RARDeployer</depends>
    <depends>jboss.jca:service=LocalTxCM,name=MySqlDS</depends>
    <!-- Make it deploy ONLY after DataSource had been started -->
   
    <attribute name="MapResources">classes/Trade.hbm.xml</attribute>
    <attribute name="JndiName">java:/hibernate/HibernateFactory</attribute>
   
    <attribute name="Dialect">net.sf.hibernate.dialect.MySQLDialect</attribute>
    <attribute name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionFactory</attribute>
    <attribute name="TransactionManagerLookupStrategy">net.sf.hibernate.transaction.JBossTransactionManagerLookup</attribute>
<attribute name="Datasource">java:/MySqlDS</attribute>
    <attribute name="ShowSql">true</attribute>
    <attribute name="UserTransactionName">UserTransaction</attribute>
</mbean>


The mysql-ds.xml is:
Code:
<datasources>
   <local-tx-datasource>
      <jndi-name>MySqlDS</jndi-name>
      <connection-url>jdbc:mysql://localhost:3306/fangtoo</connection-url>
      <driver-class>com.mysql.jdbc.Driver</driver-class>
      <user-name>name</user-name>
      <password>pass</password>
   </local-tx-datasource>
</datasources>


I want to know whether it is nessecery to write a hibernate.cfg.xml. If I don't write the hibernate.cfg.xml,JBoss report error when I run the web app,error info is :
Code:
10:54:32,421 INFO  [Environment] Hibernate 2.1.6
10:54:32,541 INFO  [Environment] hibernate.properties not found
10:54:32,631 INFO  [Environment] using CGLIB reflection optimizer
10:54:33,402 INFO  [Configuration] configuring from resource: /hibernate.cfg.xml

10:54:33,402 INFO  [Configuration] Configuration resource: /hibernate.cfg.xml
10:54:34,113 INFO  [Configuration] Mapping resource: Trade.hbm.xml
10:54:37,368 INFO  [Binder] Mapping class: lyo.test.bean.Trade -> tradetest
10:54:42,265 INFO  [Configuration] Configured SessionFactory: null
10:54:42,265 INFO  [Configuration] processing one-to-many association mappings
10:54:42,265 INFO  [Configuration] processing one-to-one association property re
ferences
10:54:42,265 INFO  [Configuration] processing foreign key constraints
10:54:42,565 INFO  [Dialect] Using dialect: net.sf.hibernate.dialect.MySQLDialec
t
10:54:42,585 INFO  [SettingsFactory] Maximim outer join fetch depth: 2
10:54:57,287 INFO  [SettingsFactory] Use outer join fetching: true
10:54:57,327 WARN  [UserSuppliedConnectionProvider] No connection properties spe
cified - the user must supply JDBC connections
10:54:57,377 INFO  [TransactionManagerLookupFactory] No TransactionManagerLookup
configured (in JTA environment, use of process level read-write cache is not re
commended)
10:54:57,377 INFO  [SettingsFactory] Use scrollable result sets: false
10:54:57,377 INFO  [SettingsFactory] Use JDBC3 getGeneratedKeys(): false
10:54:57,377 INFO  [SettingsFactory] Optimize cache for minimal puts: false
10:54:57,377 INFO  [SettingsFactory] echoing all SQL to stdout
10:54:57,407 INFO  [SettingsFactory] Query language substitutions: {}
10:54:57,407 INFO  [SettingsFactory] cache provider: net.sf.hibernate.cache.OSCa
cheProvider
10:54:57,477 INFO  [Config] Properties {cache.capacity=1000}
10:54:57,487 INFO  [Configuration] instantiating and configuring caches
10:54:57,587 INFO  [Config] Properties {cache.capacity=1000}
10:55:07,461 INFO  [GeneralCacheAdministrator] Constructed GeneralCacheAdministr
ator()
10:55:13,009 INFO  [SessionFactoryImpl] building session factory
10:55:18,697 INFO  [SessionFactoryObjectFactory] Not binding factory to JNDI, no
JNDI name configured
10:55:19,088 INFO  [STDOUT] java.lang.UnsupportedOperationException: The user mu
st supply a JDBC connection
10:55:19,098 INFO  [STDOUT]     at net.sf.hibernate.connection.UserSuppliedConne
ctionProvider.getConnection(UserSuppliedConnectionProvider.java:32)
10:55:19,098 INFO  [STDOUT]     at net.sf.hibernate.impl.BatcherImpl.openConnect
ion(BatcherImpl.java:286)
10:55:19,098 INFO  [STDOUT]     at net.sf.hibernate.impl.SessionImpl.connect(Ses
sionImpl.java:3326)
10:55:19,098 INFO  [STDOUT]     at net.sf.hibernate.impl.SessionImpl.connection(
SessionImpl.java:3286)
10:55:19,098 INFO  [STDOUT]     at net.sf.hibernate.transaction.JDBCTransaction.
begin(JDBCTransaction.java:40)
10:55:19,108 INFO  [STDOUT]     at net.sf.hibernate.transaction.JDBCTransactionF
actory.beginTransaction(JDBCTransactionFactory.java:19)
10:55:19,108 INFO  [STDOUT]     at net.sf.hibernate.impl.SessionImpl.beginTransa
ction(SessionImpl.java:2231)
10:55:19,108 INFO  [STDOUT]     at lyo.test.service.TradeDAOImpl.getTrades(Trade
DAOImpl.java:29)
10:55:19,208 INFO  [STDOUT]     at lyo.test.bean.ValidatorBean.validate(Validato
rBean.java:24)
10:55:19,218 INFO  [STDOUT]     at com.digital.test.action.LogonAction.execute(L
ogonAction.java:28)
10:55:19,218 INFO  [STDOUT]     at org.apache.struts.action.RequestProcessor.pro
cessActionPerform(RequestProcessor.java:421)
10:55:19,218 INFO  [STDOUT]     at org.apache.struts.action.RequestProcessor.pro
cess(RequestProcessor.java:226)
10:55:19,218 INFO  [STDOUT]     at org.apache.struts.action.ActionServlet.proces
s(ActionServlet.java:1158)
10:55:19,218 INFO  [STDOUT]     at org.apache.struts.action.ActionServlet.doPost
(ActionServlet.java:415)
10:55:19,218 INFO  [STDOUT]     at javax.servlet.http.HttpServlet.service(HttpSe
rvlet.java:717)
10:55:19,218 INFO  [STDOUT]     at javax.servlet.http.HttpServlet.service(HttpSe
rvlet.java:810)
10:55:19,218 INFO  [STDOUT]     at org.apache.catalina.core.ApplicationFilterCha
in.internalDoFilter(ApplicationFilterChain.java:237)
10:55:19,218 INFO  [STDOUT]     at org.apache.catalina.core.ApplicationFilterCha
...........................................
..........................................


Must I use two config file jboss-service.xml and hibernate.cfg.xml if I use JBoss as my Server? Thks!

_________________
You are not alone...


Top
 Profile  
 
 Post subject: T
PostPosted: Fri Sep 17, 2004 10:51 pm 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
I think this code:
Code:
<attribute name="Datasource">java:/MySqlDS</attribute>


in my jboss-service.xml is the dataSource. But why jboss can't find it? I must write the code:
Code:

<property name="connection.datasource">java:/MySqlDS</property>

in my hibernate.cfg.xml then jboss don't report that exception. why?

_________________
You are not alone...


Top
 Profile  
 
 Post subject: I know it!
PostPosted: Sat Sep 18, 2004 4:18 am 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
I solve this problem . The jboss-service.xml must be placed under the *.sar dir. JBoss will locate it when it started . :-)

_________________
You are not alone...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.