Hi ,
I tried as per the suggestion to see if java:comp/env works .
Here is what I did
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
p.put(Context.PROVIDER_URL,"localhost:1099");
p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming");
Context ctx = (Context) new
InitialContext(p).lookup("java:comp/env");
javax.naming.NamingEnumeration enum1 = ctx.list("");
while(enum1.hasMore())
{
System.out.println("Object 1:"+enum1.next());
}
Here is what I got
javax.naming.NameNotFoundException: comp not bound
at
sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(
RemoteCall.java:245)
at
sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall
220)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at
org.jnp.interfaces.NamingContext.lookup(NamingContext.java:280)
at
org.jnp.interfaces.NamingContext.lookup(NamingContext.java:265)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at com.ebd.ejb.CabinClient.main(CabinClient.java:45)
Rickard �berg wrote:
>
> Hi!
>
> pranab wrote:
> > I was trying to use the prefix "java:comp/env" to lookup on a
> > EJB.
> > It doesn't work that way in Jboss2.However it works when doing a plain
> > lookup on the EJB JNDI Name.
> >
> > I used this code to find out whats in there in the jndi context
> >
> > Context jndiContext = getInitialContext();
> > System.out.println("Name:"+
> > jndiContext.getNameInNamespace());
> > System.out.println("Environment:"+
> > jndiContext.getEnvironment());
> > javax.naming.NamingEnumeration enum = jndiContext.list("");
> > while(enum.hasMore())
> > {
> > System.out.println("Object:"+enum.next());
> > }
> > javax.naming.NamingEnumeration enum =
> > jndiContext.list("jdbc");
> > while(enum.hasMore())
> > {
> > System.out.println("Object:"+enum.next());
> > }
> > here is the output
> > Object:Hypersonic: org.jboss.jdbc.DataSourceImpl
> > Object:jmx: org.jboss.jmx.server.JMXAdaptorImpl
> > Object:TravelAgentBean: $Proxy0
> > Object:Cabin: $Proxy1
> > Object:jdbc: org.jnp.interfaces.NamingContext
> > Object:xa.postgresqlPool: org.jboss.minerva.datasource.XAPoolDataSource
> > Object:InstantDB: org.jboss.jdbc.DataSourceImpl
> > Object:TransactionManager: class org.jboss.tm.TxManager
> > initial context :javax.naming.InitialContext@b66cc
> > Object:jdbc/postgresql: org.jboss.jdbc.DataSourceImpl
>
> You are listing the root default context. This is exactly how it should
> be.
>
> > I think the call getNameInNamespace for the root context is not mapped
> > to "java:comp/env"
> > string.
>
> Which it should not be.
>
> > Is it how it is supposed to function???????
>
> Yes. You are accessing the default JNDI namespace. If you want to access
> the java: namespace then you must lookup the java: namespace. Like this:
> Context ctx = new InitialContext().lookup("java:comp/env");
> .. and do a listing of that. The contents will be what you specified in
> your ejb-jar.xml descriptor. If you haven't specified anything (no
> references or environment entries) it will be empty.
Here are my references
[Container factory] Deploying Cabin
[Container factory] Deploying TravelAgentBean
[Container factory] Binding an EJBReference testref
[Container factory] Binding testref to external JNDI source: Cabin
[Container factory] Binding an EJBReference ejb/CabinHome
[Container factory] Binding ejb/CabinHome to external JNDI source: Cabin
[Container factory] Binding an EJBReference sessionref
[Container factory] Binding sessionref to external JNDI source:
TravelAgentBean
...
[Container factory] Bound TravelAgentBean to TravelAgentBean
[Container factory] Bound Cabin to Cabin
Besides this I have one environment Reference in ejb-jar.xml
<env-entry-name>TEST_ENV</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>It Works</env-entry-value>
I am yet to see it work.
PKD
>
> /Rickard
>
> --
> Rickard �berg
>
> @home: +46 13 177937
> Email: [EMAIL PROTECTED]
> http://www.telkel.com
> http://www.jboss.org
> http://www.dreambean.com
>
> --
> --------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> Problems?: [EMAIL PROTECTED]
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Problems?: [EMAIL PROTECTED]