Hello,
i`m relativly new to Java and working on a project in which i`d like to call an
EJB from a Desktop client. UNfortunately now i'm stuck. As far as i can tell
the connection works fine. I' getting also something back from the server. As i
understand it is the reference object of the searched bean. The problem is,
that i get a ClassCastException if i try to cast this object to an BeanRemote
object. This is my client code:
public static void main(String args[]) throws NamingException, RemoteException {
|
| Hashtable env = new Hashtable();
| env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
| env.put(Context.URL_PKG_PREFIXES,
"org.jboss.naming:org.jnp.interfaces");
| env.put(Context.PROVIDER_URL, "jnp://localhost:1099");
|
| final Context ic = new InitialContext(env);
| Object client = ic.lookup("ClientBean");
| ClientLocal home = (ClientLocal)client; //This line causes The error
| System.out.println("ClientBean is bound to: " + client);
|
| java.awt.EventQueue.invokeLater(new Runnable() {
| public void run() {
| new Client().setVisible(true);
| }
| });
| }
|
| // Variables declaration - do not modify
| private javax.swing.JLabel jLabel1;
| private javax.swing.JButton showButton;
| private javax.swing.JTextField textFieldClient;
| private javax.swing.JButton updateButton;
| // End of variables declaration
|
| }
|
The output i get:
compile:
run:
2007-07-27 10:29:46.504 java[363] CFLog (0): CFMessagePort:
bootstrap_register(): failed 1103 (0x44f), port = 0x10303, name =
'java.ServiceProvider'
See /usr/include/servers/bootstrap_defs.h for the error codes.
2007-07-27 10:29:46.505 java[363] CFLog (99): CFMessagePortCreateLocal():
failed to name Mach port (java.ServiceProvider)
Exception in thread "main" java.lang.ClassCastException:
org.jnp.interfaces.NamingContext
at com.planetactive.ejb.client.Client.main(Client.java:106)
Java Result: 1
BUILD SUCCESSFUL (total time: 3 seconds)
If i uncomment the described line, this is my output. As you can see i get
[EMAIL PROTECTED]
back from my lookup.
compile:
run:
2007-07-27 10:31:03.198 java[364] CFLog (0): CFMessagePort:
bootstrap_register(): failed 1103 (0x44f), port = 0x10303, name =
'java.ServiceProvider'
See /usr/include/servers/bootstrap_defs.h for the error codes.
2007-07-27 10:31:03.198 java[364] CFLog (99): CFMessagePortCreateLocal():
failed to name Mach port (java.ServiceProvider)
ClientBean is bound to: [EMAIL PROTECTED]
BUILD SUCCESSFUL (total time: 5 seconds)
I've searched many forums for this problem. Seems te be an often seen problem.
Unfortunately i couldn't find a solution. I hope you can help me to fix this.
I'm using Jboss 4.2.0 GA and Netbeans.
Thanks in advance
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4068224#4068224
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4068224
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user