log4j:WARN No appenders could be found for logger
(org.jnp.interfaces.NamingContext).
log4j:WARN Please initialize the log4j system properly.
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:1399)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:579)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at _1108.TestEJB.main(TestEJB.java:14)
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:254)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1370)
... 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:228)
... 5 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
at java.net.Socket.connect(Socket.java:452)
at java.net.Socket.connect(Socket.java:402)
at java.net.Socket.<init>(Socket.java:309)
at java.net.Socket.<init>(Socket.java:211)
at org.jnp.interfaces.TimedSocketFactory.createSocket
(TimedSocketFactory.java:69)
at org.jnp.interfaces.TimedSocketFactory.createSocket
(TimedSocketFactory.java:62)
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:224)
... 5 more
下面是我的EJB测试代码:
import javax.naming.*;
import javax.rmi.PortableRemoteObject;
import javax.naming.InitialContext;
import java.util.Hashtable;
public class TestEJB {
public static void main(String[] args) {
try{
Context ctx=getInitialContext();
Object ref=ctx.lookup("ConvertCharacter";
ConvertCharacterHome home=
(ConvertCharacterHome)PortableRemoteObject.narrow(
ref,ConvertCharacterHome.class);
ConvertCharacter user=home.create();
System.out.println(user.HelloEcho("So easy!");
}
catch(Exception e) {
e.printStackTrace();
}
}
private static Context getInitialContext() throws NamingException {
Hashtable environment = new Hashtable();
environment.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory";
environment.put(Context.URL_PKG_PREFIXES,
"org.jboss.namingrg.jnp.interfaces";
environment.put(Context.PROVIDER_URL, "jnp://localhost:1099";
return new InitialContext(environment);
}
}
请问这到底是什么原因,如何进行调试,希望各位大侠多多帮忙,我用的是jbuilder2005开发工具,另外还需要添加什么*.jar文件吗?jboss4.03配置到jbuilder后,别的什么也没有配置,是否跟这个有关,谢谢!!
--转自