You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Anthony Fryer <ap...@hotmail.com> on 2012/12/06 03:34:04 UTC
How can i programmatically bind an object to the JNDI?
I have a very simple test case where i just bind a string to the jndi and
then attempt to look it up. This is failing with a NameNotFoundException in
the testReadFromJNDI test. What am i doing wrong here?
public class JNDITest {
private static InitialContext initialContext;
@BeforeClass
public static void beforeClass() throws Exception {
Properties p = new Properties();
p.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.core.LocalInitialContextFactory");
initialContext = new InitialContext(p);
}
@AfterClass
public static void afterClass() throws Exception {
}
@Before
public void setUp() throws NamingException, MalformedURLException {
}
@Test
public void testAddToJNDI() throws NamingException {
initialContext.bind("java:global/test", "true");
}
@Test
public void testReadFromJNDI() throws NamingException {
String test = (String)initialContext.lookup("java:global/test");
Assert.assertEquals("true", test);
}
}
--
View this message in context: http://openejb.979440.n4.nabble.com/How-can-i-programmatically-bind-an-object-to-the-JNDI-tp4659125.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: How can i programmatically bind an object to the JNDI?
Posted by Anthony Fryer <ap...@hotmail.com>.
I just discovered that the above test case is working if i run it within a
maven build. However it fails if i run it from eclipse. Maybe its a junit
version or eclipse issue.
--
View this message in context: http://openejb.979440.n4.nabble.com/How-can-i-programmatically-bind-an-object-to-the-JNDI-tp4659125p4659126.html
Sent from the OpenEJB User mailing list archive at Nabble.com.