【问题标题】:Nightmare with Jboss 7.1.1 FinalJboss 7.1.1 Final 的噩梦
【发布时间】:2013-12-26 12:21:27
【问题描述】:

我一直在为 JBossAS 和 EJB 苦苦挣扎,但无法解决最简单的问题。

我浏览了很多手册、教程、指南、博客,但找不到答案。

我编写了两个应用程序:server-side.jar 和 client-app。第一个应用程序由 maven 组装并部署在 Jboss 上。这里是:

RemoteCalculator.java:

package com.calculator;
import javax.ejb.Remote;

public interface RemoteCalculator {
    int add( int op1, int op2 );
}

CalculatorBean.java:

package com.calculator;
import javax.ejb.Remote;
import javax.ejb.Stateless;

@Stateless
@Remote(RemoteCalculator.class)
public class CalculatorBean implements RemoteCalculator {
    @Override
    public int add( int op1, int op2 ) {
        return op1 + op2;
    }
}

我已经组装了“ejb-remote-stateless-1.0-SNAPSHOT.jar”并将它放在Jboss上。 Satrted AS 并获得了“ejb-remote-stateless-1.0-SNAPSHOT.jar.deployed”。然后我创建了第二个简单的控制台应用程序 - 调用 CalculatorBean 的客户端:

import com.calculator.RemoteCalculator;
import org.jboss.sasl.JBossSaslProvider;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.security.Security;
import java.util.Hashtable;

public class EJBClient {
    private static void invokeStatelessBean() throws NamingException {
        RemoteCalculator statelessRemoteCalculator = lookupRemoteStatelessCalculator();
        int sum = statelessRemoteCalculator.add( 3, 4 );
        System.out.println( "sum = " + sum );
    }

private static RemoteCalculator lookupRemoteStatelessCalculator() throws NamingException {
    Security.addProvider( new JBossSaslProvider() );
    final Hashtable<String, String> p = new Hashtable<String, String>();
    p.put( Context.PROVIDER_URL, "remote://127.0.0.1:4447" );
    p.put( Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming" );
    p.put( Context.SECURITY_PRINCIPAL, "admin" );
    p.put( Context.SECURITY_CREDENTIALS, "jboss" );
    p.put( Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory" );
    final Context context = new InitialContext( p );

    return ( RemoteCalculator ) context
            .lookup( "java:/ejb-remote-stateless-1.0-SNAPSHOT/CalculatorBean!com.calculator.RemoteCalculator" );
}

public static void main( String... args ) {
    try {
        invokeStatelessBean();
    } catch ( NamingException e ) {
        e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
    }
}

}

我有这个例外:

ERROR: JBREM000200: Remote connection failed: javax.security.sasl.SaslException: 

Authentication failed: all available authentication mechanisms failed
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]

我求你说我怎么了?我做错了什么?请帮忙!!!

【问题讨论】:

    标签: jakarta-ee ejb jboss7.x


    【解决方案1】:

    我发现了错误!这是因为使用了错误的登录名/密码。我使用了管理员权限(管理)用户。

    我创建了“应用程序用户”,一切顺利!!!

    【讨论】:

    猜你喜欢
    • 2013-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多