Pessoal,
Estou começando a brincar com EJB 2.1 usando o Apache Geronimo 1.1 no Eclipse.
Um dos exemplos que eu fiz (Exam Study Kit - Manning) usa um stateless Session Bean que ta dando pau na hora do lookup
Eu to usando OpenEJB. Abaixo o código do client e tb o ejb-jar.xml alem da exception..
Se alguem puder me ajudar, acho que tem algo errado no .xml
[]´s
#FortuneClient.java ##public static void main(String[] args) {
try {
Properties props = System.getProperties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"org.openejb.client.RemoteInitialContextFactory");
props.put(Context.PROVIDER_URL, "localhost:4201");
props.put(Context.SECURITY_PRINCIPAL, "system");
props.put(Context.SECURITY_CREDENTIALS, "manager");
Context ictx = new InitialContext(props);
Object objref =
ictx.lookup("java:comp/env/ejb/FortuneSelector");
FortuneHome home =
(FortuneHome)PortableRemoteObject.narrow(objref,
FortuneHome.class);
Fortune fortuner = home.create();
System.out.println(fortuner.getNextFortune());
System.exit(0);
} catch (Exception ex) {
System.err.println("Caught an exception!");
ex.printStackTrace();
}
}
<display-name>FortuneBean</display-name>
<enterprise-beans>
<session>
<display-name>FortuneBean</display-name>
<ejb-name>FortuneCookieBean</ejb-name>
<home>FortuneHome</home>
<remote>Fortune</remote>
<ejb-class>FortuneBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Bean</transaction-type>
<ejb-ref>
<ejb-ref-name>ejb/FortuneSelector</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>FortuneHome</home>
<remote>Fortune</remote>
<ejb-link>FortuneCookieBean</ejb-link>
</ejb-ref>
<security-identity>
<description></description>
<use-caller-identity></use-caller-identity>
</security-identity>
</session>
</enterprise-beans>
Caught an exception!
java.lang.ClassCastException: java.lang.IllegalArgumentException
at org.openejb.client.JNDIContext.lookup(JNDIContext.java:266)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at FortuneClient.main(FortuneClient.java:25)
