-
1. Re: How to lookup EJB from external app
sbahal Jul 14, 2003 12:27 PM (in response to sbahal)I could get rid of this error by including the jboss-common.jar - that is such a pain- my clients may not have these files. But now I get this new error:
Exception:javax.naming.CommunicationException [Root exception is java.lang.ClassNotFoundException: org.jboss.proxy.ClientContainer (no security manager: RMI class loader disabled)]
I have tried it two ways:
1. cosNamingProperties.put( InitialContext.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
cosNamingProperties.put(InitialContext.PROVIDER_URL, "jnp://"+host+":"+port);
cosNamingProperties.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
2. cosNamingProperties.put( "java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory" );
cosNamingProperties.put( "java.naming.provider.url", host+":"+port ) ;
cosNamingProperties.put( "java.naming.factory.url.pkgs", "org.jboss.naming" ) ;
I get the same error in both cases.
Thanks again,
Sanjay -
2. Re: How to lookup EJB from external app- It works
sbahal Jul 14, 2003 1:50 PM (in response to sbahal)It finally works:
To get rid of the RMI error you need to setup the regular RMI security with policy file etc:
cosNamingProperties.put( "java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory" );
cosNamingProperties.put( "java.naming.provider.url", host+":"+port ) ;
So to sum up you need the flwg files in the client path:
jnpserver.jar, jboss-common.jar
The code is:
Properties cosNamingProperties = new Properties();
if (System.getSecurityManager() == null) {
System.setProperty("java.security.policy","server.policy"); //the policy file
System.setSecurityManager(new RMISecurityManager());
}
cosNamingProperties.put( "java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory" );
cosNamingProperties.put( "java.naming.provider.url", host+":"+port ) ;
InitialContext ctx = new InitialContext(cosNamingProperties);
ctx = new InitialContext(cosNamingProperties);
Object obj = ctx.lookup(bindName);
If anybody knows how to (if at all possible) to do the lookup without the jboss specific jar files.
Thanks a lot,
Sanjay -
3. Re: How to lookup EJB from external app- It works
imdkidd Jul 14, 2003 5:10 PM (in response to sbahal)If you don't want to hard code the JNDI parameters, you could always include a jndi.properties file with the url and context factory and include it in your WEB-INF/classes directory.
-
4. Re: How to lookup EJB from external app- It works
frito Jul 15, 2003 3:08 AM (in response to sbahal)You don't ever need to include server .jar files with your client. All libs you need are in your /client directory. Try with jbossall-client.jar which includes everything a client could need or determine which jars you need if you don't want to include the whole client thing at all.
Greetings,
Frito -
5. Re: How to lookup EJB from external app- It works
sbahal Jul 15, 2003 4:19 PM (in response to sbahal)Frito- Yes I can use the jbossall-client.jar that does reduce the jar files from 2 to 1.
Ideally I would like to use some generic jdk files to do lookup- if that is at all possible.
imdkidd- Yes I can use the property file for the setup information. My issue is the jar files and doing JBoss specific lookup things.
Thanks
Sanjay -
6. Re: How to lookup EJB from external app- It works
frito Jul 16, 2003 3:27 AM (in response to sbahal)This is not possible, since you receive an implementation for a stub. This stub is communicating with the skeleton on the server. These implementations are vendor specific. Therefore you need a client.jar for every appserver you want to use.
Greetings,
Frito -
7. Re: How to lookup EJB from external app- It works
sbahal Jul 16, 2003 9:10 AM (in response to sbahal)Frito,
Thanks. I undersatnd what you are saying. But this just breaks the whole concept of a client being independent/agnostic of the server. In this case it seems it is very dependent.
Sanjay -
8. Re: How to lookup EJB from external app- It works
frito Jul 17, 2003 3:10 AM (in response to sbahal)Remember: the client code is not dependent on what application server you are working. The implementations are behind standard interfaces at all. But the running instance is, of course. You need the resources to access the server implementation your are working with.
Greetings,
Frito