查找远程服务器上的EJB时出现javax.naming.CommunicationException

时间:2015-03-21 14:38:55

标签: java java-ee jboss ejb

所以当我尝试查找部署在服务器中的EJB时,我有这个错误。

编辑:Oups我没有看到我把错误的客户踪迹。这是好的。

     mars 22, 2015 10:39:23 AM org.jboss.ejb.client.remoting.VersionReceiver handleMessage
INFO: EJBCLIENT000017: Received server version 2 and marshalling strategies [river]
mars 22, 2015 10:39:23 AM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
INFO: EJBCLIENT000013: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@558df7bb, receiver=Remoting connection EJB receiver [connection=Remoting connection <38f0bdb>,channel=jboss.ejb,nodename=pc-jp]} on channel Channel ID f48e6c67 (outbound) of Remoting connection 4dcd1894 to /192.168.0.15:8080
javax.naming.NameNotFoundException: ejb:AnalyseExcelServeur/DataBaseServiceImpl!serveur.database.DataBaseService -- service jboss.naming.context.java.jboss.exported.ejb:AnalyseExcelServeur."DataBaseServiceImpl!serveur.database.DataBaseService"
    at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:104)
    at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:202)
    at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:179)
    at org.jboss.naming.remote.protocol.v1.Protocol$1.handleServerMessage(Protocol.java:127)
    at org.jboss.naming.remote.protocol.v1.RemoteNamingServerV1$MessageReciever$1.run(RemoteNamingServerV1.java:73)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

这是EJB:

package serveur.database;

import java.util.List;

import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.transaction.Transactional;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

@Stateless
@Remote(DataBaseService.class)
public class DataBaseServiceImpl extends SessionDB implements DataBaseService
{

    @Override
    @Transactional
    public void addEntity(Object entity, Class<?> classEntity)
    {
        initSession();
        _session.save(entity);
        commit();

    }

    @Override
    public void removeEntity(Object entity, Class<?> classEntity)
    {
        initSession();
        _session.delete(entity);
        commit();
    }

    @Override
    public Object findEntityById(Class<?> classEntity, long id)
    {
        initSession();
        Criteria criteria = _session.createCriteria(classEntity).add(Restrictions.eq("id", id));
        Object result = criteria.uniqueResult();
        return result;
    }

    @Override
    public List<?> findAllEntitiesByClass(Class<?> classEntity)
    {
        initSession();
        Criteria criteria = _session.createCriteria(classEntity);
        List<?> result = criteria.list();
        return result;
    }

    @Override
    public Object findEntityByDateAndSousCat(Class<?> classEntity, Long date, String sousCat)
    {
        initSession();
        Criteria criteria = _session.createCriteria(classEntity).add(Restrictions.eq("date", date))
                .createCriteria("sousCategorie").add(Restrictions.eq("key", sousCat));
        Object result = criteria.uniqueResult();
        return result;
    }

    @Override
    public Object findEntityByKey(Class<?> classEntity, String key)
    {
        initSession();
        Criteria criteria = _session.createCriteria(classEntity).add(Restrictions.eq("key", key));
        Object result = criteria.uniqueResult();
        return result;
    }
}

以下是尝试查找的客户端:

 /**
     * @return
     * @throws NamingException
     */
    private DataBaseService lookupRemoteStatelessDataBase() throws NamingException
    {

        Properties jndiProps = new Properties();
        jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
        jndiProps.put(Context.PROVIDER_URL, "http-remoting://192.168.0.15:8080");
        // jndiProps.put(Context.SECURITY_PRINCIPAL, "testuser");
        // jndiProps.put(Context.SECURITY_CREDENTIALS, "testpassword");
        jndiProps.put("jboss.naming.client.ejb.context", true);
        Context ctx = new InitialContext(jndiProps);

        final String appName = "AnalyseExcelServeur";
        // 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
        final String moduleName = "";
        // 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 = "";
        // The EJB name which by default is the simple class name of the bean
        // implementation class
        final String beanName = "DataBaseServiceImpl";
        // the remote view fully qualified class name
        final String viewClassName = "serveur.database.DataBaseService";
        // let's do the lookup
        // return (DataBaseService) ctx.lookup("ejb3/Hello/remote");
        String jndiName = "ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!"
                + viewClassName;
//TEST
        jndiName = "ejb:AnalyseExcelServeur/DataBaseServiceImpl!serveur.database.DataBaseService";
        return (DataBaseService) ctx.lookup(jndiName);

    }

上下文的init工作并且能够到达服务器(服务器端有跟踪)

但我认为字段jndiName不正确,但我无法确定正确的URL是什么。

请帮忙!! ;)

0 个答案:

没有答案