[jboss-user] [EJB/JBoss] - Just a question
tinico
do-not-reply at jboss.com
Fri Mar 9 11:56:39 EST 2007
Hello all, sorry for my english, I'm french !!
I've a comprehension problem !
I had a problem to find an EJB from a web application. To find it I made :
| Context ctx = new InitialContext();
| EjbExemple home = (EjbExempleHome)PortableRemoteObject.narrow( ctx.lookup(?ejbname?), EjbExempleHome.class );
| ejb = home.create();
|
This lines works only if my client is a simple jsp. If my client was my web application, this don't work. I've solve thi problem with this lines :
| properties = new Properties();
| properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
| properties.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
| properties.put(Context.PROVIDER_URL, "localhost:1099");
|
So, I find my EJB with :
Context ctx = new InitialContext(properties);
And it work !
My EJB interact with an Oracle database, so I ahve to find the connection with EJB. To do that, I use :
Context ic = new InitialContext();
| ds = (DataSource) ic.lookup(?connectionname?);
It Work !!! Without properties !
So, here, my question :
Why the jsp work without context properties whereas my web app need it ?
And, Why I don't need the context properties to find my connection whereas I need it to find EJB ??
My application work, but, it's a question which I would like to have the answer.
Thx
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4026663#4026663
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4026663
More information about the jboss-user
mailing list