You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by Rafael Barrera Oro <ra...@akyasociados.com.ar> on 2006/07/12 20:49:23 UTC
Unable to make a simple SessionBean lookup
I am trying to make a simple lookup for a simple SessionBean and,
altough it throws no exception, nothing happens as i can wait forever if
i want before the lookup is completed, maybe it has something to with
the incomplete openejb-jar.xml or incosistent properties passed to the
InitialContext, i really have no clue whatsoever.
this is the code of the client class:
import java.rmi.RemoteException;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
import beans.Rafa;
import beans.RafaHome;
public class Client {
/**
* @param args
*/
public static void main(String[] args) {
Context ctx;
Rafa rafa;
RafaHome home;
Object obj;
Properties props;props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
props.put("java.naming.provider.url", "127.0.0.1");
try{
ctx = new InitialContext(props);
obj = ctx.lookup("YATest/YATest");
home = (RafaHome)PortableRemoteObject.narrow(obj,
RafaHome.class);
rafa = home.create();
rafa.test();
}
catch(Exception e){
System.out.println("ERROR: " + e.getMessage());
}
}
}
openejb.jar.xml:
<?xml version="1.0" encoding="UTF-8"?>
<openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.0"
xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.0"
xmlns:pkgen="http://www.openejb.org/xml/ns/pkgen-2.0"
xmlns:sec="http://geronimo.apache.org/xml/ns/security-1.1"
xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.0"
configId="YATest/YATest" parentId="MyWebProject/MyWebProject">
<enterprise-beans/>
</openejb-jar>
ejb-jar.xml:
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar id="ejb-jar_ID" version="2.1"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
<display-name>
YATest</display-name>
<enterprise-beans>
<session>
<ejb-name>Rafa</ejb-name>
<home>beans.RafaHome</home>
<remote>beans.Rafa</remote>
<ejb-class>beans.RafaEJB</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>
If i look in the Geronimo console i see there is an EJB Jar deployed
under the component name: YATest/YATest, so i am sure the bean is being
deployed.
Any help will be greatly appreciated, thanks in advance
Rafael
Re: Unable to make a simple SessionBean lookup
Posted by Rafael Barrera Oro <ra...@akyasociados.com.ar>.
Thanks, you are right about that, i copied this from a JBOSS client
example and forgot to change it
Aaron Mulder wrote:
> I'm not sure your INITIAL_CONTEXT_FACTORY is correct -- org.jnp
> doesn't look right to me.
>
> Thanks,
> Aaron
>
> On 7/12/06, Rafael Barrera Oro <ra...@akyasociados.com.ar> wrote:
>> I am trying to make a simple lookup for a simple SessionBean and,
>> altough it throws no exception, nothing happens as i can wait forever if
>> i want before the lookup is completed, maybe it has something to with
>> the incomplete openejb-jar.xml or incosistent properties passed to the
>> InitialContext, i really have no clue whatsoever.
>>
>> this is the code of the client class:
>>
>> import java.rmi.RemoteException;
>> import java.util.Properties;
>>
>> import javax.naming.Context;
>> import javax.naming.InitialContext;
>> import javax.naming.NamingException;
>> import javax.rmi.PortableRemoteObject;
>>
>> import beans.Rafa;
>> import beans.RafaHome;
>>
>> public class Client {
>>
>> /**
>> * @param args
>> */
>> public static void main(String[] args) {
>> Context ctx;
>> Rafa rafa;
>> RafaHome home;
>> Object obj;
>>
>> Properties props;props = new Properties();
>>
>> props.put(Context.INITIAL_CONTEXT_FACTORY,
>> "org.jnp.interfaces.NamingContextFactory");
>> props.put("java.naming.provider.url", "127.0.0.1");
>>
>>
>>
>> try{
>> ctx = new InitialContext(props);
>> obj = ctx.lookup("YATest/YATest");
>> home = (RafaHome)PortableRemoteObject.narrow(obj,
>> RafaHome.class);
>> rafa = home.create();
>> rafa.test();
>>
>> }
>> catch(Exception e){
>> System.out.println("ERROR: " + e.getMessage());
>> }
>> }
>>
>> }
>>
>> openejb.jar.xml:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.0"
>> xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.0"
>> xmlns:pkgen="http://www.openejb.org/xml/ns/pkgen-2.0"
>> xmlns:sec="http://geronimo.apache.org/xml/ns/security-1.1"
>> xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.0"
>> configId="YATest/YATest" parentId="MyWebProject/MyWebProject">
>> <enterprise-beans/>
>> </openejb-jar>
>>
>> ejb-jar.xml:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <ejb-jar id="ejb-jar_ID" version="2.1"
>> xmlns="http://java.sun.com/xml/ns/j2ee"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
>> http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
>> <display-name>
>> YATest</display-name>
>> <enterprise-beans>
>> <session>
>> <ejb-name>Rafa</ejb-name>
>> <home>beans.RafaHome</home>
>> <remote>beans.Rafa</remote>
>> <ejb-class>beans.RafaEJB</ejb-class>
>> <session-type>Stateless</session-type>
>> <transaction-type>Container</transaction-type>
>> </session>
>> </enterprise-beans>
>> </ejb-jar>
>>
>> If i look in the Geronimo console i see there is an EJB Jar deployed
>> under the component name: YATest/YATest, so i am sure the bean is being
>> deployed.
>>
>> Any help will be greatly appreciated, thanks in advance
>>
>> Rafael
>>
>
Re: Unable to make a simple SessionBean lookup
Posted by Aaron Mulder <am...@alumni.princeton.edu>.
I'm not sure your INITIAL_CONTEXT_FACTORY is correct -- org.jnp
doesn't look right to me.
Thanks,
Aaron
On 7/12/06, Rafael Barrera Oro <ra...@akyasociados.com.ar> wrote:
> I am trying to make a simple lookup for a simple SessionBean and,
> altough it throws no exception, nothing happens as i can wait forever if
> i want before the lookup is completed, maybe it has something to with
> the incomplete openejb-jar.xml or incosistent properties passed to the
> InitialContext, i really have no clue whatsoever.
>
> this is the code of the client class:
>
> import java.rmi.RemoteException;
> import java.util.Properties;
>
> import javax.naming.Context;
> import javax.naming.InitialContext;
> import javax.naming.NamingException;
> import javax.rmi.PortableRemoteObject;
>
> import beans.Rafa;
> import beans.RafaHome;
>
> public class Client {
>
> /**
> * @param args
> */
> public static void main(String[] args) {
> Context ctx;
> Rafa rafa;
> RafaHome home;
> Object obj;
>
> Properties props;props = new Properties();
>
> props.put(Context.INITIAL_CONTEXT_FACTORY,
> "org.jnp.interfaces.NamingContextFactory");
> props.put("java.naming.provider.url", "127.0.0.1");
>
>
>
> try{
> ctx = new InitialContext(props);
> obj = ctx.lookup("YATest/YATest");
> home = (RafaHome)PortableRemoteObject.narrow(obj,
> RafaHome.class);
> rafa = home.create();
> rafa.test();
>
> }
> catch(Exception e){
> System.out.println("ERROR: " + e.getMessage());
> }
> }
>
> }
>
> openejb.jar.xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.0"
> xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.0"
> xmlns:pkgen="http://www.openejb.org/xml/ns/pkgen-2.0"
> xmlns:sec="http://geronimo.apache.org/xml/ns/security-1.1"
> xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.0"
> configId="YATest/YATest" parentId="MyWebProject/MyWebProject">
> <enterprise-beans/>
> </openejb-jar>
>
> ejb-jar.xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ejb-jar id="ejb-jar_ID" version="2.1"
> xmlns="http://java.sun.com/xml/ns/j2ee"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
> http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
> <display-name>
> YATest</display-name>
> <enterprise-beans>
> <session>
> <ejb-name>Rafa</ejb-name>
> <home>beans.RafaHome</home>
> <remote>beans.Rafa</remote>
> <ejb-class>beans.RafaEJB</ejb-class>
> <session-type>Stateless</session-type>
> <transaction-type>Container</transaction-type>
> </session>
> </enterprise-beans>
> </ejb-jar>
>
> If i look in the Geronimo console i see there is an EJB Jar deployed
> under the component name: YATest/YATest, so i am sure the bean is being
> deployed.
>
> Any help will be greatly appreciated, thanks in advance
>
> Rafael
>
Re: Unable to make a simple SessionBean lookup
Posted by David Blevins <da...@visi.com>.
On Jul 13, 2006, at 7:42 AM, Rafael Barrera Oro wrote:
>
> Aaron Mulder wrote:
>>
>> On 7/13/06, Rafael Barrera Oro <ra...@akyasociados.com.ar> wrote:
>>> The problem thas arose now is that when i invoke the create
>>> method from
>>> the home interface, the result is the following exception:
>>>
>>> Exception in thread "main" java.lang.NoClassDefFoundError:
>>> org/apache/geronimo/security/ContextManager
>>
>> You need a couple Geronimo JARs on the class path of the client. I'm
>> not sure which ones off the top of my head. But this error would
>> suggest geronimo-security-1.1.jar is one of them. :) You can find
>> the JARs in geronimo-1.1/repository/geronimo/...
>>
>
> It worked perfectly, thanks a zillion, really. I 've been stuck for
> a while on this.
>
There's an open JIRA with a list of client jars required for a plain-
java ejb client. Feel welcome to update that with a more current list
http://jira.codehaus.org/browse/OPENEJB-19
Or better yet, feel free to edit this page and add a note about the
right jars for OpenEJB 2.x/Geronimo 1.x
http://docs.codehaus.org/display/OPENEJB/Remote+Server
Thanks!
-David
Re: Unable to make a simple SessionBean lookup
Posted by Rafael Barrera Oro <ra...@akyasociados.com.ar>.
It worked perfectly, thanks a zillion, really. I 've been stuck for a
while on this.
Rafael
Aaron Mulder wrote:
> You need a couple Geronimo JARs on the class path of the client. I'm
> not sure which ones off the top of my head. But this error would
> suggest geronimo-security-1.1.jar is one of them. :) You can find
> the JARs in geronimo-1.1/repository/geronimo/...
>
> Thanks,
> Aaron
>
> On 7/13/06, Rafael Barrera Oro <ra...@akyasociados.com.ar> wrote:
>> The problem thas arose now is that when i invoke the create method from
>> the home interface, the result is the following exception:
>>
>> Exception in thread "main" java.lang.NoClassDefFoundError:
>> org/apache/geronimo/security/ContextManager
>> at org.openejb.client.EJBHomeHandler.create(EJBHomeHandler.java:219)
>> at
>> org.openejb.client.EJBHomeHandler._invoke(EJBHomeHandler.java:148)
>> at
>> org.openejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:181)
>>
>> at
>> org.openejb.client.CgLibInvocationHandler.invoke(CgLibInvocationHandler.java:77)
>>
>> at
>> org.openejb.client.CgLibInvocationHandler.intercept(CgLibInvocationHandler.java:67)
>>
>> at
>> org.openejb.client.CgLibProxy$$EnhancerByCGLIB$$a242ddb2.create(<generated>)
>>
>> at Client.main(Client.java:33)
>>
>> Again, thanks in advance
>>
>>
>
Re: Unable to make a simple SessionBean lookup
Posted by Aaron Mulder <am...@alumni.princeton.edu>.
You need a couple Geronimo JARs on the class path of the client. I'm
not sure which ones off the top of my head. But this error would
suggest geronimo-security-1.1.jar is one of them. :) You can find
the JARs in geronimo-1.1/repository/geronimo/...
Thanks,
Aaron
On 7/13/06, Rafael Barrera Oro <ra...@akyasociados.com.ar> wrote:
> The problem thas arose now is that when i invoke the create method from
> the home interface, the result is the following exception:
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/geronimo/security/ContextManager
> at org.openejb.client.EJBHomeHandler.create(EJBHomeHandler.java:219)
> at org.openejb.client.EJBHomeHandler._invoke(EJBHomeHandler.java:148)
> at
> org.openejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:181)
> at
> org.openejb.client.CgLibInvocationHandler.invoke(CgLibInvocationHandler.java:77)
> at
> org.openejb.client.CgLibInvocationHandler.intercept(CgLibInvocationHandler.java:67)
> at
> org.openejb.client.CgLibProxy$$EnhancerByCGLIB$$a242ddb2.create(<generated>)
> at Client.main(Client.java:33)
>
> Again, thanks in advance
>
>
Re: Unable to make a simple SessionBean lookup
Posted by Rafael Barrera Oro <ra...@akyasociados.com.ar>.
The problem thas arose now is that when i invoke the create method from
the home interface, the result is the following exception:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/geronimo/security/ContextManager
at org.openejb.client.EJBHomeHandler.create(EJBHomeHandler.java:219)
at org.openejb.client.EJBHomeHandler._invoke(EJBHomeHandler.java:148)
at
org.openejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:181)
at
org.openejb.client.CgLibInvocationHandler.invoke(CgLibInvocationHandler.java:77)
at
org.openejb.client.CgLibInvocationHandler.intercept(CgLibInvocationHandler.java:67)
at
org.openejb.client.CgLibProxy$$EnhancerByCGLIB$$a242ddb2.create(<generated>)
at Client.main(Client.java:33)
Again, thanks in advance
Re: Unable to make a simple SessionBean lookup
Posted by Rafael Barrera Oro <ra...@akyasociados.com.ar>.
Thank you very much, that solved the problem, however now i am not sure
if i am setting the SECURITY_CREDENTIALS and SECURITY_PRINCIPAL values
right, are these mandatory anyway? which values are possible? where are
they configured?
Thanks a lot anyway
David Blevins wrote:
>
> On Jul 12, 2006, at 11:49 AM, Rafael Barrera Oro wrote:
>
>> I am trying to make a simple lookup for a simple SessionBean and,
>> altough it throws no exception, nothing happens as i can wait forever
>> if i want before the lookup is completed, maybe it has something to
>> with the incomplete openejb-jar.xml or incosistent properties passed
>> to the InitialContext, i really have no clue whatsoever.
>>
>
> If you're using a non-J2EE app client (i.e. plain java code), you
> should use these values:
>
> http://openejb.codehaus.org/Remote+Server
>
> -David
>
>
>> this is the code of the client class:
>>
>> import java.rmi.RemoteException;
>> import java.util.Properties;
>>
>> import javax.naming.Context;
>> import javax.naming.InitialContext;
>> import javax.naming.NamingException;
>> import javax.rmi.PortableRemoteObject;
>>
>> import beans.Rafa;
>> import beans.RafaHome;
>>
>> public class Client {
>>
>> /**
>> * @param args
>> */
>> public static void main(String[] args) {
>> Context ctx;
>> Rafa rafa;
>> RafaHome home;
>> Object obj;
>> Properties props;props = new Properties();
>> props.put(Context.INITIAL_CONTEXT_FACTORY,
>> "org.jnp.interfaces.NamingContextFactory");
>> props.put("java.naming.provider.url", "127.0.0.1");
>>
>> try{
>> ctx = new InitialContext(props);
>> obj = ctx.lookup("YATest/YATest");
>> home = (RafaHome)PortableRemoteObject.narrow(obj, RafaHome.class);
>> rafa = home.create();
>> rafa.test();
>> }
>> catch(Exception e){
>> System.out.println("ERROR: " + e.getMessage());
>> }
>> }
>>
>> }
>>
>> openejb.jar.xml:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.0"
>> xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.0"
>> xmlns:pkgen="http://www.openejb.org/xml/ns/pkgen-2.0"
>> xmlns:sec="http://geronimo.apache.org/xml/ns/security-1.1"
>> xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.0"
>> configId="YATest/YATest" parentId="MyWebProject/MyWebProject">
>> <enterprise-beans/>
>> </openejb-jar>
>>
>> ejb-jar.xml:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <ejb-jar id="ejb-jar_ID" version="2.1"
>> xmlns="http://java.sun.com/xml/ns/j2ee"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
>> http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
>> <display-name>
>> YATest</display-name>
>> <enterprise-beans>
>> <session>
>> <ejb-name>Rafa</ejb-name>
>> <home>beans.RafaHome</home>
>> <remote>beans.Rafa</remote>
>> <ejb-class>beans.RafaEJB</ejb-class>
>> <session-type>Stateless</session-type>
>> <transaction-type>Container</transaction-type>
>> </session>
>> </enterprise-beans>
>> </ejb-jar>
>>
>> If i look in the Geronimo console i see there is an EJB Jar deployed
>> under the component name: YATest/YATest, so i am sure the bean is
>> being deployed.
>>
>> Any help will be greatly appreciated, thanks in advance
>>
>> Rafael
>>
>
>
Re: Unable to make a simple SessionBean lookup
Posted by David Blevins <da...@visi.com>.
On Jul 12, 2006, at 11:49 AM, Rafael Barrera Oro wrote:
> I am trying to make a simple lookup for a simple SessionBean and,
> altough it throws no exception, nothing happens as i can wait
> forever if i want before the lookup is completed, maybe it has
> something to with the incomplete openejb-jar.xml or incosistent
> properties passed to the InitialContext, i really have no clue
> whatsoever.
>
If you're using a non-J2EE app client (i.e. plain java code), you
should use these values:
http://openejb.codehaus.org/Remote+Server
-David
> this is the code of the client class:
>
> import java.rmi.RemoteException;
> import java.util.Properties;
>
> import javax.naming.Context;
> import javax.naming.InitialContext;
> import javax.naming.NamingException;
> import javax.rmi.PortableRemoteObject;
>
> import beans.Rafa;
> import beans.RafaHome;
>
> public class Client {
>
> /**
> * @param args
> */
> public static void main(String[] args) {
> Context ctx;
> Rafa rafa;
> RafaHome home;
> Object obj;
> Properties props;props = new Properties();
> props.put(Context.INITIAL_CONTEXT_FACTORY,
> "org.jnp.interfaces.NamingContextFactory");
> props.put("java.naming.provider.url", "127.0.0.1");
>
> try{
> ctx = new InitialContext(props);
> obj = ctx.lookup("YATest/YATest");
> home = (RafaHome)PortableRemoteObject.narrow(obj,
> RafaHome.class);
> rafa = home.create();
> rafa.test();
> }
> catch(Exception e){
> System.out.println("ERROR: " + e.getMessage());
> }
> }
>
> }
>
> openejb.jar.xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.0"
> xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.0"
> xmlns:pkgen="http://www.openejb.org/xml/ns/pkgen-2.0"
> xmlns:sec="http://geronimo.apache.org/xml/ns/security-1.1"
> xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.0"
> configId="YATest/YATest" parentId="MyWebProject/MyWebProject">
> <enterprise-beans/>
> </openejb-jar>
>
> ejb-jar.xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ejb-jar id="ejb-jar_ID" version="2.1" xmlns="http://java.sun.com/
> xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://
> java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
> <display-name>
> YATest</display-name>
> <enterprise-beans>
> <session>
> <ejb-name>Rafa</ejb-name>
> <home>beans.RafaHome</home>
> <remote>beans.Rafa</remote>
> <ejb-class>beans.RafaEJB</ejb-class>
> <session-type>Stateless</session-type>
> <transaction-type>Container</transaction-type>
> </session>
> </enterprise-beans>
> </ejb-jar>
>
> If i look in the Geronimo console i see there is an EJB Jar
> deployed under the component name: YATest/YATest, so i am sure the
> bean is being deployed.
>
> Any help will be greatly appreciated, thanks in advance
>
> Rafael
>