2

i have a problem with connecting standalone desktop client with ejb on Jboss AS. So the question is how to remote call for EJB class from standalone client propably in java SE with swing windows ? and on the other side, is there something wrong with my concept ?

img link: https://i.sstatic.net/4wFZH.jpg

3
  • Consume the EJB methods as Web Services. Commented May 6, 2013 at 23:13
  • While webservices are sexy, RMI is still useful. I found EJB 3 reasonably trivial to consume from a client. What specific problems are you having? Commented May 6, 2013 at 23:36
  • Your architecture diagram looks fairly standard, You will need to investigate your network architecture as well, non http traffic will often have problems with network permissions. Commented May 6, 2013 at 23:37

1 Answer 1

3

First, read this article EJB invocations from a remote client using JNDI.

  1. You need a file called 'jboss-ejb-client.properties' in your classpath, the file needs the basic config to connecto to your jboss server, for example:

    remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false remote.connections=default remote.connection.default.host=localhost remote.connection.default.port = 4447 remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false

  2. Create the EJB Remote proxy

    Properties p = new Properties(); p.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); final Context context = new InitialContext(p); final String appName = "YOUR APP NAME"; final String moduleName = "YOUR EJB MODULE NAME"; final String distinctName = "DISTINCT NAME"; final String beanName = "Your bean name"; final String viewClassName = ClienteDAORemote.class.getName(); String path = "ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName; Object o = context.lookup(path); return (RemoteBean) o; //Cast to your remote interface 

You need:

  1. A EJB with a remote interface
  2. A copy of the interface in your standalone client
  3. My properties files is for local and unsecured connections.

A example implementation is in this file. Its a example aplication that connects to a EJB Services, the entire repo is like your concept:

  1. A web application with JSF + PrimeFaces
  2. A EJB Bussiness Tier
  3. JPA with hibernate
  4. A standalone client
  5. EJB Web Services

Sorry for my bad english, cheers.

Sign up to request clarification or add additional context in comments.

3 Comments

Nice answer, but will i be able to run this standalone client outside of jboss server like a desktop application ? Second thing is about entities, ive got about 5, do i have to make beans for each one and one for managing database or can i have all in one bean ?
Yes, in the Repository you can see a client, I only test the client in the same machine, but if you provide a password and enable the jboss to listen from outside, then you should'n have problems. Second, i recomend you to have 5 entities and a bean for each entity, like a DAO, but you can have all methods and all logic in one bean. Cheers
Hi I'm experiencing an issue relating to this and I posted a question. Would you please have a look here? stackoverflow.com/questions/70353500/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.