EJBCLIENT000025:没有可用的EJB接收器来处理[appName :, moduleName:EJB_projectTP1_Server,distinctName:]

时间:2019-11-09 12:15:04

标签: java eclipse ejb wildfly-8 illegalstateexception

我正在使用Wildfly 8.x,我不知道为什么会出现此错误。我尝试添加我的ejb-jar,但一无所获。

我也删除服务器,然后重新配置它,什么也没有。

我的EJB_Client> appClientModule>(默认包)中的Main是:

import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import org.jboss.ejb.client.EJBClientConfiguration;
import org.jboss.ejb.client.EJBClientContext;
import org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration;
import org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector;

import welcome.RemoteWelcome;
import welcome.WelcomeBean;

public class Main {
    public static void main(String[] args) throws NamingException {
        RemoteWelcome remoteWelcome = lookupRemoteWelcome();
        String message = remoteWelcome.sendWelcomeMessage("Salut");
    }

    /* (non-Java-doc)
     * @see java.lang.Object#Object()
     */
    public Main() {
        super();
    }

    public static RemoteWelcome lookupRemoteWelcome() throws NamingException {
        Properties properties = new Properties();
        properties.put("Options.SSL_ENABLED", "false");
        properties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
        properties.put("remote.connections", "default");
        properties.put("remote.connection.default.host", "localhost");
        properties.put("remote.connection.default.port", "8080");
        properties.put("remote.connection.default.username", "application"); //Soit admin soit application (idem pour les mot des passe)
        properties.put("remote.connection.default.password", "application");

        EJBClientConfiguration ejbConfig = new PropertiesBasedEJBClientConfiguration(properties);
        ConfigBasedEJBClientContextSelector configSelector = new ConfigBasedEJBClientContextSelector(ejbConfig);
        EJBClientContext.setSelector(configSelector);
        final Context context = new InitialContext(properties);

        final String appName = "";
        // This is the module name of the deployed EJBs on the server. This is typically the jar name of the
        // EJB deployment, without the .jar suffix, but can be overridden via the ejb-jar.xml
        // In this example, we have deployed the EJBs in a jboss-as-ejb-remote-app.jar, so the module name is
        // jboss-as-ejb-remote-app
        final String moduleName = "EJB_Project_TP1_Client";
        // AS7 allows each deployment to have an (optional) distinct name. We haven't specified a distinct name for
        // our EJB deployment, so this is an empty string
        final String distinctName = "EJB_projectTP1_Server";
        // The EJB name which by default is the simple class name of the bean implementation class
        final String beanName = WelcomeBean.class.getSimpleName();
        // the remote view fully qualified class name
        final String viewClassName = RemoteWelcome.class.getName();
        // let's do the lookup

        System.out.println("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName);
        return (RemoteWelcome) context.lookup("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName);

        //return (RemoteWelcome) context.lookup("ejb:/EJB_Project_TP1_Client/EJB_projectTP1_Server/WelcomeBean!welcome.RemoteWelcome");         
    }

}

在EJB_projectTP1_Server中,我有:

我的远程界面

package welcome;

import javax.ejb.Remote;

@Remote
public interface RemoteWelcome {
    public String sendWelcomeMessage(String message);

}

还有我的欢迎豆

package welcome;

import javax.ejb.LocalBean;
import javax.ejb.Stateless;

/**
 * Session Bean implementation class WelcomeBean
 */
@Stateless
@LocalBean
public class WelcomeBean implements RemoteWelcome {

    /**
     * Default constructor. 
     */
    public WelcomeBean() {
        // TODO Auto-generated constructor stub
    }

    public String sendWelcomeMessage(String message){
        //Send the message
        String messageToSend = "Bienvenue " + message;
        System.out.println(messageToSend);
        return messageToSend;
    }

}

我的ejb-jar.xml是:

<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar version="3.2" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/ejb-jar_3_2.xsd">
  <display-name>EJB_projectTP1</display-name>
 </ejb-jar>

有人可以帮我吗?我的老师也不明白。

0 个答案:

没有答案