I am trying to use hibernate.cfg.xml.
What works using hibernate.properties is:
I have a startup class and the following works when I hardocde in the program:
private static void doBind() throws Exception {
Properties environment = null;
InitialContext context = null;
try {
environment = new Properties();
environment.put("java.naming.factory.initial", "weblogic.jndi.WLInitialContextFactory");
environment.put("java.naming.provider.url", "t3://localhost:7001");
System.out.println("Constructing an Initial Directory Context object");
context = new InitialContext(environment);
/* Create a single instance of configuration and use it to set hte location of the mapping files.
addClass() assumes that the name of hte mapping file ends with the .hbm.xml extension
and is deployed along with the mapped class file.
If not, use i.e. addResource("monitor/Datum.hbm.xml") */
Configuration cfg = new Configuration();
cfg.setProperty("hibernate.connection.datasource", "TestDS");
_____
When I put the following in the hibernate.cfg.xml:
<session-factory name="java:/hibernate/HibernateFactory">
<property name="show_sql">true</property>
<property name="connection.datasource">
java:/comp/env/jdbc/TestDS
</property>
<property name="dialect">
org.hibernate.dialect.Oracle9Dialect
</property>
_____
and change the startup class to:
org.hibernate.SessionFactory factory = cfg.buildSessionFactory();
_____
I get the error:
14:35:25,746 INFO Configuration:917 - processing foreign key constraints
14:35:25,777 INFO NamingHelper:26 - JNDI InitialContext properties:{}
14:35:25,777 FATAL DatasourceConnectionProvider:47 - Could not find datasource: java:/comp/env/jdbc/TestDSjavax.naming.NameNotFoundException: remaining name: /comp/env/jdbc/TestDS
at weblogic.j2eeclient.SimpleContext.resolve(SimpleContext.java:35)
at weblogic.j2eeclient.SimpleContext.resolve(SimpleContext.java:39)
at weblogic.j2eeclient.SimpleContext.lookup(SimpleContext.java:57)
at weblogic.j2eeclient.SimpleContext.lookup(SimpleContext.java:62)
at weblogic.jndi.factories.java.ReadOnlyContextWrapper.lookup(ReadOnlyCo
ntextWrapper.java:45)
at weblogic.jndi.internal.AbstractURLContext.lookup(AbstractURLContext.j
ava:130)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at org.hibernate.connection.DatasourceConnectionProvider.configure(Datas
ourceConnectionProvider.java:44)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvi
der(ConnectionProviderFactory.java:80)
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFa
ctory.java:362)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:
60)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1463
)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav
a:1004)
at com.util.common.WLSStartup.doBind(WLSStartup.java:53)
at com.util.common.WLSStartup.startup(WLSStartup.java:27)
at weblogic.t3.srvr.StartupClassService.invokeStartup(StartupClassServic
e.java:177)
at weblogic.t3.srvr.StartupClassService.invokeClass(StartupClassService.
java:158)
at weblogic.t3.srvr.StartupClassService.access$000(StartupClassService.j
ava:36)
at weblogic.t3.srvr.StartupClassService$1.run(StartupClassService.java:1
21)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate
dSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:
121)
at weblogic.t3.srvr.StartupClassService.invokeStartupClass(StartupClassS
ervice.java:116)
at weblogic.t3.srvr.StartupClassService.addDeployment(StartupClassServic
e.java:88)
at weblogic.management.mbeans.custom.DeploymentTarget.addDeployment(Depl
oymentTarget.java:337)
at weblogic.management.mbeans.custom.DeploymentTarget.addDeployments(Dep
loymentTarget.java:597)
at weblogic.management.mbeans.custom.DeploymentTarget.updateServerDeploy
ments(DeploymentTarget.java:575)
at weblogic.management.mbeans.custom.DeploymentTarget.updateDeployments(
DeploymentTarget.java:241)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at weblogic.management.internal.DynamicMBeanImpl.invokeLocally(DynamicMB
eanImpl.java:754)
at weblogic.management.internal.DynamicMBeanImpl.invoke(DynamicMBeanImpl
.java:733)
at weblogic.management.internal.ConfigurationMBeanImpl.invoke(Configurat
ionMBeanImpl.java:509)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
60)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
28)
at weblogic.management.internal.RemoteMBeanServerImpl.private_invoke(Rem
oteMBeanServerImpl.java:988)
at weblogic.management.internal.RemoteMBeanServerImpl.invoke(RemoteMBean
ServerImpl.java:946)
at weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:954)
at weblogic.management.internal.MBeanProxy.invokeForCachingStub(MBeanPro
xy.java:481)
at weblogic.management.configuration.ServerMBean_Stub.updateDeployments(
ServerMBean_Stub.java:7691)
at weblogic.management.deploy.slave.SlaveDeployer.updateServerDeployment
s(SlaveDeployer.java:1304)
at weblogic.management.deploy.slave.SlaveDeployer.resume(SlaveDeployer.j
ava:347)
at weblogic.management.deploy.DeploymentManagerServerLifeCycleImpl.resum
e(DeploymentManagerServerLifeCycleImpl.java:229)
at weblogic.t3.srvr.SubsystemManager.resume(SubsystemManager.java:131)
at weblogic.t3.srvr.T3Srvr.resume(T3Srvr.java:966)
at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:361)
at weblogic.Server.main(Server.java:32)
startup -- Exception while binding Hibernate Object to Weblogic JNDI
org.hibernate.HibernateException: Could not find datasource
at org.hibernate.connection.DatasourceConnectionProvider.configure(Datas
ourceConnectionProvider.java:48)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvi
der(ConnectionProviderFactory.java:80)
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFa
ctory.java:362)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:
60)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1463
)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav
a:1004)
at com.util.common.WLSStartup.doBind(WLSStartup.java:53)
at com.util.common.WLSStartup.startup(WLSStartup.java:27)
at weblogic.t3.srvr.StartupClassService.invokeStartup(StartupClassServic
e.java:177)
at weblogic.t3.srvr.StartupClassService.invokeClass(StartupClassService.
java:158)
at weblogic.t3.srvr.StartupClassService.access$000(StartupClassService.j
ava:36)
at weblogic.t3.srvr.StartupClassService$1.run(StartupClassService.java:1
21)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate
dSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:
121)
at weblogic.t3.srvr.StartupClassService.invokeStartupClass(StartupClassS
ervice.java:116)
at weblogic.t3.srvr.StartupClassService.addDeployment(StartupClassServic
e.java:88)
at weblogic.management.mbeans.custom.DeploymentTarget.addDeployment(Depl
oymentTarget.java:337)
at weblogic.management.mbeans.custom.DeploymentTarget.addDeployments(Dep
loymentTarget.java:597)
at weblogic.management.mbeans.custom.DeploymentTarget.updateServerDeploy
ments(DeploymentTarget.java:575)
at weblogic.management.mbeans.custom.DeploymentTarget.updateDeployments(
DeploymentTarget.java:241)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
____
Help
|