1 Reply Latest reply on Dec 4, 2006 9:28 PM by Kevin Fowlks

    Swing application using EJB3

    Ilan Meyrowitsch Newbie

      I need an example how to send and recieve transaction between an application server and a swing gui application. (Not using a web server).

      Please help with a simple example how swing and EJB3 fit together.

        • 1. Re: Swing application using EJB3
          Kevin Fowlks Newbie

          You still need an application server, the tomcat web server can be disabled if you'd like in the default server configuration by deleting the tomcat sar directory. You'll need to build your ejb jar and deploy it as normal. Then connect to it using the following client application example.

          package com.example.web.Test.client;
          import javax.naming.Context;
          import java.util.*;
          import com.example.web.jList.ejb.*;
          import com.example.web.jList.ejb.entity.*;
          public class TestClient
           public static Context getInitialContext() throws javax.naming.NamingException
           return new javax.naming.InitialContext();
           * @param args
           public static void main(String[] args)
           Context jndiContext = getInitialContext();
           jndiContext.addToEnvironment("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
           jndiContext.addToEnvironment("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
           /* You'll need to change this part to obtain your deployed SessionBean */
           LoginService loginService = (LoginService) jndiContext.lookup("LoginBean/remote");
           catch (Exception e )
           System.out.printf( e.getMessage());