Object obj = ctx.lookup("HelloHome");//这里有问题吧。我记得格式应该是
war
bean-name/remote
ear
war-name/bean-name/remote

解决方案 »

  1.   

    Cannot instantiate class: javax.naming.spi.InitialContextFactory 不能实例化上下文工厂???
    为什么会这样啊...
      

  2.   

    刚才的问题解决了,又出现了新问题...log4j:WARN No appenders could be found for logger (org.jnp.interfaces.NamingContext).
    log4j:WARN Please initialize the log4j system properly.
    Exception in thread "main" javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]]
    at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1414)
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:594)
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at HelloClient.main(HelloClient.java:20)
    Caused by: javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]
    at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:269)
    at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1385)
    ... 4 more
    Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]
    at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:243)
    ... 5 more
    Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(Unknown Source)
    at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.<init>(Unknown Source)
    at java.net.Socket.<init>(Unknown Source)
    at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:84)
    at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:77)
    at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:239)
    ... 5 more
      

  3.   

    [Root exception is java.net.ConnectException: Connection refused: connect]???----------