-->
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.  [ 6 posts ] 
Author Message
 Post subject: Using Hibernate from a Client application
PostPosted: Fri Oct 24, 2003 3:50 am 
Newbie

Joined: Fri Oct 24, 2003 3:31 am
Posts: 5
Location: Spain (Madrid)
Hello hibernate world,

I am a new hibernate user and I have found a problem, not in the hibernate product, I thing my problem is the way I want to use hibernate.

I have installed properly Hibernate in a JBoss server as a service ( see reference www.hibernate.org/66.html).

I am trying to code a client application, that is a standalone applications that try to get a HibernateFactory from a JBoss remote platform. All the examples I have seen are EJB's or Web applications but not clients.

To do that I have only changed the default JNDI Hibernate name configuration from java:/hibernate/HibernateFactory to jnp:/hibernate/HibernateFactory

I am able to create from my client a HibernateFactory reference but it is NULL. This is the used code in the main method:
...
Context jndiContext = getInitialContext();
Object ref = jndiContext.lookup("jnp:/hibernate/HibernateFactory");
...

ref is null (but there is no runtime errors)

Can anybody HELP ME? please
It is not a correct architecture to use Hibernate?

THANKS in advance


Top
 Profile  
 
 Post subject: Thick client jndi lookup of Hibernate as JBoss JMX service
PostPosted: Tue Nov 11, 2003 1:55 am 
Hi Carlos,

I also want to access the Hibernate service from a "thick" client, that is a client using a different JVM on the same machine.

After setting the Jndi name to "jnp:/hibernate/AiFactory" so that it can be reached from any JVM, I have the same problem as you. Namely the reference ends up being null.

Did anyone ever help you solve the problem?

This issue seems absolutely critical to JBoss developers.


Regards,

Eliot Clingman

P.S. Below are quotes from Mbean and the client call:
MBEAN
<server>
<mbean code="net.sf.hibernate.jmx.HibernateService" name="jboss.jca:service=HibernateFactory,
name=HibernateFactory">
<depends>jboss.jca:service=LocalTxCM,name=jdbc/OrMappingDS</depends>
<!-- Make it deploy ONLY after DataSource had been started
-->
<depends>jboss.jca:service=RARDeployer</depends>
jboss.jca:service=LocalTxCM,name=jdbc/OrMappingDS
<attribute name="MapResources">mappings/Rol.hbm.xml,mappings/User.hbm.xml,mappings/UserRol.hbm.xml,mappings/VwAppCompanySummary.hbm.xml,mappings/VwAppCompanySummarySubjectMetric.hbm.xml</attribute>
<attribute name="JndiName">jnp:/hibernate/AiFactory</attribute>
<attribute name="Datasource">java:jdbc/OrMappingDS</attribute>
<!--attribute name="Dialect">net.sf.hibernate.dialect.SybaseDialect</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="UseOuterJoin">true</attribute>
<attribute name="ShowSql">true</attribute>
<attribute name="UserTransactionName">java:/UserTransaction</attribute>
</mbean>
</server>


Client

Hashtable env = new Hashtable();
env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
env.put("java.naming.factory.url.pkgs", "org.jnp.interfaces");
env.put("java.naming.provider.url", "localhost:1099");
InitialContext myContext = new InitialContext(env);
aSessionFactory =
(SessionFactory) PortableRemoteObject.narrow(
myContext.lookup("jnp:/hibernate/AiFactory"),
SessionFactory.class);


Top
  
 
 Post subject:
PostPosted: Tue Nov 11, 2003 4:49 am 
Newbie

Joined: Tue Oct 28, 2003 3:48 am
Posts: 8
Location: LECOTAD
Hi all,

I have similary problem.

I thing it is ? about How to hold session.
After close hibernate-session U loss
any object and their mappings.

so U need somehow transfer object to
e.g SLSB`s which will hold your object.

But how???, Gavin have U any Idea???
S.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 11, 2003 6:26 am 
Newbie

Joined: Fri Oct 24, 2003 3:31 am
Posts: 5
Location: Spain (Madrid)
The solution I am using, at the moment, is to change the JTA transactions method by a JDBC connection. That is, changing the configuration sentence FROM:

<attribute name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionFactory</attribute>

TO:

<attribute name="TransactionStrategy">net.sf.hibernate.transaction.JDBCTransactionFactory</attribute>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 11, 2003 1:07 pm 
Beginner
Beginner

Joined: Thu Sep 25, 2003 5:22 pm
Posts: 29
Location: NC
I am using Hibernate with a thick client... but with a Session Bean layer in between. Then my JNDI lookup is just for the Bean and the Bean interfaces with the Hibernate classes. Assuming I include my domain model jars in my classpath, I can still access those classes directly once the Bean gets them for me. Not sure if this is what you want to do, though.

-Kat


Top
 Profile  
 
 Post subject: Thick Clients / Junit tests and Hibernate Jboss service
PostPosted: Tue Nov 11, 2003 3:02 pm 
Hi Kat,

I recently learned that, being in a SAR, the hibernate service is only available inside the container on purpose.

My thick clients are junit tests, which I need for developing and unit testing persistent classes. I think in this situation using a session bean would get in the way of a true unit test. So for unit tests, I think the following 2 choices are good:
- Run junit tests w/Cactus for access to container, or
- Obtain hibernate Datasource directly.

However In the case of true applications, I think your approach of using session beans is the best solution!

Regards,

Eliot


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