I am using the embeddable EJB container of WebSphere 8 to write some unit tests for my EJBs with JUnit4. I have a simple java project in MyEclipse where I reference the EJB project. The EJB project uses Hibernate 3.5 for persistence and the datasource JNDI in hibernate.cfg.xml is jdbc/connectionname. When it runs on standard WebSphere 8 I have set up the datasource through the web console and all works fine. On the embeddable container the datasource is set up in embeddable.properties with:
name again as jdbc/connectionname among other datasource info (username, password etc.) and Bean.#TestProjectName#ClassNameForTests.ResourceRef.BindingName.jdbc/connectionname=jdbc/connectionname
My embeddable.properties is as follows:
DataSource.ds1.name=jdbc/connectionname
DataSource.ds1.className=com.ibm.db2.jcc.DB2Driver
DataSource.ds1.createDatabase=create
DataSource.ds1.databaseName=DBNAME
DataSource.ds1.user=dbusername
DataSource.ds1.password=dbpassword
DataSource.ds1.transactional=true
DataSource.ds1.createDatabase=create
The embeddable container starts successfully and the EJBs can be found successfully through JNDI but at the point where the method call is made I get the error:
ERROR org.hibernate.connection.DatasourceConnectionProvider.configure:78 - Could not find datasource: jdbc/connectionname
javax.naming.NameNotFoundException: Name jdbc not found in context "serverlocal:CELLROOT/SERVERROOT".
at com.ibm.ws.naming.ipbase.NameSpace.getParentCtxInternal(NameSpace.java:1969)
at com.ibm.ws.naming.ipbase.NameSpace.retrieveBinding(NameSpace.java:1376)
at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal(NameSpace.java:1219)
at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:1141)
at com.ibm.ws.naming.urlbase.UrlContextImpl.lookupExt(UrlContextImpl.java:1436)
at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1314)
at javax.naming.InitialContext.lookup(InitialContext.java:436)
at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:75)
Any advice would be appreciated.