users@glassfish.java.net

Re: Writing a Swing-EJB Client (with Netbeans 6.0)

From: Markus KARG <markus.karg_at_gmx.net>
Date: Thu, 06 Mar 2008 18:51:08 +0100

Read this: https://glassfish.dev.java.net/javaee5/docs/DG/beakt.html

Have Fun
Markus

glassfish_at_javadesktop.org schrieb:
> Hello folks!
>
> I'm want to develop an Swing-based EJB-Client in the easiest possible way. How can I connect to the Session-Beans?
>
> When I use Netbeans "Enterprise Ressources" -> "Call Enterprise Bean" Feature, it generates the following Code:
>
> public class NewJFrame extends javax.swing.JFrame {
> @EJB
> private static AuftragsAbwicklungRemote auftragsAbwicklungBean;
> ....
>
>
> The Main-Class is quite straight-forwarded:
>
> package pi_praktikum1;
> import javax.swing.JFrame;
>
> public class Main {
>
> public static void main(String[] args) {
>
> JFrame gui = new NewJFrame();
> gui.setVisible(Boolean.TRUE);
> }
> }
>
>
> When I try to use the Session-Bean (even by starting the program with Webstart) I get an Null-Pointer Exception.
>
> so my work-around is to develop a separate class, to access the Bean:
>
> public class TestClass {
> public AuftragsAbwicklungRemote lookupAuftragsAbwicklungBean() {
> try {
> Context c = new InitialContext();
> return (AuftragsAbwicklungRemote) c.lookup("java:comp/env/AuftragsAbwicklungBean");
> } catch (NamingException ne) {
> java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE, "exception caught", ne);
> throw new RuntimeException(ne);
> }
> }
>
> }
>
> My Question is: "Is there a simpler way (directly from the NewJFrame-Class)"
> and: "Why doesnt Dependency Injection work?"
>
> I would be happy if someone could help me.
>
> Greetings,
> Jan
> [Message sent by forum member 'janmueller' (janmueller)]
>
> http://forums.java.net/jive/thread.jspa?messageID=262666
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>


-- 
http://www.xing.com/go/invita/58469