-
1. Re: Remote JNDI Lookup with JBOSS AS -7.1.0.Beta1
suikast42 Nov 23, 2011 9:33 AM (in response to suikast42)I forgot to say,
everytime if i try to make a lookup I get this exception:
2011-11-23 15:31:41,113 ERROR SendMessageJNDI$ServiceLokup: Error:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at SendMessageJNDI$ServiceLokup.doLookup(SendMessageJNDI.java:118)
at SendMessageJNDI.initConnection(SendMessageJNDI.java:51)
at SendMessageJNDI.main(SendMessageJNDI.java:35)
-
2. Re: Remote JNDI Lookup with JBOSS AS -7.1.0.Beta1
jaikiran Nov 23, 2011 9:52 AM (in response to suikast42)Sueleyman Vurucu wrote:
The second problem is when I start AS -7.1.0.Beta1 with JBoss tools from eclipse I get an a lot of errors.
15:28:06,861 ERROR [org.jboss.remoting.remote] (Remoting "ws048059:MANAGEMENT" read-1) JBREM000200: Remote connection failed: java.io.IOException: JBREM000201: Received invalid message on Remoting connection 00b9e9a3 to /127.0.0.1:2593
It probably is because of a mismatch in the client side remoting, sasl library versions with the server side ones. When do you see those errors?
everytime if i try to make a lookup I get this exception:
2011-11-23 15:31:41,113 ERROR SendMessageJNDI$ServiceLokup: Error:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at SendMessageJNDI$ServiceLokup.doLookup(SendMessageJNDI.java:118)
at SendMessageJNDI.initConnection(SendMessageJNDI.java:51)
at SendMessageJNDI.main(SendMessageJNDI.java:35)
My guess is that you aren't using the ejb: namespace for the JNDI name or you haven't passed the
Context.URL_PKG_PREFIXES (with org.jboss.ejb.client.naming as the value) to the intial context constructor.
-
3. Re: Remote JNDI Lookup with JBOSS AS -7.1.0.Beta1
ylemoigne Nov 23, 2011 10:31 AM (in response to suikast42)About
2011-11-23 15:31:41,113 ERROR SendMessageJNDI$ServiceLokup: Error:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at SendMessageJNDI$ServiceLokup.doLookup(SendMessageJNDI.java:118)
at SendMessageJNDI.initConnection(SendMessageJNDI.java:51)
at SendMessageJNDI.main(SendMessageJNDI.java:35)
Does your url start with "java:" ? I was having the same error until I replace it to "ejb:"
I have a similar problem now when I call an EJB, on the server side, I have :
JBREM000200: Remote connection failed: java.io.IOException: JBREM000201: Received invalid message on Remoting connection 46f02f31 to /127.0.0.1:52771
And on client side :
INFO: JBoss Remoting version 3.2.0.CR2
nov. 23, 2011 4:30:49 PM org.jboss.remoting3.remote.RemoteConnection handleException
ERROR: JBREM000200: Remote connection failed: java.io.IOException: JBREM000202: Abrupt close on Remoting connection 4cac1566 to localhost/127.0.0.1:4447
nov. 23, 2011 4:30:49 PM org.jboss.ejb.client.ConfigBasedEJBClientContextSelector createConnections
ERROR: Could not create connection for connection named default
java.lang.RuntimeException: java.io.IOException: JBREM000202: Abrupt close on Remoting connection 4cac1566 to localhost/127.0.0.1:4447
at org.jboss.ejb.client.remoting.IoFutureHelper.get(IoFutureHelper.java:91)
at org.jboss.ejb.client.ConfigBasedEJBClientContextSelector.createConnection(ConfigBasedEJBClientContextSelector.java:276)
If someone has a solution...
-
4. Re: Remote JNDI Lookup with JBOSS AS -7.1.0.Beta1
ylemoigne Nov 23, 2011 10:39 AM (in response to ylemoigne)Problem solved on my side : jar version mismatch
jboss-ejb-client on maven => Remoting version 3.2.0.CR2
jboss 7.1 Beta1 use 3.2.0.CR3.
Force version CR3 on client solved the problem.
-
5. Re: Remote JNDI Lookup with JBOSS AS -7.1.0.Beta1
jaikiran Nov 23, 2011 10:45 AM (in response to ylemoigne)Yeah, thought so. By the way, I think this won't be an issue going forward since I believe those remoting and sasl jars are expected to maintain backward compatibility. I'll check though.
Yann Le Moigne wrote:
jboss-ejb-client on maven => Remoting version 3.2.0.CR2
jboss 7.1 Beta1 use 3.2.0.CR3.
Force version CR3 on client solved the problem.
That's correct. Also make sure your sasl jar version on the client side is 1.0.0.Beta6 since that jar was upgraded on the server side too.
-
6. Re: Remote JNDI Lookup with JBOSS AS -7.1.0.Beta1
jaikiran Nov 23, 2011 10:48 AM (in response to ylemoigne)Yann Le Moigne wrote:
And on client side :
INFO: JBoss Remoting version 3.2.0.CR2
nov. 23, 2011 4:30:49 PM org.jboss.remoting3.remote.RemoteConnection handleException
ERROR: JBREM000200: Remote connection failed: java.io.IOException: JBREM000202: Abrupt close on Remoting connection 4cac1566 to localhost/127.0.0.1:4447
nov. 23, 2011 4:30:49 PM org.jboss.ejb.client.ConfigBasedEJBClientContextSelector createConnections
ERROR: Could not create connection for connection named default
java.lang.RuntimeException: java.io.IOException: JBREM000202: Abrupt close on Remoting connection 4cac1566 to localhost/127.0.0.1:4447
at org.jboss.ejb.client.remoting.IoFutureHelper.get(IoFutureHelper.java:91)
at org.jboss.ejb.client.ConfigBasedEJBClientContextSelector.createConnection(ConfigBasedEJBClientContextSelector.java:276)
If someone has a solution...
Yeah, upgrade the sasl library on the client side to 1.0.0.Beta6.
-
7. Re: Remote JNDI Lookup with JBOSS AS -7.1.0.Beta1
jaikiran Nov 23, 2011 10:52 AM (in response to jaikiran)Here's the pom.xml which I use for that quickstart example of the client https://github.com/jaikiran/quickstart/blob/master/ejb-remote/client/pom.xml
-
8. Re: Remote JNDI Lookup with JBOSS AS -7.1.0.Beta1
suikast42 Nov 23, 2011 2:26 PM (in response to jaikiran)Hi jaikiran ,
I see in your pom.xml 7.0.2-SNAPSHOT as parent decleration and I#m confused??
For recontruction my advance,
1. Download JBoss AS from http://www.jboss.org/jbossas/downloads/
2. Configure this in Eclipse as Serverruntime (Error occures if I want startr the server ). When I start the server outside of Eclipse then is everything fine. I assume that the error occurs in combination with jboss tools.
3. I create a client project in Eclipse an set the serverruntime as dependency. ( I don't use maven ). If I try to make a lookup then I get the error javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet
I worked so with JBoss 6 and JBoss 5.
-
9. Re: Remote JNDI Lookup with JBOSS AS -7.1.0.Beta1
suikast42 Nov 23, 2011 3:15 PM (in response to suikast42)I looked for the library it says
20:34:19,859 INFO [org.jboss.remoting] JBoss Remoting version 3.2.0.CR3
-
10. Re: Remote JNDI Lookup with JBOSS AS -7.1.0.Beta1
suikast42 Nov 24, 2011 2:51 AM (in response to suikast42)jaikiran wrote:
My guess is that you aren't using the ejb: namespace for the JNDI name or you haven't passed the
Context.URL_PKG_PREFIXES (with org.jboss.ejb.client.naming as the value) to the intial context constructor.
I think thta's true but can't locate the error. I guess there a lib that fail in my classpath. I try di the lookup in this way.
import java.io.File;
import java.util.Hashtable;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.apache.log4j.Logger;
public class MainTest {
public static void main(String[] args){
new ServiceLokup<Object>().doLookup("test");
new ServiceLokup<Object>().doLookupOld("test");
}
public static class ServiceLokup<T> {
private Logger lLog = Logger.getLogger(ServiceLokup.class);
private final String lIP = "localhost";
private final String lPort = "1099";
/**
* The new JBoss 7.1 way to do remote lookup ??
*/
public T doLookup(String pServiceName){
final Hashtable<String, String> jndiProperties = new Hashtable<String, String>();
File lFile = new File("jboss-ejb-client.properties");
lLog.info(lFile.getAbsolutePath());
jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
try {
final Context context = new InitialContext(jndiProperties);
context.lookup(pServiceName);
} catch (NamingException e) {
lLog.error("Error: ", e);
}
return null;
}
/**
* Works perfect with JBoss 5 or 6 but failed on JBoss 7.1
*/
@SuppressWarnings("unchecked")
public T doLookupOld(String pServiceName){
InitialContext context;
Properties properties = new Properties();
properties.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
properties.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
properties.put("java.naming.provider.url", "jnp://" + lIP + ":" + lPort);
try {
context = new InitialContext(properties);
return (T)context.lookup(pServiceName);
} catch (NamingException e) {
lLog.error("Error: ", e);
}
return null;
}
}
}
Furthermore I have a jboss-ejb-client.properties in my sorce folder bind the libs in my classpath from JBOSS AS 7.1 like jaikiran describes in https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI
-
11. Re: Remote JNDI Lookup with JBOSS AS -7.1.0.Beta1
suikast42 Nov 24, 2011 2:56 AM (in response to suikast42)And here is the Full stacktrace :
011-11-24 08:42:32,626 INFO MainTest$ServiceLokup: F:\IDE\WORKSPACEs\JAVAEE_TESTS_JB7\CONTROLLER_TEST_CLIENT\jboss-ejb-client.properties
2011-11-24 08:42:32,626 ERROR MainTest$ServiceLokup: Error:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at MainTest$ServiceLokup.doLookup(MainTest.java:35)
at MainTest.main(MainTest.java:14)
2011-11-24 08:42:32,642 ERROR MainTest$ServiceLokup: Error:
javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:197)
at MainTest$ServiceLokup.doLookupOld(MainTest.java:51)
at MainTest.main(MainTest.java:15)
Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:46)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
... 5 more
-
12. Re: Remote JNDI Lookup with JBOSS AS -7.1.0.Beta1
morphy Nov 24, 2011 3:14 AM (in response to suikast42)Hi Sueleyman,
i succeded in going over this problem fixing the pom:
i've added the dependency import:
<dependencyManagement> <dependencies> <dependency> <groupId>org.jboss.spec</groupId> <artifactId>jboss-javaee-web-6.0</artifactId> <version>2.0.0.Final</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
with this element the jboss-ejb-client has been recovered and the initial factory jndi property were no more required
EDIT:
is this F:\IDE\WORKSPACEs\JAVAEE_TESTS_JB7\CONTROLLER_TEST_CLIENT\jboss-ejb-client.properties in your classpath? if your using maven (you are using a pom so i expect your are using maven), why don't you place that file in src/main/resources ?
EDIT2:
Unfortunately, no maven
ops... mmm...
EDIT3:
This error indicates that you are looking up some object whose JNDI name doesn't start with ejb:
What does your JNDI name look like?
-
13. Re: Remote JNDI Lookup with JBOSS AS -7.1.0.Beta1
jaikiran Nov 24, 2011 3:12 AM (in response to morphy)011-11-24 08:42:32,626 INFO MainTest$ServiceLokup: F:\IDE\WORKSPACEs\JAVAEE_TESTS_JB7\CONTROLLER_TEST_CLIENT\jboss-ejb-client.properties
2011-11-24 08:42:32,626 ERROR MainTest$ServiceLokup: Error:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at MainTest$ServiceLokup.doLookup(MainTest.java:35)
at MainTest.main(MainTest.java:14)
This error indicates that you are looking up some object whose JNDI name doesn't start with ejb:
What does your JNDI name look like?
-
14. Re: Remote JNDI Lookup with JBOSS AS -7.1.0.Beta1
suikast42 Nov 24, 2011 3:52 AM (in response to jaikiran)jaikiran pai schrieb:
This error indicates that you are looking up some object whose JNDI name doesn't start with ejb:
What does your JNDI name look like?
And how I can make a lookup for a non ejb resource like a jms topic for example ??
But is the same when I do a lookup for:
context
.lookup("ejb:/jboss-as-ejb-remote-app//CalculatorBean!org.jboss.as.quickstarts.ejb.remote.stateless.RemoteCalculator");
I think my jboss-ejb-client.properties not found. Where shuold I place this for a non maven project ?