This content has been marked as final.
Show 2 replies
-
1. Re: Getting Exception while trying to access a Stateless EJB
jaikiran Dec 11, 2006 5:35 AM (in response to dvuday)Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jboss.naming.HttpNamingContextFactory");
props.put(Context.PROVIDER_URL,"jnp://localhost:8080");
Context ctx = new InitialContext(props);
This should be:Properties props = new Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory"); props.put(Context.PROVIDER_URL,"jnp://localhost:1099"); Context ctx = new InitialContext(props);
-
2. Re: Getting Exception while trying to access a Stateless EJB
dvuday Dec 12, 2006 12:01 PM (in response to dvuday)"jaikiran" wrote:
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jboss.naming.HttpNamingContextFactory");
props.put(Context.PROVIDER_URL,"jnp://localhost:8080");
Context ctx = new InitialContext(props);
This should be:Properties props = new Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory"); props.put(Context.PROVIDER_URL,"jnp://localhost:1099"); Context ctx = new InitialContext(props);
Thank you very much for quick response jaikiran. I tried to execute the client program by the changes you mentioned above. But still getting Exception. I have included the log4j.jar from <JBOSS_HOME>\client\ both in the build path of the project and in the jboss configuration.(Jboss is configured in eclipse).
Can you please help me to come out of this exception...
--------------------------------------------------------------------------------------------------------------------
The ejb-jar.xml file is
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xs1="http://www.w3.org/2001/XMLSchema-instance" xs1:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd" version="2.1">
<enterprise-beans>
<ejb-name>HelloHome</ejb-name>
examples.ejb21.HelloHome
examples.ejb21.Hello
<local-home>examples.ejb21.HelloLocalHome</local-home>
examples.ejb21.HelloLocal
<ejb-class>examples.ejb21.HelloBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</enterprise-beans>
</ejb-jar>
--------------------------------------------------------------------------------------------------------------------
Exception is
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:1399)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:579)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
at javax.naming.InitialContext.lookup(Unknown Source)
at client.HelloClient.main(HelloClient.java:37)
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(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.(Unknown Source)
at java.net.Socket.(Unknown Source)
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
Thanks in advance
Uday