Reputation: 1137
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
Upvotes: 2
Views: 16127
Reputation: 3637
First, read this article EJB invocations from a remote client using JNDI.
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
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:
A example implementation is in this file. Its a example aplication that connects to a EJB Services, the entire repo is like your concept:
Sorry for my bad english, cheers.
Upvotes: 3