Results 1 to 5 of 5
  1. #1
    JavaDever is offline Member
    Join Date
    Aug 2013
    Posts
    2
    Rep Power
    0

    Default How can I access an ejb in another Glassfish server?

    For test purpose I have created two projects.

    1. Project: HelloServer with the following files

    1. File: HelloService.java

    Java Code:
    		package org.testejb;
    
    		import javax.ejb.Remote;
    
    		@Remote
    		public interface HelloService {
    			String sayHello(String name);
    		}
    2. File: HelloServiceImpl.java

    Java Code:
    		package org.testejb;
    
    		import javax.ejb.LocalBean;
    		import javax.ejb.Stateless;
    		import javax.inject.Named;
    
    		@Stateless
    		@Named
    		@LocalBean
    		public class HelloServiceImpl implements HelloService{
    
    			@Override
    			public String sayHello(String name) {
    				return "Hello " + name;
    			}
    
    		}
    2. Project: HelloClient

    1. File: HelloService.java

    Java Code:
    		package org.testejb;
    
    		import javax.ejb.Remote;
    
    		@Remote
    		public interface HelloService {
    			String sayHello(String name);
    		}
    2. File: TestHelloService.java
    Java Code:
    		package org.testejb.client;
    
    		import javax.ejb.EJB;
    		import javax.faces.bean.ManagedBean;
    
    		import org.testejb.HelloService;
    
    		@ManagedBean
    		public class TestHelloService {
    	
    			@EJB
    			HelloService service;
    	
    			public String sayHello() {
    				return service.sayHello("Test User");
    			}
    		}
    3. File: sayHello.xhtml

    XML Code:
    		<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    		    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    		<html xmlns="http://www.w3.org/1999/xhtml"
    			xmlns:ui="http://java.sun.com/jsf/facelets"
    			xmlns:h="http://java.sun.com/jsf/html"
    			xmlns:f="http://java.sun.com/jsf/core">
    
    			<h:body>
    				<h1>Output: #{testHelloService.sayHello()}</h1>
    			</h:body>
    		</html>
    If both projects are running in the same glassfish instances then it works fine. The output of sayHello.xhtml is "Hello Test User".
    And now my question:

    I have two glassfish instance I1 & I2. I1 running on my localhost:8080 and I2 in a vm with the url 192.168.100.199:8080.
    In I1 is deployed HelloClient.war and in I2 is deployed HelloServer.

    What is the configuration of the @EJB annotaion in the TestHelloService class, if i want the call HelloServiceImpl.sayHello() method in glassfish instance I2?

    I tried something but nothing did work.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,184
    Rep Power
    19

    Default Re: How can I access an ejb in another Glassfish server?

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    JavaDever is offline Member
    Join Date
    Aug 2013
    Posts
    2
    Rep Power
    0

    Default Re: How can I access an ejb in another Glassfish server?

    Quote Originally Posted by DarrylBurke View Post
    I know, I htnik it is better to ask in more than one forum. Is this a problem?

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,184
    Rep Power
    19

    Default Re: How can I access an ejb in another Glassfish server?

    Quote Originally Posted by JavaDever View Post
    Is this a problem?
    Did I say it was a problem?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,746
    Rep Power
    5

    Default Re: How can I access an ejb in another Glassfish server?

    Quote Originally Posted by JavaDever View Post
    I know, I htnik it is better to ask in more than one forum.
    For you, but not for the people who take the time to answer. When you crosspost, post links to your other posts so people can follow them and see if the question is already answered somewhere else, to prevent wasting time doing what has already been done.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Security on Sun GlassFish Enterprise Server v2.1
    By srinathscion in forum Advanced Java
    Replies: 0
    Last Post: 08-01-2011, 11:50 AM
  2. GlassFish Server 3 problems
    By gedas in forum New To Java
    Replies: 4
    Last Post: 06-28-2011, 02:51 PM
  3. GlassFish vs Sun java Application Server
    By vahini in forum New To Java
    Replies: 1
    Last Post: 06-17-2011, 10:25 AM
  4. glassfish server its urgent
    By hemant_metalia in forum NetBeans
    Replies: 0
    Last Post: 02-22-2011, 11:37 AM
  5. About Application Server - Glassfish
    By sathishscjp in forum Advanced Java
    Replies: 1
    Last Post: 07-30-2009, 03:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •