JBoss Community

Client wont connect to remote interface of EJB

created by Juan Camilo Prada in EJB Development - View the full discussion

Hi guys, I'm really new to EJB and JEE in general.

So far im trying to make this EJB to work with no succes til now. I really dont know what is the problem. I'm following this book and I tried the examples and all works fine in a local server, but now, i deployed my beans to an external server, with a public IP, and I cant seem to get things work.

 

The Bean is this:

 

package server.ejb.gmail;
 
import javax.ejb.Stateless;
import com.google.gdata.data.appsforyourdomain.AppsForYourDomainException;
import com.google.gdata.client.appsforyourdomain.*;
import sample.appsforyourdomain.*;
 
@Stateless
public class GmailBean implements GmailBeanRemote, GmailBeanLocal {
    
    public void ConexionGmail()
    {
        
        AppsForYourDomainClient client = null;
        try {
            client = new AppsForYourDomainClient("user@domain.com",
                    "password", "domain.com");
            
            System.out.println("Hello world");
        } catch (Exception e) {
 
            System.out.println("Error conexion gmail:" + e.getMessage());
 
        }
    }
 
}

 

GmailBeanRemote looks like this:

 

 

package server.ejb.gmail;
import javax.ejb.Remote;
 
@Remote
public interface GmailBeanRemote {
     public void ConexionGmail();
}

 

GmailBeanLocal is exactly like the remote counterpart, the only difference is the tag which uses @Local instead of @Remote

 

The client Im using is this:

 

 

package client.usuario;
 
import java.util.Properties;
 
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
 
import server.ejb.gmail.GmailBeanRemote;
import server.ejb.usuario.UsuarioBeanRemote;
 
public class CrearUsuario {
 
   public static void main(String[] args) {
        try {
            Properties p = new Properties();
            p.put(Context.INITIAL_CONTEXT_FACTORY,
                    "org.jnp.interfaces.NamingContextFactory");
            
            p.put(Context.URL_PKG_PREFIXES,
                    "org.jboss.naming:org.jnp.interfaces");
            
            p.put(Context.PROVIDER_URL, "jnp://myhost:1099");
            
            Context ctx = new InitialContext(p);
            
            Object ref = ctx.lookup("GmailBean/remote");
            GmailBeanRemote ebr = (GmailBeanRemote) PortableRemoteObject.narrow(ref, GmailBeanRemote.class);
            ebr.ConexionGmail();
        } catch (NamingException e)
        {
            e.printStackTrace();
        }
    }
 
}

 

If there is any way the JNDI output is useful, here it is:

 

 

+- UserTransactionSessionFactory (proxy: $Proxy112 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
  +- UUIDKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.uuid.UUIDKeyGeneratorFactory)
  +- HiLoKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory)
  +- SecureDeploymentManager (class: org.jnp.interfaces.NamingContext)
  |   +- remote[link -> DeploymentManager] (class: javax.naming.LinkRef)
  +- SecureManagementView (class: org.jnp.interfaces.NamingContext)
  |   +- remote[link -> ManagementView] (class: javax.naming.LinkRef)
  +- DeploymentManager (class: org.jboss.aop.generatedproxies.AOPProxy$4)
  +- UsuarioBean (class: org.jnp.interfaces.NamingContext)
  |   +- local (class: Proxy for: server.ejb.usuario.UsuarioBeanLocal)
  |   +- local-server.ejb.usuario.UsuarioBeanLocal (class: Proxy for: server.ejb.usuario.UsuarioBeanLocal)
  |   +- remote-server.ejb.usuario.UsuarioBeanRemote (class: Proxy for: server.ejb.usuario.UsuarioBeanRemote)
  |   +- remote (class: Proxy for: server.ejb.usuario.UsuarioBeanRemote)
  +- XAConnectionFactory (class: org.hornetq.jms.client.HornetQConnectionFactory)
  +- ProfileService (class: org.jboss.aop.generatedproxies.AOPProxy$2)
  +- SecureProfileService (class: org.jnp.interfaces.NamingContext)
  |   +- remote[link -> ProfileService] (class: javax.naming.LinkRef)
  +- queue (class: org.jnp.interfaces.NamingContext)
  |   +- DLQ (class: org.hornetq.jms.client.HornetQQueue)
  |   +- ExpiryQueue (class: org.hornetq.jms.client.HornetQQueue)
  +- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
  +- ConnectionFactory (class: org.hornetq.jms.client.HornetQConnectionFactory)
  +- jmx (class: org.jnp.interfaces.NamingContext)
  |   +- invoker (class: org.jnp.interfaces.NamingContext)
  |   |   +- RMIAdaptor (class: javax.management.MBeanServerConnection)
  |   +- rmi (class: org.jnp.interfaces.NamingContext)
  |   |   +- RMIAdaptor (class: javax.management.MBeanServerConnection)
  +- ProxyFactory (class: org.jnp.interfaces.NamingContext)
  |   +- UsuarioUnico (class: org.jnp.interfaces.NamingContext)
  |   |   +- UsuarioBean (class: org.jnp.interfaces.NamingContext)
  |   |   |   +- UsuarioBean (class: org.jnp.interfaces.NamingContext)
  |   |   |   |   +- remote (proxy: $Proxy197 implements interface org.jboss.ejb3.proxy.impl.factory.session.SessionSpecProxyFactory,interface org.jboss.ejb3.proxy.impl.factory.session.SessionProxyFactory,interface org.jboss.ejb3.proxy.impl.factory.ProxyFactory)
  |   |   +- GmailBean (class: org.jnp.interfaces.NamingContext)
  |   |   |   +- GmailBean (class: org.jnp.interfaces.NamingContext)
  |   |   |   |   +- remote (proxy: $Proxy197 implements interface org.jboss.ejb3.proxy.impl.factory.session.SessionSpecProxyFactory,interface org.jboss.ejb3.proxy.impl.factory.session.SessionProxyFactory,interface org.jboss.ejb3.proxy.impl.factory.ProxyFactory)
  +- BeanValidatorFactories (class: org.jnp.interfaces.NamingContext)
  +- persistence.unit:unitName=#timerdb (class: org.hibernate.impl.SessionFactoryImpl)
  +- TomcatAuthenticators (class: java.util.Properties)
  +- GmailBean (class: org.jnp.interfaces.NamingContext)
  |   +- local (class: Proxy for: server.ejb.gmail.GmailBeanLocal)
  |   +- remote (class: Proxy for: server.ejb.gmail.GmailBeanRemote)
  |   +- local-server.ejb.gmail.GmailBeanLocal (class: Proxy for: server.ejb.gmail.GmailBeanLocal)
  |   +- remote-server.ejb.gmail.GmailBeanRemote (class: Proxy for: server.ejb.gmail.GmailBeanRemote)
  +- XAThroughputConnectionFactory (class: org.hornetq.jms.client.HornetQConnectionFactory)
  +- ManagementView (class: org.jboss.aop.generatedproxies.AOPProxy$3)
  +- ThroughputConnectionFactory (class: org.hornetq.jms.client.HornetQConnectionFactory)




 

I dont know what to do to make it work, so any help would be really appreciated.

 

Thanks

Reply to this message by going to Community

Start a new discussion in EJB Development at Community