• Post Reply Bookmark Topic Watch Topic
  • New Topic

Sample Session Bean creation.. javax.naming.NamingException: Lookup failed

 
Ravi Sathish
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers

I'm a newbie to EJB... was trying EJB Tutorials...

In Session Bean Creation I'm getting the following runtime exception:

javax.naming.NamingException: Lookup failed: java.security.AccessControlExceptio
n: access denied (java.net.SocketPermission localhost:2050 resolve)
at desisoft.ejb.client.EjbClientContext.lookup(EjbClientContext.java:81)

at javax.naming.InitialContext.lookup(Unknown Source)
at SessionClientSample.main(SessionClientSample.java:42)

The client code goes like this:

line 38>
Properties env = new Properties();
line 39> env.put "java.naming.factory.initial", "desisoft.ejb.client.JRMPFactory" );
line 40>
env.put( "desisoft.ejb.nameServer1", "localhost:2050" );

line 41>
Context ctx = new InitialContext( env );

line 42>
StockQuotesHome home = (StockQuotesHome) PortableRemoteObject.narrow(
ctx.lookup( "StockQuotes" ), StockQuotesHome.class );

System.out.println(" passed here 3");

I'm using Blazix application server.

Has anybody faced similar problems? How to resolve this one? I'm sure this exception is something related to security policy. Could anybody please help provide some insight about setting security policy in JRE.

Thanks in advance
Ravi
 
Anna Madhusudhanan Natanagopalan
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
can u try this line
env.put("java.naming.provider.url",your server ip address);
instead of
env.put( "desisoft.ejb.nameServer1", "localhost:2050" ); this line



Thanks and regards

Anna Madhusudhanana
 
Ravi Sathish
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anna

I tried your suggestion but its still not working. Have you tried this type of client program. If so, can you please paste the lines where you initialize the properties and obtain the home interface and obtain ejb context?

Thanks once again
Ravi
 
Trajan Walker
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravi:

I'm having exactly the same problem. I got passed your step with the following.

1. Add a client.policy file with the following contents:

grant {
// Allow everything for now
permission java.security.AllPermission;
};

2. Use java -Djava.security.policy=client.policy -classpath ... <classname>

That got me passed this error. I still haven't got it to work, but I did get passed the access denied error.
 
Trajan Walker
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also figured out the other problems I was having.

1.) The JNDI name had to be specified in JBOSS.xml and the lookup has to be exactly what you specify in the deployment descriptors.

2.) The class path in the client has to point to the jar file or a directory structure consistent with your package name. The class loader doesn't like to find the class file in a local directory that doesn't have the same directory structure as the classpath.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!