You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Laird Nelson <lj...@gmail.com> on 2009/04/20 17:23:32 UTC
Putting data source into local container?
Hello; I'd like to set up a data source in my embedded OpenEJB container.
Here's my code so far, which results in nothing being bound into the JNDI
tree:
final Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
org.apache.openejb.client.LocalInitialContextFactory.class.getName());
properties.setProperty("jdbc/test", "new://Resource?type=DataSource");
properties.setProperty("jdbc/test.JdbcDriver", "org.h2.Driver");
properties.setProperty("jdbc/test.JdbcUrl",
"jdbc:h2:mem:test;DB_CLOSE_DELAY=-1");
properties.setProperty("jdbc/test.Username", "");
properties.setProperty("jdbc/test.Password", "");
properties.put("jdbc/test.DefaultAutoCommit", Boolean.valueOf(false));
this.context = new InitialContext(properties);
Any ideas? The context is empty. I got this recipe from the documentation
on the website.
Best,
Laird
Re: Putting data source into local container?
Posted by Laird Nelson <lj...@gmail.com>.
This, I hope, will be the last TestCase I post. Thanks for folks' patience.
I hope this is a definitive case that shows my problem. Please disregard my
earlier ones.
In this test case, I make sure to incorporate Jean-Louis' suggestions. For
whatever reason, the list() method fails with a NameNotFoundException,
claiming that it cannot find (and I checked this carefully)
"java:openejb/Resource", and so cannot list its contents.
Thanks again so far for your help, Jean-Louis; I am grateful for it, but I'm
still stuck. :-(
package openejbbugs;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingEnumeration;
import javax.naming.NameClassPair;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
public class TestCaseOpenEJBBug {
private Context context;
@Before
public final void setUp() throws Exception {
final Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
org.apache.openejb.client.LocalInitialContextFactory.class.getName());
properties.setProperty("test", "new://Resource?type=DataSource");
properties.setProperty("test.JdbcDriver", "org.h2.Driver");
properties.setProperty("test.JdbcUrl",
"jdbc:h2:mem:test;DB_CLOSE_DELAY=-1");
properties.setProperty("test.Username", "sa");
properties.setProperty("test.Password", "");
properties.put("test.DefaultAutoCommit", Boolean.valueOf(false));
// properties.setProperty("openejb.embedded.remotable", "true");
this.context = new InitialContext(properties);
String name = null;
// XXX TODO FIXME: the test fails here with the following output:
// javax.naming.NameNotFoundException: Name "java:openejb/Resource" not
found.
// at
org.apache.openejb.core.ivm.naming.IvmContext.federate(IvmContext.java:172)
// at
org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:129)
// at
org.apache.openejb.core.ivm.naming.IvmContext.list(IvmContext.java:328)
// at
org.apache.openejb.core.ivm.naming.ContextWrapper.list(ContextWrapper.java:99)
// at javax.naming.InitialContext.list(InitialContext.java:436)
// at openejbbugs.TestCaseOpenEJBBug.setUp(TestCaseOpenEJBBug.java:45)
final NamingEnumeration<NameClassPair> ne =
this.context.list("java:openejb/Resource");
assertNotNull(ne);
try {
while (ne.hasMore()) {
final NameClassPair ncp = ne.next();
assertNotNull(ncp);
name = ncp.getName();
if (name != null && name.indexOf("test") >= 0) {
break;
}
}
} finally {
ne.close();
}
assertNotNull(name);
System.out.println("Name: " + name);
final Object o = this.context.lookup("java:openejb/Resource/test");
assertTrue(o instanceof javax.sql.DataSource);
}
@Test
public void testLoad() throws Exception {
assertNotNull(context);
}
}
Re: Putting data source into local container?
Posted by Jean-Louis MONTEIRO <je...@atosorigin.com>.
Thanks a lot David for this very detailed description.
Jean-Louis
David Blevins wrote:
>
>
> On Apr 20, 2009, at 12:12 PM, Jean-Louis MONTEIRO wrote:
>
>>
>> Laird,
>>
>> I found the problem (on a new project created from scratch ;-)).
>> If you duplicate the line
>> this.context = new InitialContext(properties);
>> it will work.
>> A JIRA already exists on that point.
>> https://issues.apache.org/jira/browse/OPENEJB-1011
>> https://issues.apache.org/jira/browse/OPENEJB-1011
>>
>> I don't know why, but sometimes the InitialContext used to bootstrap
>> OpenEJB
>> is corrupted.
>
> It's basically due to this strange way that the InitialContext works.
>
> You can register a provider to handle lookups that start with a prefix
> (see Context.URL_PKG_PREFIXES which is an internal flag). When
> someone does a "new InitialContext().lookup("java:foo")", the
> InitialContext looks for a class called '<any-package-
> prefix>.java.javaURLContextFactory', instantiates it and does the
> lookup using that factory.
>
> But when the InitialContext is constructed with properties that
> contain an Context.INITIAL_CONTEXT_FACTORY, it decides to go a
> different route entirely, ignores the javaURLContextFactory
> implementation and instead delegates the call to the Context created
> by the InitialContextFactory. Kind of a messy API, but that's the way
> it is.
>
> To get around it I basically had to beef up the IvmContext
> implementation to catch "java:" lookups and delegate them to our
> "javaURLContextFactory" implementation. This should give us a more
> consistent view of url lookups. In lots of situations (tomcat or
> geronimo) the "java:" provider is already taken, so it seemed like a
> good additional measure to add a new prefix "openejb:" that would be
> guaranteed to work more universally. So in 3.1.1 using
> "openejb:Resource/TestDataSource" is definitely preferred to
> "java:openejb/Resource/TestDataSource".
>
> -David
>
>
>
--
View this message in context: http://www.nabble.com/Putting-data-source-into-local-container--tp23138888p23144652.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Putting data source into local container?
Posted by David Blevins <da...@visi.com>.
On Apr 20, 2009, at 12:12 PM, Jean-Louis MONTEIRO wrote:
>
> Laird,
>
> I found the problem (on a new project created from scratch ;-)).
> If you duplicate the line
> this.context = new InitialContext(properties);
> it will work.
> A JIRA already exists on that point.
> https://issues.apache.org/jira/browse/OPENEJB-1011
> https://issues.apache.org/jira/browse/OPENEJB-1011
>
> I don't know why, but sometimes the InitialContext used to bootstrap
> OpenEJB
> is corrupted.
It's basically due to this strange way that the InitialContext works.
You can register a provider to handle lookups that start with a prefix
(see Context.URL_PKG_PREFIXES which is an internal flag). When
someone does a "new InitialContext().lookup("java:foo")", the
InitialContext looks for a class called '<any-package-
prefix>.java.javaURLContextFactory', instantiates it and does the
lookup using that factory.
But when the InitialContext is constructed with properties that
contain an Context.INITIAL_CONTEXT_FACTORY, it decides to go a
different route entirely, ignores the javaURLContextFactory
implementation and instead delegates the call to the Context created
by the InitialContextFactory. Kind of a messy API, but that's the way
it is.
To get around it I basically had to beef up the IvmContext
implementation to catch "java:" lookups and delegate them to our
"javaURLContextFactory" implementation. This should give us a more
consistent view of url lookups. In lots of situations (tomcat or
geronimo) the "java:" provider is already taken, so it seemed like a
good additional measure to add a new prefix "openejb:" that would be
guaranteed to work more universally. So in 3.1.1 using
"openejb:Resource/TestDataSource" is definitely preferred to
"java:openejb/Resource/TestDataSource".
-David
Re: Putting data source into local container?
Posted by Laird Nelson <lj...@gmail.com>.
On Mon, Apr 20, 2009 at 3:12 PM, Jean-Louis MONTEIRO <
jean-louis.monteiro@atosorigin.com> wrote:
> I found the problem (on a new project created from scratch ;-)).
> If you duplicate the line
> this.context = new InitialContext(properties);
> it will work.
> A JIRA already exists on that point.
> https://issues.apache.org/jira/browse/OPENEJB-1011
> https://issues.apache.org/jira/browse/OPENEJB-1011
>
> I don't know why, but sometimes the InitialContext used to bootstrap
> OpenEJB
> is corrupted.
> We definitely have to fix it.
>
> Sorry for that and for not finding the solution earlier.
That's fine! I actually found that "solution" as well, but was baffled by
why it would be the case. OK; thanks; at least I have a way to make it
work. :-)
Best,
Laird
Re: Putting data source into local container?
Posted by Jean-Louis MONTEIRO <je...@atosorigin.com>.
Laird,
I found the problem (on a new project created from scratch ;-)).
If you duplicate the line
this.context = new InitialContext(properties);
it will work.
A JIRA already exists on that point.
https://issues.apache.org/jira/browse/OPENEJB-1011
https://issues.apache.org/jira/browse/OPENEJB-1011
I don't know why, but sometimes the InitialContext used to bootstrap OpenEJB
is corrupted.
We definitely have to fix it.
Sorry for that and for not finding the solution earlier.
Jean-Louis
--
View this message in context: http://www.nabble.com/Putting-data-source-into-local-container--tp23138888p23143031.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Putting data source into local container?
Posted by Laird Nelson <lj...@gmail.com>.
OK, bear with me. Here is a revised test case that still fails. You'll
note that my listing code, following your suggestion, works properly. But
then a lookup based on that name--I hope--fails.
package openejbbugs;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingEnumeration;
import javax.naming.NameClassPair;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
public class TestCaseOpenEJBBug {
private Context context;
@Before
public final void setUp() throws Exception {
final Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
org.apache.openejb.client.LocalInitialContextFactory.class.getName());
properties.setProperty("test", "new://Resource?type=DataSource");
properties.setProperty("test.JdbcDriver", "org.h2.Driver");
properties.setProperty("test.JdbcUrl",
"jdbc:h2:mem:test;DB_CLOSE_DELAY=-1");
properties.setProperty("test.Username", "sa");
properties.setProperty("test.Password", "");
properties.put("test.DefaultAutoCommit", Boolean.valueOf(false));
// properties.setProperty("openejb.embedded.remotable", "true");
this.context = new InitialContext(properties);
String name = null;
final NamingEnumeration<NameClassPair> ne = new
InitialContext(properties).list("java:openejb/Resource");
assertNotNull(ne);
try {
while (ne.hasMore()) {
final NameClassPair ncp = ne.next();
assertNotNull(ncp);
name = ncp.getName();
if (name != null && name.indexOf("test") >= 0) {
break;
}
}
} finally {
ne.close();
}
assertNotNull(name);
System.out.println("Name: " + name);
final Object o = this.context.lookup("java:openejb/Resource/test");
assertTrue(o instanceof javax.sql.DataSource);
}
@Test
public void testLoad() throws Exception {
assertNotNull(context);
}
}
On Mon, Apr 20, 2009 at 2:41 PM, Laird Nelson <lj...@gmail.com> wrote:
> On Mon, Apr 20, 2009 at 2:40 PM, Jean-Louis MONTEIRO <
> jean-louis.monteiro@atosorigin.com> wrote:
>
>>
>> It works on my computer. I copy/paste your test case and I'm able to
>> lookup
>> the datasource.
>> The test fails because you did not change the context.list("") to
>> context.list("java:openejb/Resource")
>>
>
> Oh, so it's a forward slash before "Resource"? OK, let me try that
> listing.
>
> Laird
>
Re: Putting data source into local container?
Posted by Laird Nelson <lj...@gmail.com>.
On Mon, Apr 20, 2009 at 2:40 PM, Jean-Louis MONTEIRO <
jean-louis.monteiro@atosorigin.com> wrote:
>
> It works on my computer. I copy/paste your test case and I'm able to lookup
> the datasource.
> The test fails because you did not change the context.list("") to
> context.list("java:openejb/Resource")
>
Oh, so it's a forward slash before "Resource"? OK, let me try that listing.
Laird
Re: Putting data source into local container?
Posted by Jean-Louis MONTEIRO <je...@atosorigin.com>.
It works on my computer. I copy/paste your test case and I'm able to lookup
the datasource.
The test fails because you did not change the context.list("") to
context.list("java:openejb/Resource")
Jean-Louis
--
View this message in context: http://www.nabble.com/Putting-data-source-into-local-container--tp23138888p23142512.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Putting data source into local container?
Posted by Laird Nelson <lj...@gmail.com>.
Hello; it does not. Revised test case below:
package openejbbugs;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingEnumeration;
import javax.naming.NameClassPair;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
public class TestCaseOpenEJBBug {
private Context context;
@Before
public final void setUp() throws Exception {
final Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
org.apache.openejb.client.LocalInitialContextFactory.class.getName());
properties.setProperty("test", "new://Resource?type=DataSource");
properties.setProperty("test.JdbcDriver", "org.h2.Driver");
properties.setProperty("test.JdbcUrl",
"jdbc:h2:mem:test;DB_CLOSE_DELAY=-1");
properties.setProperty("test.Username", "sa");
properties.setProperty("test.Password", "");
properties.put("test.DefaultAutoCommit", Boolean.valueOf(false));
// properties.setProperty("openejb.embedded.remotable", "true");
this.context = new InitialContext(properties);
final Object o = this.context.lookup("java:openejb:Resource/test");
assertTrue(o instanceof javax.sql.DataSource);
boolean found = false;
final NamingEnumeration<NameClassPair> ne = new
InitialContext(properties).list("");
assertNotNull(ne);
try {
while (ne.hasMore()) {
final NameClassPair ncp = ne.next();
assertNotNull(ncp);
final String n = ncp.getName();
assertNotNull(n);
if (n.indexOf("test") >= 0) {
found = true;
break;
}
}
} finally {
ne.close();
}
assertTrue(found);
}
@Test
public void testLoad() throws Exception {
assertNotNull(context);
}
}
On Mon, Apr 20, 2009 at 2:26 PM, Jean-Louis MONTEIRO <
jean-louis.monteiro@atosorigin.com> wrote:
>
>
> ljnelson wrote:
> >
> > final NamingEnumeration<NameClassPair> ne = context.list("");
> >
>
> If you replace this line by this one, it should work
> final NamingEnumeration<NameClassPair> ne =
> context.list("java:openejb:Resource");
>
>
> Jean-Louis
> --
> View this message in context:
> http://www.nabble.com/Putting-data-source-into-local-container--tp23138888p23142261.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>
Re: Putting data source into local container?
Posted by Jean-Louis MONTEIRO <je...@atosorigin.com>.
ljnelson wrote:
>
> final NamingEnumeration<NameClassPair> ne = context.list("");
>
If you replace this line by this one, it should work
final NamingEnumeration<NameClassPair> ne =
context.list("java:openejb:Resource");
Jean-Louis
--
View this message in context: http://www.nabble.com/Putting-data-source-into-local-container--tp23138888p23142261.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Putting data source into local container?
Posted by David Blevins <da...@visi.com>.
On Apr 20, 2009, at 11:07 AM, Laird Nelson wrote:
> Hey, this gets weirder.
>
> I found this:
> http://www.nabble.com/DataSource-lookup-by-JNDI-name-tt23101598.html#a23101598
>
> Now, this indicates that what you can do is set up your
> InitialContext, then
> *throw it away*, then create a *new* InitialContext without
> *any*properties, and look up your data source in
> *there*.
>
> I tried it and it works, but boy does it creep me out. :-)
>
> Any ideas as to why I need to create a new InitialContext with no
> arguments
> after my initialization code to get the subsequent lookup to work?
Right, it is indeed quirky. We made some improvements here not too
long ago: https://issues.apache.org/jira/browse/OPENEJB-1009
So basically in 3.1.1 you should be able to lookup "openejb:Resource/
Foo" from inside the same vm as the container, regardless of how you
constructed your InitialContext or if it is a bean or client doing the
lookup.
Till then the "new InitialContext().lookup("java:openejb/Resource/
Foo")" approach will always work in the test case.
-David
Re: Putting data source into local container?
Posted by Laird Nelson <lj...@gmail.com>.
Hey, this gets weirder.
I found this:
http://www.nabble.com/DataSource-lookup-by-JNDI-name-tt23101598.html#a23101598
Now, this indicates that what you can do is set up your InitialContext, then
*throw it away*, then create a *new* InitialContext without
*any*properties, and look up your data source in
*there*.
I tried it and it works, but boy does it creep me out. :-)
Any ideas as to why I need to create a new InitialContext with no arguments
after my initialization code to get the subsequent lookup to work?
Cheerfully baffled,
Laird
Re: Putting data source into local container?
Posted by Laird Nelson <lj...@gmail.com>.
Here is my JUnit 4.5 test case demonstrating the problem.
package openejbbugs;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingEnumeration;
import javax.naming.NameClassPair;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
public class TestCaseOpenEJBBug {
private static Context context;
@BeforeClass
public static final void oneTimeSetup() throws Exception {
final Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
org.apache.openejb.client.LocalInitialContextFactory.class.getName());
properties.setProperty("test", "new://Resource?type=DataSource");
properties.setProperty("test.JdbcDriver", "org.h2.Driver");
properties.setProperty("test.JdbcUrl",
"jdbc:h2:mem:test;DB_CLOSE_DELAY=-1");
properties.setProperty("test.Username", "");
properties.setProperty("test.Password", "");
properties.put("test.DefaultAutoCommit", Boolean.valueOf(false));
// properties.setProperty("openejb.embedded.remotable", "true");
context = new InitialContext(properties);
boolean found = false;
final NamingEnumeration<NameClassPair> ne = context.list("");
assertNotNull(ne);
try {
while (ne.hasMore()) {
final NameClassPair ncp = ne.next();
assertNotNull(ncp);
final String n = ncp.getName();
assertNotNull(n);
if (n.indexOf("test") >= 0) {
found = true;
break;
}
}
} finally {
ne.close();
}
assertTrue(found); // XXX Test fails here
}
@Test
public void testLoad() throws Exception {
assertNotNull(context);
}
}
Best,
Laird
On Mon, Apr 20, 2009 at 1:34 PM, Laird Nelson <lj...@gmail.com> wrote:
> 3.1, yes, and sure, although the rest of my test code does not execute,
> because I don't get past this.
>
> The code I've supplied is all that I do to the InitialContext. I have a
> session bean which deploys properly (i.e. it is available in the Context).
>
> The JNDI content gets dumped by this code:
>
> final NamingEnumeration<NameClassPair> ne = context.list("");
> assertNotNull(ne);
> try {
> while (ne.hasMore()) {
> final NameClassPair ncp = ne.next();
> assertNotNull(ncp);
> System.out.println(ncp.getName() + " = " + ncp.getClassName());
> }
> } finally {
> ne.close();
> }
>
> ...and outputs:
>
> . = java.lang.String
> PersonsRemote = org.apache.openejb.core.ivm.naming.BusinessRemoteReference
>
> (PersonsRemote is obviously the deployment of my SLSB.)
>
> I will see what I can do to separate out the setup code from my test case
> and will post it next, although it won't add one whit to the information
> I've already supplied :-).
>
> Best,
> Laird
>
>
> On Mon, Apr 20, 2009 at 1:28 PM, Jean-Louis MONTEIRO <
> jean-louis.monteiro@atosorigin.com> wrote:
>
>>
>> Which openejb version do you use ?
>> Did you dump the JNDI content ?
>> Can you give us more code (from you unit test case ?) ?
>>
>> Jean-Louis
>>
>>
>> ljnelson wrote:
>> >
>> > Hello; I'd like to set up a data source in my embedded OpenEJB
>> container.
>> >
>> > Here's my code so far, which results in nothing being bound into the
>> JNDI
>> > tree:
>> >
>> > final Properties properties = new Properties();
>> > properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
>> > org.apache.openejb.client.LocalInitialContextFactory.class.getName());
>> > properties.setProperty("jdbc/test",
>> "new://Resource?type=DataSource");
>> > properties.setProperty("jdbc/test.JdbcDriver", "org.h2.Driver");
>> > properties.setProperty("jdbc/test.JdbcUrl",
>> > "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1");
>> > properties.setProperty("jdbc/test.Username", "");
>> > properties.setProperty("jdbc/test.Password", "");
>> > properties.put("jdbc/test.DefaultAutoCommit",
>> Boolean.valueOf(false));
>> > this.context = new InitialContext(properties);
>> >
>> > Any ideas? The context is empty. I got this recipe from the
>> > documentation
>> > on the website.
>> >
>> > Best,
>> > Laird
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Putting-data-source-into-local-container--tp23138888p23141193.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>
>>
>
Re: Putting data source into local container?
Posted by Laird Nelson <lj...@gmail.com>.
3.1, yes, and sure, although the rest of my test code does not execute,
because I don't get past this.
The code I've supplied is all that I do to the InitialContext. I have a
session bean which deploys properly (i.e. it is available in the Context).
The JNDI content gets dumped by this code:
final NamingEnumeration<NameClassPair> ne = context.list("");
assertNotNull(ne);
try {
while (ne.hasMore()) {
final NameClassPair ncp = ne.next();
assertNotNull(ncp);
System.out.println(ncp.getName() + " = " + ncp.getClassName());
}
} finally {
ne.close();
}
...and outputs:
. = java.lang.String
PersonsRemote = org.apache.openejb.core.ivm.naming.BusinessRemoteReference
(PersonsRemote is obviously the deployment of my SLSB.)
I will see what I can do to separate out the setup code from my test case
and will post it next, although it won't add one whit to the information
I've already supplied :-).
Best,
Laird
On Mon, Apr 20, 2009 at 1:28 PM, Jean-Louis MONTEIRO <
jean-louis.monteiro@atosorigin.com> wrote:
>
> Which openejb version do you use ?
> Did you dump the JNDI content ?
> Can you give us more code (from you unit test case ?) ?
>
> Jean-Louis
>
>
> ljnelson wrote:
> >
> > Hello; I'd like to set up a data source in my embedded OpenEJB container.
> >
> > Here's my code so far, which results in nothing being bound into the JNDI
> > tree:
> >
> > final Properties properties = new Properties();
> > properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
> > org.apache.openejb.client.LocalInitialContextFactory.class.getName());
> > properties.setProperty("jdbc/test",
> "new://Resource?type=DataSource");
> > properties.setProperty("jdbc/test.JdbcDriver", "org.h2.Driver");
> > properties.setProperty("jdbc/test.JdbcUrl",
> > "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1");
> > properties.setProperty("jdbc/test.Username", "");
> > properties.setProperty("jdbc/test.Password", "");
> > properties.put("jdbc/test.DefaultAutoCommit",
> Boolean.valueOf(false));
> > this.context = new InitialContext(properties);
> >
> > Any ideas? The context is empty. I got this recipe from the
> > documentation
> > on the website.
> >
> > Best,
> > Laird
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Putting-data-source-into-local-container--tp23138888p23141193.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>
Re: Putting data source into local container?
Posted by Jean-Louis MONTEIRO <je...@atosorigin.com>.
Which openejb version do you use ?
Did you dump the JNDI content ?
Can you give us more code (from you unit test case ?) ?
Jean-Louis
ljnelson wrote:
>
> Hello; I'd like to set up a data source in my embedded OpenEJB container.
>
> Here's my code so far, which results in nothing being bound into the JNDI
> tree:
>
> final Properties properties = new Properties();
> properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
> org.apache.openejb.client.LocalInitialContextFactory.class.getName());
> properties.setProperty("jdbc/test", "new://Resource?type=DataSource");
> properties.setProperty("jdbc/test.JdbcDriver", "org.h2.Driver");
> properties.setProperty("jdbc/test.JdbcUrl",
> "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1");
> properties.setProperty("jdbc/test.Username", "");
> properties.setProperty("jdbc/test.Password", "");
> properties.put("jdbc/test.DefaultAutoCommit", Boolean.valueOf(false));
> this.context = new InitialContext(properties);
>
> Any ideas? The context is empty. I got this recipe from the
> documentation
> on the website.
>
> Best,
> Laird
>
>
--
View this message in context: http://www.nabble.com/Putting-data-source-into-local-container--tp23138888p23141193.html
Sent from the OpenEJB User mailing list archive at Nabble.com.