tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Hughes <ahhug...@gmail.com>
Subject Re: A little help with hibernate.cfg.xml and test datasources
Date Thu, 28 Apr 2011 01:17:19 GMT
Thanks very much!  When I get this all working I think I will submit an new
example to the project (p.s. distributed version control would be nice).

THANKS FOR ALL YOUR HELP SO FAR! Sorry for bombarding the mailing list with
these noobie questions...

Unfortunately I have another problem which I am again in the dark with...

FATAL - Could not find datasource: *myapp.portal.ds*
javax.naming.NameNotFoundException: Name "*myapp.portal.ds*" not found.
at
org.apache.openejb.core.ivm.naming.IvmContext.federate(IvmContext.java:193)
at org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:150)
at
org.apache.openejb.core.ivm.naming.ContextWrapper.lookup(ContextWrapper.java:115)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at
org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
at
org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
at
org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
at
org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:414)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
at
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
at
org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)


Either my datasource creation is wrong:

@BeforeClass
public static void setUp() throws Exception {
final Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.LocalInitialContextFactory");
p.put("*myapp.portal.ds*", "new://Resource?type=DataSource");
p.put("*myapp.portal.ds.JdbcDriver*", SQLServerDriver.class.getName());
p.put("*myapp.portal.ds.JdbcUrl*",
System.getProperty("myappPortalDsJdbcUrl"));
p.put("*myapp.portal.ds.UserName*",
System.getProperty("myappPortalDsUserName"));
p.put("*myapp.portal.ds.Password*",
System.getProperty("myappPortalDsPassword"));
p.put("*myapp.portal.ds.JtaManaged*", "true");
context = new InitialContext(p);
}


Or the hibernate.cfg.xml's 'hibernate.connection.datasource' is wrong
(complete hibernate.cfg.xml in initial post for reference):


<property name="hibernate.connection.datasource">*myapp.portal.ds*
</property>



Or I am stuffing up something else I don't know about??? :'(


CHEERS AND THANKS FOR ALL YOUR HELP SO FAR!
--AH




PS. for reference I needed to add the following to my hibernate.cfg.xml to
fix the javax.naming.NoInitialContextException problem.

<hibernate-configuration>
    <session-factory>
        ....
*        <property
name="hibernate.jndi.class">org.apache.openejb.client.LocalInitialContextFactory</property>
*
        ....
    <session-factory>
</hibernate-configuration>




On Thu, Apr 28, 2011 at 8:47 AM, djheisterberg <djheisterberg@yahoo.com>wrote:

> You just need to let hibernate know about
> org.apache.openejb.client.LocalInitialContextFactory.  Either set it in
> jndi.properties or in the hibernate config with <property
> name="hibernate.jndi.class">.
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/A-little-help-with-hibernate-cfg-xml-and-test-datasources-tp3477192p3479695.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message