Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » JBoss Initial Context Problem
JBoss Initial Context Problem [message #494088] Thu, 29 October 2009 07:55 Go to next message
Patrick Haun is currently offline Patrick HaunFriend
Messages: 30
Registered: October 2009
Member
Hi,

I'm using JBoss 4.2.2.GA. I'm trying to use a datasource from the inside of my Application. Therefore I try to get the EntityManager via a JNDI lookup.

A JSP file containig this code snippet:

 
InitialContext ctx = new InitialContext(); 
DatabaseMetaData dm = null; 
DataSource ds = (DataSource) 
ctx.lookup("java:/DerbyDS"); 


works completly.


But inside my OSGi Application I get the following errors:

1.: using this code snippet
Context ctx = new InitialContext(); 
ctx.lookup("java:/DerbyDS"); 


leads to
09:59:34,750 ERROR [STDERR] javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]


2.: using this code snippet

 
final Properties env = new Properties(); 
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); 
env.put(Context.PROVIDER_URL, "jnp://localhost:1099"); 
env.put(Context.URL_PKG_PREFIXES, 
"org.jboss.naming:org.jnp.interfaces"); 
final Context initialContext = new InitialContext(env); 
initialContext.lookup("java:/DerbyDS"); 

leads to:
09:59:29,508 ERROR [STDERR] DerbyDS not bound


This is my underlying problem. If the JNDI lookups do work properly I want to get the Entity Manager this way.
Re: JBoss Initial Context Problem [message #496272 is a reply to message #494088] Mon, 09 November 2009 15:00 Go to previous messageGo to next message
Philip Borlin is currently offline Philip BorlinFriend
Messages: 30
Registered: July 2009
Member
Have you tried org.jboss.naming.NamingContextFactory as your INITIAL_CONTEXT_FACTORY?
Re: JBoss Initial Context Problem [message #496313 is a reply to message #494088] Mon, 09 November 2009 16:57 Go to previous message
Simon Kaegi is currently offline Simon KaegiFriend
Messages: 381
Registered: July 2009
Senior Member
The InitialContext lookup done by JNDI is frequently done by using the
thread's context class loader as a key. The posting below details an
approach that should help.

http://markmail.org/message/4t56wp3rjpf2u7pk?q=servletbridge +initialcontext+bridgeservlet&page=1&refer=4t56wp3rj pf2u7pk

-Simon

"Patrick Haun" <P.Haun@cenit.de> wrote in message
news:hcbhpl$9ab$1@build.eclipse.org...
> Hi,
> I'm using JBoss 4.2.2.GA. I'm trying to use a datasource from the inside
> of my Application. Therefore I try to get the EntityManager via a JNDI
> lookup.
> A JSP file containig this code snippet:
>
> InitialContext ctx = new InitialContext(); DatabaseMetaData dm = null;
> DataSource ds = (DataSource) ctx.lookup("java:/DerbyDS");
>
> works completly.
>
> But inside my OSGi Application I get the following errors:
> 1.: using this code snippet
> Context ctx = new InitialContext(); ctx.lookup("java:/DerbyDS");
> leads to 09:59:34,750 ERROR [STDERR]
> javax.naming.CommunicationException: Receive timed out [Root exception is
> java.net.SocketTimeoutException: Receive timed out]
> 2.: using this code snippet
> final Properties env = new Properties();
> env.put(Context.INITIAL_CONTEXT_FACTORY,
> "org.jnp.interfaces.NamingContextFactory"); env.put(Context.PROVIDER_URL,
> "jnp://localhost:1099"); env.put(Context.URL_PKG_PREFIXES,
> "org.jboss.naming:org.jnp.interfaces"); final Context initialContext = new
> InitialContext(env); initialContext.lookup("java:/DerbyDS");
> leads to: 09:59:29,508 ERROR [STDERR] DerbyDS not bound
>
> This is my underlying problem. If the JNDI lookups do work properly I want
> to get the Entity Manager this way.
Previous Topic:When gets the ExtensionRegistry its BundleEvents
Next Topic:p2 product update
Goto Forum:
  


Current Time: Sat Apr 27 00:16:09 GMT 2024

Powered by FUDForum. Page generated in 0.03086 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top