(Resolvido)lookup ejb no jboss 7.1 de um client jse fora do server

Bom dia,

Estou a dias tentando efetuar um lookup de um sistema jse para um ejb no jboss 7.1 sem sucesso, eu adicionei um usuario pelo add-user.bath, e me loguei no console do jboss com sucesso, porém ao executar o codigo abaixo:


import javax.naming.NamingException;

import org.myapp.ejb.Foo;

public class ClientEJB {
	
	
	void doBeanLookup() throws NamingException {
		 
		 Properties jndiProps = new Properties();
		jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
		jndiProps.put(Context.PROVIDER_URL,"remote://127.0.0.1:4447");
		// username
		jndiProps.put(Context.SECURITY_PRINCIPAL, "ribclauport");
//		// password
		jndiProps.put(Context.SECURITY_CREDENTIALS, "java");
		// This is an important property to set if you want to do EJB invocations via the remote-naming project
		jndiProps.put("jboss.naming.client.ejb.context", true);
		// create a context passing these properties
		Context ctx = new InitialContext(jndiProps);
		// lookup the bean     Foo
		Foo beanRemoteInterface= (Foo) ctx.lookup("myapp/myejbmodule/FooBean!org.myapp.ejb.Foo");
		String bar = beanRemoteInterface.sayBar();
		System.out.println("Remote Foo bean returned " + bar);
		 
		}
	public static void main(String[] args) throws NamingException {
		ClientEJB cliente = new ClientEJB();
		cliente.doBeanLookup();
	}
}


obtenho o erro seguinte:

Mai 18, 2014 3:53:29 PM org.xnio.Xnio <clinit>
INFO: XNIO Version 3.0.3.GA
Mai 18, 2014 3:53:29 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.0.3.GA
Mai 18, 2014 3:53:29 PM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 3.2.3.GA
Mai 18, 2014 3:53:29 PM org.jboss.remoting3.remote.RemoteConnection handleException
ERROR: JBREM000200: Remote connection failed: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed
Exception in thread "main" javax.naming.NamingException: Failed to create remoting connection [Root exception is java.lang.RuntimeException: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed]
	at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:36)
	at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:121)
	at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
	at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
	at javax.naming.InitialContext.init(Unknown Source)
	at javax.naming.InitialContext.<init>(Unknown Source)
	at myclientjse.ClientEJB.doBeanLookup(ClientEJB.java:26)
	at myclientjse.ClientEJB.main(ClientEJB.java:35)
Caused by: java.lang.RuntimeException: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed
	at org.jboss.naming.remote.protocol.IoFutureHelper.get(IoFutureHelper.java:87)
	at org.jboss.naming.remote.client.NamingStoreCache.getRemoteNamingStore(NamingStoreCache.java:56)
	at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateCachedNamingStore(InitialContextFactory.java:166)
	at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateNamingStore(InitialContextFactory.java:139)
	at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:104)
	... 6 more
Caused by: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed
	at org.jboss.remoting3.remote.ClientConnectionOpenListener$Capabilities.handleEvent(ClientConnectionOpenListener.java:365)
	at org.jboss.remoting3.remote.ClientConnectionOpenListener$Capabilities.handleEvent(ClientConnectionOpenListener.java:214)
	at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:72)
	at org.xnio.channels.TranslatingSuspendableChannel.handleReadable(TranslatingSuspendableChannel.java:189)
	at org.xnio.channels.TranslatingSuspendableChannel$1.handleEvent(TranslatingSuspendableChannel.java:103)
	at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:72)
	at org.xnio.nio.NioHandle.run(NioHandle.java:90)
	at org.xnio.nio.WorkerThread.run(WorkerThread.java:184)
	at ...asynchronous invocation...(Unknown Source)
	at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:270)
	at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:251)
	at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:349)
	at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:333)
	at org.jboss.naming.remote.client.EndpointCache$EndpointWrapper.connect(EndpointCache.java:105)
	at org.jboss.naming.remote.client.NamingStoreCache.getRemoteNamingStore(NamingStoreCache.java:55)
	... 9 more

ja coloquei também no classpath o properties jboss-ejb-client.properties com o conteúdo

endpoint.name=client-endpoint
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
 
remote.connections=default
 
remote.connection.default.host=10.20.30.40
remote.connection.default.port = 4447
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
 
remote.connection.default.username=ribclauport
remote.connection.default.password=java

Mas não consegui ainda passar deste erro, o ejb eu injetei com @EJB normalmente no projeto WEB, mas de um Client JSE não consigo…

Qualquer ajuda é bem vinda.

Eu havia adicionado um Management User pelo add-user.bat, mas eu
precisava adicionar um Application User, eu não sabia que o Management User não era usado para acessar a app…

enfim adicionei o usuario em ambos os níveis e funcionou.

Obrigado.

Muito obrigado, não estava conseguindo também fazer lookup pois não sabia que o usuário tinha que ser do tipo “Application User”

Ops!, que bom que ajudou.

Obrigado me ajudou bastante