[jboss-user] [JBoss Portal] - portlet accessing different database

tellarsrinivasprabhu do-not-reply at jboss.com
Mon Sep 17 02:59:30 EDT 2007


Hi all,

     I have a portlet where i need a database connection. I am using MS SQL Server 2005 and i have created data source configuration in portal-sqlserver-ds.xml.  I have created jboss-service.xml in META-INF folder of my portlet and in this jboss-service.xml i have created the session factory for the data source as follows 

  | <mbean
  |       code="org.jboss.portal.jems.hibernate.SessionFactoryBinder"
  |       name="portal:service=Hibernate,type=Srinivas"
  |       xmbean-dd=""
  |       xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
  |       <xmbean/>
  |       <depends>jboss.jca:service=DataSourceBinding,name=PortalDS</depends>
  |       <attribute name="DoChecking">true</attribute>
  |       <attribute name="ConfigLocation">conf/hibernate/srinivas/hibernate.cfg.xml</attribute>
  |       <attribute name="JNDIName">java:/portal/SrinivasSessionFactory</attribute>
  |    </mbean>    

Now in my code when i access the sessionfactory using following lines of code 

  | try {            
  | 	            SessionFactory mySessionFactory = (SessionFactory) new InitialContext()
  | 	            .lookup("java:/portal/SrinivasSessionFactory");
  | 	            
  | 	        } catch (Throwable ex) {            
  | 	            System.out.println("------> Error while creating session factory  --> " + ex.getMessage());
  | 	            ex.getStackTrace();
  | 	        }
  | 
am getting an exception.

SrinivasSessionFactory not bound

However if when i create the mbean in jboss-service.xml which is in server\default\deploy\jboss-portal.sar\META-INF directory, there is no exception which means that the mbean is created in this case.


Now i feel each portlet must be independent enough to carry its database connectivity details. So i want to keep the mbean (of sessionFactory) definition in my portlet rather than jboss-portal.sar. 

So can any one tell me how can i achieve this goal of keeping this mbean definition in my portlet than jboss-portal.sar.


Also can i keep the data source details (which are kept in portal-sqlserver-ds.xml) in my portlet ?

 

my environment is as follows
JBoss Portal Version : jboss 2.6.1
  | Did you get Portal from CVS : yes
  | JBoss AS Version : JBoss AS 4.0.5
  | Database Vendor and Version : MS SQL server 2005
  | JDBC Connector : jdbc:jtds:sqlserver
  | OS Platform : Windows NT 
  |  
  | 
  | Thanks in advance,
  | srinivas prabhu

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4084901#4084901

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4084901



More information about the jboss-user mailing list