Skip to main content

How to call EJB from Standalone java program in diffrent JVM



I have developed EJB using NETbeans IDE having glassfish server. I can call it from standalone java, only if this java project is developed under NETbeans and run under same JRE. But I need to find out how to run it in different jre's. I could not find much help on this one. Any suggestions? (or related links would do) Thanks,




Comments

  1. In order to call EJB from remote JVM, you should


    Use @Remote annotation on you EJB
    Supply a jar with interfaces and put it in the classpath of you client-vm
    Use JNDI in order to obtain a reference on the EJB stub from server.
    For JNDI you'll need an implementation that depends on container (for example, if its JBoss jboss-client-all.jar should be enough (I don't remember the exact name but you've got the point, I think)


    Once you feel comfortable with the overall notions and definitions, read this example, I think its handy enough
    Example

    Hope this helps

    ReplyDelete
  2. STEP 1:

    Context context = new InitialContext():



    The initial context is a reference to the JNDI lookup service.
    It is like the entry into the JNDI virtual directory tree.


    STEP 2:

    Object o = context.lookup("mejb"):



    Here in the lookup we need to give the name of the bean whatever that is deployed in the server, to get a reference to the home interface of that bean.
    We then get the object of type java.lang.Object we need to cast this object to the Home interface of whichever bean we did a lookup on.


    STEP 3:

    Home home = (Home) PortableRemoteObject.narrow(o,Home.class):



    We actually need to cast the object to the type that we think it is type of. However, since this is RMI over IIOP we need to use the PortableRemoteObject.narrow method this it seems filters the object type to the actual object type and checks for errors.

    ReplyDelete

Post a Comment

Popular posts from this blog

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.