From: wittnebel <nu...@jb...> - 2005-07-15 17:05:21
|
Ich soll eine J2EE Applikation schreiben, die EJBs als Middleware benutzt. Auf die Middleware soll mit Hilfe eines Swing Clients zugegriffen werden. Als Voruebung habe ich einen TestClient entwickelt (siehe Anlage), der den Namen der EJB mittels JNDI im Initialcontext nachgucken soll. Aber es geht schon bei der Instanziierung des Initialkontexts schief, die Anmeldekonfiguration kann nicht gefunden werden. Dabei habe ich in den Properties fuer den Initialkontext auch den Ort der auth.conf angegeben. Kann mir jemand bitte einen Tip geben? Anna //15.Juli 2005 package de.mpg.mpimbonn.transaction; import javax.naming.Context; import javax.naming.InitialContext; import javax.rmi.PortableRemoteObject; import de.mpg.mpimbonn.ejb.Example; import de.mpg.mpimbonn.ejb.ExampleHome; import java.util.Properties; public class TestClient { public Context login(String user, String password) { Context ctx = null; Properties p = new Properties(); p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.security.jndi.LoginInitialContextFactory"); p.put(Context.PROVIDER_URL, "jnp://localhost:1099"); p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); p.put(Context.SECURITY_AUTHENTICATION, "file:///C:/j2ee/jboss-4.0.2/client/auth.conf"); p.put(Context.SECURITY_PROTOCOL, "login"); p.put(Context.SECURITY_PRINCIPAL, user); p.put(Context.SECURITY_CREDENTIALS, password); try{ ctx = new InitialContext(p); }catch(Exception e){ System.out.println("Schon bei der Instanziierung des "); System.out.println("Initialkontextes geht was schief! "); System.out.println("Grund "+e.getCause()); e.getMessage(); e.printStackTrace(); } return ctx; } public static void main(String[] args) { TestClient test = new TestClient(); Context initial = test.login("200","j2ee"); try{ Object ref = null; if(initial!=null){ ref = initial.lookup("java:comp/env/ejb/Example"); }else{ System.out.println("InitialContext ist null!"); } ExampleHome home = (ExampleHome) PortableRemoteObject.narrow (ref, ExampleHome.class); Example example = home.create(); }catch(Exception e){ e.getMessage(); e.printStackTrace(); } }//end main() }//end class TestClient View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3885069#3885069 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3885069 |