-->
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.  [ 5 posts ] 
Author Message
 Post subject: JMX Service and Jboss
PostPosted: Thu Oct 09, 2003 2:30 pm 
Beginner
Beginner

Joined: Wed Oct 01, 2003 3:35 pm
Posts: 35
All,

I have created the following JMX Service under JBoss:

<server>
<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=MyHomePageDS</depends>
<!-- Make it deploy ONLY after DataSource had been started -->
<attribute name="MapResources">
mappings/ContactInfo.hbm.xml,
mappings/NavigationMain.hbm.xml,
mappings/NavigationSub.hbm.xml
mappings/ActualPicture.hbm.xml,
mappings/PictureToActualPicture.hbm.xml
</attribute>
<attribute name="JndiName">MyHomePageHibernateFactory</attribute>
<attribute name="Datasource">java:/MyHomePageDS</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">false</attribute>
<attribute name="ShowSql">false</attribute>
<attribute name="UserTransactionName">java:/UserTransaction</attribute>
</mbean>
</server>

I then, created the following client code:

try
{
Properties props = new Properties();
props.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
props.setProperty("java.naming.provider.url", "jnp://localhost:1099");
props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
InitialContext ctx = new InitialContext(props);

Object ref = ctx.lookup("MyHomePageHibernateFactory");
SessionFactory session = (SessionFactory)PortableRemoteObject.narrow(ref, SessionFactory.class );
System.out.println(session);
}
catch(Exception e)
{
System.out.println("exception: " + e.getMessage());
e.printStackTrace();
}

What is happening is that I am getting a NULL object. So for some reason, I am not getting the SessionFactory. Any reason as to why?

From the Jboss output, it appears as though the hibernate.properties is necessary. Is it?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 09, 2003 2:57 pm 
Beginner
Beginner

Joined: Wed Oct 01, 2003 3:35 pm
Posts: 35
I realized that I am now seeing:

[HibernateServiceMBean] Could not build SessionFactory using the MBean classpath - will try again using client classpath: Repeated column in mapping for class com.ronmar.homepage.hibernate.ContactInfo should be mapped with insert="false" update="false": navigation_sub_id

I must have messed up something with my mapping code.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 09, 2003 5:12 pm 
Beginner
Beginner

Joined: Wed Oct 01, 2003 3:35 pm
Posts: 35
This appears to be a problem with my mappng file. The mapping file is giving the following error:

16:44:09,119 INFO [HibernateServiceMBean] Could not build SessionFactory using the MBean classpath - will try again using client classpath: Repeated column in mapping for class com.ronmar.homepage.hibernate.ContactInfo should be mapped with insert="false" update="false": navigation_sub_id

So here is the mapping file:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping>

<!--
Created by Middlegen Hibernate plugin

http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->

<class
name="com.ronmar.homepage.hibernate.ContactInfo"
table="contact_info"
>
<composite-id name="propertyName" class="com.ronmar.homepage.hibernate.ContactInfoPK">
<key-property name="navigationSubId" column="navigation_sub_id" type="int"/>
<key-property name="navigationMainId" column="navigation_main_id" type="int"/>
</composite-id>

<property
name="navigationSubId"
type="int"
column="navigation_sub_id"
not-null="true"
length="11"
insert="false" update="false"
/>

<property
name="navigationMainId"
type="int"
column="navigation_main_id"
not-null="true"
length="11"
insert="false" update="false"
/>

<property
name="emailAddress"
type="java.lang.String"
column="email_address"
not-null="true"
length="100"
/>
<property
name="fromLength"
type="int"
column="from_length"
not-null="true"
length="11"
/>
<property
name="subjectLength"
type="int"
column="subject_length"
not-null="true"
length="11"
/>
<property
name="messageLength"
type="int"
column="message_length"
not-null="true"
length="11"
/>

<!-- associations -->
<!-- bi-directional one-to-one association to NavigationSub -->
<many-to-one
name="navigationSub"
class="com.ronmar.homepage.hibernate.NavigationSub"
>
<column name="navigation_sub_id" />
<column name="navigation_main_id" />
</many-to-one>

</class>
</hibernate-mapping>

I am not sure what is wrong with it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 09, 2003 5:27 pm 
Beginner
Beginner

Joined: Wed Oct 01, 2003 3:35 pm
Posts: 35
Okay I got my mapping files worked out. Now the SessionFactory still comes back null. Here is the log output from JBoss:

17:21:06,602 INFO [HibernateServiceMBean] starting service at JNDI name: MyHomePageHibernateFactory
17:21:06,602 INFO [HibernateServiceMBean] service properties: {hibernate.session_factory_name=MyHomePageHibernateFactory, hibernate.transaction.manager_lookup_class=net.sf.hibernate.transaction.JBossTransactionManagerLookup, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.show_sql=false, hibernate.use_outer_join=false, hibernate.transaction.factory_class=net.sf.hibernate.transaction.JTATransactionFactory, hibernate.connection.datasource=java:/MyHomePageDS, jta.UserTransaction=java:/UserTransaction}
17:21:06,642 INFO [Environment] Hibernate 2.0.3
17:21:06,652 INFO [Environment] hibernate.properties not found
17:21:06,652 INFO [Environment] using CGLIB reflection optimizer
17:21:06,652 INFO [Environment] JVM proxy support: true
17:21:06,662 INFO [Configuration] Mapping resource: mappings/ContactInfo.hbm.xml
17:21:07,122 INFO [Binder] Mapping class: com.ronmar.homepage.hibernate.ContactInfo -> contact_info
17:21:08,274 INFO [Configuration] Mapping resource: mappings/NavigationMain.hbm.xml
17:21:08,474 INFO [Binder] Mapping class: com.ronmar.homepage.hibernate.NavigationMain -> navigation_main
17:21:08,504 INFO [Configuration] Mapping resource: mappings/NavigationSub.hbm.xml
17:21:08,825 INFO [Binder] Mapping class: com.ronmar.homepage.hibernate.NavigationSub -> navigation_sub
17:21:08,895 INFO [Configuration] Mapping resource: mappings/ActualPicture.hbm.xml
17:21:09,376 INFO [Binder] Mapping class: com.ronmar.homepage.hibernate.ActualPicture -> actual_picture
17:21:09,426 INFO [Configuration] Mapping resource: mappings/PictureToActualPicture.hbm.xml
17:21:09,646 INFO [Binder] Mapping class: com.ronmar.homepage.hibernate.PictureToActualPicture -> picture_to_actual_picture
17:21:09,706 INFO [Configuration] processing one-to-many association mappings
17:21:09,706 INFO [Binder] Mapping collection: com.ronmar.homepage.hibernate.NavigationMain.navigationSubs -> navigation_sub
17:21:09,706 INFO [Binder] Mapping collection: com.ronmar.homepage.hibernate.NavigationSub.pictureToActualPictures -> picture_to_actual_picture
17:21:09,706 INFO [Binder] Mapping collection: com.ronmar.homepage.hibernate.ActualPicture.pictureToActualPictures -> picture_to_actual_picture
17:21:09,706 INFO [Configuration] processing foreign key constraints
17:21:09,816 INFO [SessionFactoryImpl] building session factory
17:21:09,846 INFO [Dialect] Using dialect: net.sf.hibernate.dialect.MySQLDialect
17:21:09,856 INFO [NamingHelper] JNDI InitialContext properties:{}
17:21:09,876 INFO [DatasourceConnectionProvider] Using datasource: java:/MyHomePageDS
17:21:09,876 INFO [SessionFactoryImpl] Use outer join fetching: false
17:21:10,267 INFO [SessionFactoryImpl] Use scrollable result sets: true
17:21:10,267 INFO [SessionFactoryImpl] JDBC 2 max batch size: 15
17:21:10,267 INFO [SessionFactoryImpl] Transaction strategy: net.sf.hibernate.transaction.JTATransactionFactory
17:21:10,277 INFO [NamingHelper] JNDI InitialContext properties:{}
17:21:10,277 INFO [JTATransactionFactory] Locating TransactionManager using: net.sf.hibernate.transaction.JBossTransactionManagerLookup
17:21:10,287 INFO [NamingHelper] JNDI InitialContext properties:{}
17:21:10,287 INFO [JTATransactionFactory] TransactionManager lookup successful
17:21:11,809 INFO [SessionFactoryObjectFactory] Factory name: MyHomePageHibernateFactory
17:21:11,809 INFO [NamingHelper] JNDI InitialContext properties:{}
17:21:11,809 INFO [SessionFactoryObjectFactory] Bound factory to JNDI name: MyHomePageHibernateFactory
17:21:11,809 WARN [SessionFactoryObjectFactory] InitialContext did not implement EventContext
17:21:11,809 INFO [SessionFactoryImpl] Query language substitutions: {}

So I am back to where I started. Why is the SessionFactory coming back null?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 12, 2003 12:29 am 
Beginner
Beginner

Joined: Wed Oct 01, 2003 3:35 pm
Posts: 35
Seems I forgot that JMX Services are not accesible outside of the JBoss container. Not sure why this is, but it is.


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