This discussion is archived
6 Replies Latest reply: Feb 24, 2012 1:04 AM by gimbal2 RSS

JavaFX 2.0 and EJB 3.0 injection

909602 Newbie
Currently Being Moderated
Hi all

I need help in JavaFX2.0(Standalone Desktop apps) and EJB3.0 injection, I have tried multiple way of JNDI lookup annotations but still facing javax.naming.namenotfoundexception unable to resolve.

Please help in this regard it would be helpful if there is any example available.

NetBeans7.1
Glassfish 3.1.1.
JavaFX2.0(Standalone application)


Thanks
Nilesh
  • 1. Re: JavaFX 2.0 and EJB 3.0 injection
    jsmith Guru
    Currently Being Moderated
    Are you bundling all of the jars for EJB with your JavaFX 2.0 standalone app and referring to them from the standalone apps jar manifest? And if you are, how are you getting the bundling done, is it via NetBeans? And if it is NetBeans, are you using the latest NetBeans nightly build which doesn't incorrectly construct the JavaFX jar manifests like the NetBeans 7.1 release build does?

    What exactly are you trying to do? Are you trying to invoke EJBs which are hosted in the deployed JavaFX app or remotely call EJBs hosted in the GlassFish server? If you are trying to remotely call EJBs hosted in the GlassFish server how would you do that?
  • 2. Re: JavaFX 2.0 and EJB 3.0 injection
    909602 Newbie
    Currently Being Moderated
    EJB project is completely diffrent from JavaFX, i am deploying EJB project on glassfish,
    Invoking EJB with the help of JNDI lookup, where it is failing it is working fine if i lookup outside fx project like simple java project.

    Properties props=new Properties();
    props.setProperty("java.naming.factory.initial","com.sun.enterprise.naming.SerialInitContextFactory");
    props.setProperty("org.omg.CORBA.ORBInitialHost", "xxx.xx.xx.xx");//ur server ip http://
    props.setProperty("org.omg.CORBA.ORBInitialPort","3700"); //default is 3700
    ctx = new InitialContext(props);
    ctx.lookup(java:global/EnterpriseApplication2-ejb/BillSearchQuery);

    I have tried all the standard naming conventions for JNDI

    EJB project jar in Dist folder refrencing to JavaFx project.

    Pleae let me know if i have missed out anything

    Edited by: 906599 on Feb 23, 2012 3:31 PM
  • 3. Re: JavaFX 2.0 and EJB 3.0 injection
    jsmith Guru
    Currently Being Moderated
    Hmm, I don't think I'll be able to help you as I have not dealt with EJBs for a long time and never had to remotely invoke one from a Java client. If you are able to get the invocation working from a Swing client or standalone Java app, but not JavaFX, then it is probably an application packaging issue. If that is the case, then unpack your application jar file and check your jar manifest to make sure all of the dependent jars you need to get the call to work are in your application jar, make sure you are using the latest nightly build of NetBeans and not the NetBeans 7.1 release, make sure you are trying to execute your application as a standalone application and not a an applet or webstart app (which you would need to sign to allow the corba call to work on port 3700). I think you also would need to ensure that the client code is correctly packaged and configured (via XML or annotations or however EJB does it nowadays), to allow resolution of this lookup => java:global/EnterpriseApplication2-ejb/BillSearchQuery
    it would be helpful if there is any example available.
    Yes it would - I don't think one exists.
    If you manage to get your call to work, you could publish the client/server code, then there would be one . . .
  • 4. Re: JavaFX 2.0 and EJB 3.0 injection
    jsmith Guru
    Currently Being Moderated
    There seems to be a few different ways you can get an client to talk to a GlassFish EJB server.

    1. Look at http://edwin.baculsoft.com/2010/09/a-simple-java-client-server-application-using-ejb3-and-glassfish3/ and see if you can get that example to work in a JavaFX client. I couldn't believe that you would need to package 36 jars with your client app, just to talk to the server and say hello world, but that is what that blog recommends - other sources say differently though as below . . .

    2. What seems to be a bit more sane is "How do I access a Remote EJB component from a stand-alone java client?"(http://glassfish.java.net/javaee5/ejb/EJB_FAQ.html#StandaloneRemoteEJB). It seems just a single additional client jar which is involved, but it is tied to only be able to communicate with a GlassFish Server - so if you changed your JEE server to WebSphere or something like that, you would have to repackage and redeploy your clients - probably not a big deal for you as if that scenario were really a hassle, you would probably just be writing a webapp with an html client anyway.

    3. Finally, there is the ability to deploy your code to an Application Client Container (ACC) http://docs.oracle.com/cd/E19798-01/821-1752/beakv/index.html which would allow you to write a remote EJB client which could communicate with different EJB servers in a standard way so you could switch in and out your EJB server vendor without updating your clients. I would not really recommend such an approach as (a) it looks way complex (b) it has it's own packager and launcher which is likely not to work in a friendly manner (or at all) with the standard JavaFX packager and launcher.

    This tutorial offers a different set of jars for adding to your ejb client http://wiki.netbeans.org/CreatingEJB3UsingNetbeansAndGlassfish.

    For me, it's all just a confusing mess . . . I wonder what option you are using?
  • 5. Re: JavaFX 2.0 and EJB 3.0 injection
    909602 Newbie
    Currently Being Moderated
    Give me some time i am going through links provided by you
  • 6. Re: JavaFX 2.0 and EJB 3.0 injection
    gimbal2 Guru
    Currently Being Moderated
    jsmith wrote:
    There seems to be a few different ways you can get an client to talk to a GlassFish EJB server.

    1. Look at http://edwin.baculsoft.com/2010/09/a-simple-java-client-server-application-using-ejb3-and-glassfish3/ and see if you can get that example to work in a JavaFX client. I couldn't believe that you would need to package 36 jars with your client app, just to talk to the server and say hello world, but that is what that blog recommends - other sources say differently though as below . . .
    That's my main beef with using remote EJB invocations from client applications, you need all those server specific dependencies just to be able to make it work. But if you turn said EJB into a JAX-WS webservice... you need none at all, plus the setup code is a whole lot easier.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points