You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Alys <al...@gmail.com> on 2011/03/02 15:13:21 UTC

EJB 2.1 + OpenEJB + Tomcat + Datasource: Name openejb is not bound in this Context

Hello,

I have an old application, in Java 1.4 with EJB 2.1, Struts and iBatis 2.
This app is in production, and working fine.

But, the application server we use is proprietary, and there was a request
to use another one. I tried JBoss 5 first, and was successful migrating it.
But now I have to test with Tomcat + Open EJB, and I'm stucked in the
datasource configuration part.

I download the Tomcat bundle: tomee-6.0.29.314.zip

Put my EAR file in the webapp folder, changed the openejb.xml file (on
TOMCAT_HOME\conf) to include the datasource:

&lt;Resource id="NameDS" type="DataSource"&gt;
  JdbcDriver oracle.jdbc.driver.OracleDriver
  JdbcUrl jdbc:oracle:oci:string_conecction
  UserName SIATUPRD
  Password gsmssiatu
  JtaManaged true
&lt;/Resource&gt;

But, it doesn't work. When I start Tomcat, I get the error:

	javax.naming.NameNotFoundException: Name openejb is not bound in this
Context
	
I can see in the log that he recognize my NameDS:

	2011-03-02 09:03:21,609 - INFO  - Creating Resource(id=NameDS)

I have a ServiceLocator class, where I use the source code below, to open a
Datasource object:

	Context context = new InitialContext(p);
	...
	DataSource ds = (DataSource) context.lookup("java:openejb/Resource/NameDS")
	
I also tried to configure the Datasource on Tomcat's way (like on 
http://numberformat.wordpress.com/tag/tomcat-6-mysql-datasource/ this  site
), but I keep getting the same problem.

The only thing I changed so far, in configurations files, is the openejb.xml
I mentioned early. I don't know much of EJB 2.1 (I'm more used to Spring and
Servlets), but I believe it's correct configured, since it worked fine on
JBoss.

I saw this other post, 
http://openejb.979440.n4.nabble.com/NamingExpection-Name-openejb-is-not-bound-in-this-Context-td980644.html#a980645
NamingExpection: Name openejb is not bound in this Context , and thought to
post there, but, since Cae Fernandes is using Spring, it could mess his
post.

Thanks.

--
View this message in context: http://openejb.979440.n4.nabble.com/EJB-2-1-OpenEJB-Tomcat-Datasource-Name-openejb-is-not-bound-in-this-Context-tp3331555p3331555.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: EJB 2.1 + OpenEJB + Tomcat + Datasource: Name openejb is not bound in this Context

Posted by zsaade <zs...@path-solutions.com>.
Hi 

I'm facing the same problem can you advice which JNDI did you use in order
to resolve your problem?


Best Regards



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html

Re: EJB 2.1 + OpenEJB + Tomcat + Datasource: Name openejb is not bound in this Context

Posted by Alys <al...@gmail.com>.
Thank you very much David!

My datasource is correct configured now, and Tomcat + OpenEJB starts with no
problem.

Although, I would like to ask another thing, if you don't mind. Inside my
EAR, I have lots of EJBs packed inside JARs, and web modules into WARs.

One of this wars files is called ROOT.war, and I want to configure
Tomcat/OpenEJB in order to load this module by default (so, as I enter, for
example, localhost:8080, this ROOT.war is loaded instead of Tomcat's default
page).

I know I can configure an application to be Tomcat's default by setting it's
context, something like this:

		&lt;Context path="" docBase="my_ear_name" debug="0" reloadable="true"&gt;
		&lt;/Context&gt;

But, the trouble is: the app I want as default is not exactly my EAR, is
something inside it. Is it possible?

--
View this message in context: http://openejb.979440.n4.nabble.com/EJB-2-1-OpenEJB-Tomcat-Datasource-Name-openejb-is-not-bound-in-this-Context-tp3331555p3333222.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: EJB 2.1 + OpenEJB + Tomcat + Datasource: Name openejb is not bound in this Context

Posted by David Blevins <da...@gmail.com>.
On Mar 2, 2011, at 6:13 AM, Alys wrote:

> I have a ServiceLocator class, where I use the source code below, to open a
> Datasource object:
> 
> 	Context context = new InitialContext(p);
> 	...
> 	DataSource ds = (DataSource) context.lookup("java:openejb/Resource/NameDS")

Give it a try with this instead,  "openejb:Resource/NameDS".

Basically Tomcat owns "java:" and we have share it.  Same for when OpenEJB is in Geronimo (Geronimo owns "java:").  As a workaround, we created the "openejb:" namespace that will work consistently in any environment where OpenEJB is present.


-David