Toon posts:

[Java] RMI gaat fout

Pagina: 1
Acties:

Verwijderd

Topicstarter
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.

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 ]


  • Glimi
  • Registratie: Augustus 2000
  • Niet online

Glimi

Designer Drugs

(overleden)
Wat heb je al allemaal geprobeerd? Wat werkt er wel en wat niet? Wat vond je op google enz ;) Kortom: wat heb je zelf al gedaan :P Vul dat nog ff aan ajb :)
Heb je trouwens stub gegenereerd?

Verwijderd

volgens mij moet je in de volgende regel nog aangeven welke applicatie je aan wilt spreken op de ejb server:
code:
1
env.put(Context.PROVIDER_URL,"rmi://localhost");


dus je krijgt dan iets van
code:
1
env.put(Context.PROVIDER_URL,"rmi://localhost/myApp");


maar dat hangt af van welke app server je gebruikt, dit kun je waarschijnlijk wel vinden in de documentatie van je app server.