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

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Alys
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:

<Resource id="NameDS" type="DataSource">
  JdbcDriver oracle.jdbc.driver.OracleDriver
  JdbcUrl jdbc:oracle:oci:string_conecction
  UserName user
  Password pass
  JtaManaged true
</Resource>

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 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, 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.
Reply | Threaded
Open this post in threaded view
|

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

David Blevins-2

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

Reply | Threaded
Open this post in threaded view
|

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

Alys
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:

                <Context path="" docBase="my_ear_name" debug="0" reloadable="true">
                </Context>


But, the trouble is: the app I want as default is not exactly my EAR, is something inside it. Is it possible?
Reply | Threaded
Open this post in threaded view
|

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

zsaade
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