Hi,
I am binding hibernate to Jboss JNDI using file Hibernate-service.xml.Its
content is:
<?xml version="1.0" encoding="UTF-8"?>
| <server>
| <mbean code="org.jboss.hibernate.jmx.Hibernate"
name="jboss.har:service=Hibernate"><depends>jboss.jca:name=jdbc/mysql,service=DataSourceBinding</depends><attribute
name="DatasourceName">jdbc/mysql</attribute> <attribute
name="Dialect">org.hibernate.dialect.MySQLDialect</attribute><attribute
name="SessionFactoryName">testing</attribute><attribute
name="Hbm2ddlAuto">create-drop</attribute> <attribute
name="ShowSqlEnabled">true</attribute> </mbean></server>
Jboss server console is showing that
17:45:19,000 INFO [NamingHelper] JNDI InitialContext properties:{}
|
| 17:45:19,093 INFO [DatasourceConnectionProvider] Using datasource:
jdbc/sqlserver
|
| 17:45:19,203 INFO [SettingsFactory] RDBMS: Microsoft SQL Server, version:
Microsoft SQL Server 2000 - 8.00.194 (Intel X86)
|
| Aug 6 2000 00:57:48
|
| Copyright (c) 1988-2000 Microsoft Corporation
|
| Enterprise Evaluation Edition on Windows NT 5.0 (Build 2195: Service Pack
4)
|
|
|
| 17:45:19,218 INFO [SettingsFactory] JDBC driver: SQLServer, version:
2.2.0040
|
| 17:45:19,234 INFO [Dialect] Using dialect:
org.hibernate.dialect.SQLServerDialect
|
| 17:45:19,234 INFO [TransactionFactoryFactory] Transaction strategy:
org.hibernate.transaction.JTATransactionFactory
|
| 17:45:19,234 INFO [NamingHelper] JNDI InitialContext properties:{}
|
| 17:45:19,234 INFO [TransactionManagerLookupFactory] instantiating
TransactionManagerLookup:
org.hibernate.transaction.JBossTransactionManagerLookup
|
| 17:45:19,250 INFO [TransactionManagerLookupFactory] instantiated
TransactionManagerLookup
|
| 17:45:19,250 INFO [TransactionManagerLookupFactory] instantiating
TransactionManagerLookup:
org.hibernate.transaction.JBossTransactionManagerLookup
|
| 17:45:19,250 INFO [TransactionManagerLookupFactory] instantiated
TransactionManagerLookup
| 17:45:19,250 INFO [SettingsFactory] Automatic flush during
beforeCompletion(): enabled
|
| 17:45:19,250 INFO [SettingsFactory] Automatic session close at end of
transaction: enabled
|
| 17:45:19,250 INFO [SettingsFactory] Scrollable result sets: enabled
|
| 17:45:19,265 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): disabled
|
| 17:45:19,265 INFO [SettingsFactory] Connection release mode:
after_statement
|
| 17:45:19,281 INFO [SettingsFactory] Default batch fetch size: 1
|
| 17:45:19,281 INFO [SettingsFactory] Generate SQL with comments: disabled
|
| 17:45:19,281 INFO [SettingsFactory] Order SQL updates by primary key:
disabled
|
| 17:45:19,312 INFO [SettingsFactory] Query translator:
org.hibernate.hql.ast.ASTQueryTranslatorFactory
|
| 17:45:19,312 INFO [ASTQueryTranslatorFactory] Using
ASTQueryTranslatorFactory
|
| 17:45:19,312 INFO [SettingsFactory] Query language substitutions: {}
|
| 17:45:19,328 INFO [SettingsFactory] Second-level cache: enabled
|
| 17:45:19,328 INFO [SettingsFactory] Query cache: disabled
|
| 17:45:19,328 INFO [SettingsFactory] Cache provider:
org.hibernate.cache.HashtableCacheProvider
|
| 17:45:19,328 INFO [SettingsFactory] Optimize cache for minimal puts:
disabled
|
| 17:45:19,328 INFO [SettingsFactory] Structured second-level cache entries:
disabled
|
| 17:45:19,328 INFO [SettingsFactory] Statistics: disabled
|
| 17:45:19,328 INFO [SettingsFactory] Deleted entity synthetic identifier
rollback: disabled
|
| 17:45:19,328 INFO [SettingsFactory] Default entity-mode: pojo 17:45:19,390
INFO [SessionFactoryImpl] building session factory
|
| 17:45:19,406 INFO [SessionFactoryObjectFactory] Not binding factory to
JNDI, no JNDI name configured
|
| 17:45:19,406 INFO [NamingHelper] JNDI InitialContext properties:{}
|
| 17:45:19,406 INFO [Hibernate] SessionFactory successfully built and bound
into JNDI [testing]
|
Code to look up::::::::::::::::::::
| InitialContext initialContext = null;
|
| Hashtable environment = new Hashtable();
|
| environment.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
|
| environment.put(Context.URL_PKG_PREFIXES,
"org.jboss.naming:org.jnp.interfaces");
|
| environment.put(Context.PROVIDER_URL, "jnp://localhost:1099");
|
| try {
|
| initialContext = new InitialContext(environment);
|
| } catch (NamingException e) {
|
| // TODO Auto-generated catch block
|
| e.printStackTrace();
|
| }
|
| String jndiName = "java:testing"; //"testing" (whichever i use obj is null)
|
| Object obj=ctx.lookup(jndiName);
| System.out.println("obj:"+obj);
Sometimes,It returns null but sometimes it returns
obj:Reference Class Name: org.hibernate.impl.SessionFactoryImpl
Please tell why it is happening.Am i missing some basic concept.
Help will be highly appreciated.
Thanks
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3944453#3944453
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3944453
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user