Ik zit met het volgende probleem. Ik wil een client schrijven die via rmi communiceert met een server(EJB). Maar bij de volgende code krijg ik altijd dezelfde foutmelding. Ik werk in IBM Websphere Studio Application Developper.
javax.naming.CommunicationException. Root exception is java.rmi.MarshalException: Error marshaling transport header; nested exception is:
java.net.SocketException: Connection aborted by peer: socket closed
java.net.SocketException: Connection aborted by peer: socket closed
at java.net.SocketInputStream.socketRead(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:113)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:202)
at java.io.BufferedInputStream.read(BufferedInputStream.java:220)
at java.io.DataInputStream.readByte(DataInputStream.java:241)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:244)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:201)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:331)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:103)
at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:113)
at javax.naming.InitialContext.lookup(InitialContext.java:359)
at examples.HelloClient.main(HelloClient.java:19)
Exception in thread "main"
Java:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
| package examples; import javax.naming.Context; import javax.naming.InitialContext; import java.util.Hashtable; import java.util.Properties; public class HelloClient { public static void main (String [] args) throws Exception { Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.rmi.registry.RegistryContextFactory"); env.put(Context.PROVIDER_URL,"rmi://localhost"); //Properties props = System.getProperties(); Context ctx = new InitialContext(env); Object obj = ctx.lookup("HelloHome"); HelloHome home = (HelloHome) javax.rmi.PortableRemoteObject.narrow(obj,HelloHome.class); Hello hello = home.create(); System.out.println(hello.hello()); hello.remove(); } } |
javax.naming.CommunicationException. Root exception is java.rmi.MarshalException: Error marshaling transport header; nested exception is:
java.net.SocketException: Connection aborted by peer: socket closed
java.net.SocketException: Connection aborted by peer: socket closed
at java.net.SocketInputStream.socketRead(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:113)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:202)
at java.io.BufferedInputStream.read(BufferedInputStream.java:220)
at java.io.DataInputStream.readByte(DataInputStream.java:241)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:244)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:201)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:331)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:103)
at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:113)
at javax.naming.InitialContext.lookup(InitialContext.java:359)
at examples.HelloClient.main(HelloClient.java:19)
Exception in thread "main"
[ Voor 2% gewijzigd door .oisyn op 08-05-2003 14:06 ]