How to lookup a bean from a standalone app.

I've got the following question..
I've created a stateless sessionbean and deployed it in the J2EE Server 1.3.1. (That one you get from Sun when you download the J2EE SDK) I've created a client for my bean, and when i execute it with the 'runclient -client my.ear -name myclientclass' command, it works just fine.
But, i now want to run it as a standalone application, without the 'runclient' command. I am able to create an initialcontext (without any properties), but my bean can not be found in 'java:comp/env/ejb/bean' (the same name i use with the 'runclient' command, so the bean should be there). My guess is that i should add some initial context properties, but which ones? All the examples i can find are with ldap context factories. Can anyone give me any advice on how to connect to the J2EE server and lookup my bean?
Thanks in advance.
Nick

Hi,
You could write something as below
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "jnp:localhost:1099");
env.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
try {
Context ctx = new InitialContext(env);
Session_LocalHome session_lh = (Session_LocalHome) ctx.lookup("Session_Home");
Session_ session_ = session_lh.create();
OR
Use a jndi.properties file which would have the same entries as above, please search over internet and find out what to include in it.
One more thing to note is, in above example i said
env.put(Context.PROVIDER_URL, "jnp:localhost:1099");
meaning the lookup is on port 1099, this is not same for all the servers. Check your server documentation and find out " What is the port number on which your server listens ? "
Regards
Meka Toka

Similar Messages

  • How to lookup EJB3 beans using JNDI names without defining ejb-ref in DD?

    Hi Kenneth,
    I am just continuing the topic:
    How Lookup SLSB from other SLSB? <HELP>
    http://forum.java.sun.com/thread.jspa?threadID=5117484&tstart=0
    (my original forums account failed, so I am using new one)
    if I am not seeking portability I should be able to lookup a bean directly through JNDI without using the ejb-ref. (I just want to see how it can be done)
    http://forum.java.sun.com/thread.jspa?forumID=13&threadID=751907
    http://www.theserverside.com/discussions/thread.tss?thread_id=16402
    I am using SJSAS PE 9.0 I am failing to lookup my beans from other beans directly without ejb-ref.
    Is there some sample code to look at?
    Thanks!

    Global JNDI names are vendor-specific and not known until deployment time. That is one
    of the main reasons the Java EE component environment model defines a level of
    indirection for accessing component dependencies. It is best to use either an ejb-ref
    or @EJB annotation when accessing EJBs from a Java EE component.
    If you choose not to, you just have to make sure the global JNDI name you use matches
    the one assigned to the target EJB. We have a lot of information on how this works
    in our EJB FAQ.
    https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html
    If you're still encountering an error, please provide more specifics about your application,
    the code you're using for the lookup, and the error message you're receiving. Just
    saying "my looking fails" doesn't help us diagnose the problem :-)
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How can I transfer books from kobo ipad app to another ipad

    How can I transfer books from kobo ipad app to another ipad with a kobo ipad app.

    On the other iPad's kobo app, sign in. It should automaticaly load you books with your account. Hope this helps.

  • My wife and I share a computer, but different Itunes accounts. How do I stop itunes from synchronising her apps to my phone

    My wife and I share a computer, but different Itunes accounts. How do I stop itunes from synchronising her apps to my phone?

    If the music is on the same computer, import the songs to your iTunes library by dragging them into iTunes or choosing File > Add to Library (Mac) or File > Add File to Library or Add Folder to Library (Windows).  If the music is on different computers you can set up Home Sharing to copy the music from one library to the other (see http://support.apple.com/kb/HT3819 and http://support.apple.com/kb/HT4620).

  • How do I stream music from non-iTunes apps to Airport (mac air core-i7 OS 10.7.5 airport firmware 7.6.1 --- option-clicking speaker icon only shows internal speakers - audio streaming works from iTunes just fine.

    How do I stream music from non-iTunes apps to Airport (mac air core-i7 OS 10.7.5 airport firmware 7.6.1 --- option-clicking speaker icon only shows internal speakers - audio streaming works from iTunes just fine.

    Hello Achates:
    I did not read the rather long post. If you wish to reinstall OS X 10.4, use your software install DVD. Backup is essential. To minimize your risk, I would use an archive and install:
    http://docs.info.apple.com/article.html?artnum=107120
    In that way, you will have a fresh copy of OS X and your current settings will be preserved.
    Incidentally, I do not agree that the printer problem is best solved by reinstalling OS X. I have had HP printers for sometime and, on one occasion, had difficulty after an upgrade. HP technical support walked me through uninstalling all traces of the HP driver and then reinstalling.
    Barry

  • HT204053 How do i move files from my dropbox app to my music app on my ipad?

    How do i move files from my dropbox app to my music app on my ipad?

    You can't.
    You have to add them from DropBox to iTunes on your computer and then sync them to your iPad

  • HT1491 how to use a ringtone from a downloaded app in iphone5

    how to use a ringtone from a downloaded app in iphone 5

    RINGTONE
    This how to make ring tones for your iPhone:
    Choose the desired song from you library
    Do a secondary click on your song if you are using a MAC (right click for PC)
    Click "Get Info"
    Go to Options tab
    Set Start Time and Stop Time, some iOS only allow for a 30 sec duration for ringtones, then click OK
    Do secondary click (right click for PC) to your selected song
    Click "Create AAC Version", new song from your selected will added to your library (short one)
    Do secondary click (right click for PC) to your short one (new song)
    Click "Show in Finder"
    Rename file *.m4a to *.m4r, click "use *.m4r"
    Drag the file to library, for the first time it would automatically add your library with new folder "Tones" under Apps folder
    Open the ring tones in the Tones folder of your library than drag it to your iPhone and your ringtone also would be automatically added "Tones" folder.
    Last but not least, set the ring tone in your iPhone under the "Setting-Sound"
    For information on how to make ringtones read http://www.ehow.com/how_2160460_custom-iphone-ringtones-free.html
    Or
    http://www.demogeek.com/2009/07/31/how-to-add-custom-ringtones-to-your-iphone/

  • How can I stop iTunes from transferring purchased apps from iPad to computer?

    How can I stop iTunes from transferring purchased apps from iPad to my computer? I don't want them taking up space on my computer. iPad backups and apps on the cloud are enough to ensure my apps are backed up, so I don't understand why they need to be on iTunes too. I'm running Mavericks, iTunes 11.1.5 and iOS 7.0.6.

    There isn't an app for that!
    As far as I can tell there is no option to give you that control. It is worth noting that apps can be withdrawn from the store at any time. Should your device need restoring you need all the apps in your library to transfer to it before the app data can be successfully restored. Pulling that all down from the cloud would be time consuming.
    If space is becoming an issue you should consider moving the library to a bigger drive (which you should also backup to another).
    As a temporary measure you could try deleting some larger apps using Finder from within iTunes/iTunes Media/Mobile Applications while keeping the entries in your library. iTunes may complain during syncs that it cannot copy apps to the device because they cannot be found, but it should not clear them from the device. Test first on a single app that doesn't have any data that you would mind losing in case the behavior has changed from the last time I tested it.
    tt2

  • How do you delete albums from the music app in iOS 7?

    How do you delete albums from the music app in iOS 7?

    You use to be able to in the last IOS and it was a nice feature and now it's gone. iOS7 ruined the Music App!

  • How can I delete cities from my weather app?

    How can I delete cities from my weather app?

    1. After launching the weather app in iOS 7, click on the list view icon in the bottom right connerto bring up the city list view.
    2. Then, select the city you want to delete.
    3. Next, swipe left on the selection,  then click on the delete button that appears.
    same steps have been explained in detail with screen shots in this article ..... http://nyacomputing.com/how-to-delete-a-city-in-weather-app-in-ios-7/

  • How to call A Seesion Bean from a standalone java program

    i want to call a session bean vis a standalone java program on the same machine. i am having some problem with CORBA. i really do not understand what is going on.
    help me please.
    Thank you

    You are shooting in the dark......explain the problem

  • How to call java bean from jsp

    hi
    How to call a java bean from jsp page..
    Is any other way to call javabean from jsp page apart from this sample code...
    <jsp:useBean id="obj" class="com.devsphere.articles.calltag.TestBean"/>
    thnx in advance

    If you also use servlets, you can attach beans to the request or session and use them directly in your JSP's. So if you do:
    request.setAttribute("name", yourBean);and then forward to a JSP, you can reference the bean like:
    ${requestScope.name}

  • How to call Java Beans from JSP (eg.put them in a WAR or package)

    Can anyone explain to me what are the steps and ways to call java beans from JSP?

    1st, put the javabean classes in the right place:
    the web-inf/classes/your_bean.class directory of corresponding web application
    2nd in your jsp page:
    <jsp:useBean id="obj_var_name" class="your_bean"/>
    <jsp:setProperty name="obj_var_name" property="smthg" value="smthg_calue"/>
    Micheal

  • How to lookup a Bean?

    i have successfully deployed an EJB by using J2EE deploytool.
    my source code to lookup the Bean as following:
    Context ctx = new InitialContext(System.getProperties());
    java.lang.Object objref = ctx.lookup("skey");
    home = (SessionKeyHome)PortableRemoteObject.narrow(objref, com.ibm.sessionkey.SessionKeyHome.class);
    i have read serval books and articles,there are different codes for lookuping a bean.Why?and when should we use this or that?
    But i get the error msg:
    Warning: unable to read transaction.interoperability config property
    java.io.FileNotFoundException: /export/home/ass/config/security.properties
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:103)
    at com.sun.enterprise.util.Utility.getPropertiesFromFile(Utility.java:42)
    at com.sun.enterprise.iiop.security.SecurityMechanismSelector.<clinit>(SecurityMechanismSelector.java:102)
    at com.sun.enterprise.iiop.IIOPSSLSocketFactory.getEndPointInfo(IIOPSSLSocketFactory.java:211)
    at com.sun.corba.ee.internal.iiop.ConnectionTable.getConnection(ConnectionTable.java:73)
    at com.sun.corba.ee.internal.iiop.ConnectionTable.getConnection(ConnectionTable.java:68)
    at com.sun.corba.ee.internal.iiop.GIOPImpl.getConnection(GIOPImpl.java:70)
    at com.sun.corba.ee.internal.corba.InitialNamingClient.locateObject(InitialNamingClient.java:769)
    at com.sun.corba.ee.internal.corba.InitialNamingClient.getIORUsingHostInfo(InitialNamingClient.java:597)
    at com.sun.corba.ee.internal.corba.InitialNamingClient.resolveCorbaloc(InitialNamingClient.java:573)
    at com.sun.corba.ee.internal.corba.InitialNamingClient.resolveUsingORBInitRef(InitialNamingClient.java:544)
    at com.sun.corba.ee.internal.corba.InitialNamingClient.cachedInitialReferences(InitialNamingClient.java:1080)
    at com.sun.corba.ee.internal.corba.InitialNamingClient.resolve_initial_references(InitialNamingClient.java:981)
    at com.sun.corba.ee.internal.corba.ORB.resolve_initial_references(ORB.java:2425)
    at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.java:52)
    at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:120)
    at javax.naming.InitialContext.lookup(InitialContext.java:347).java:23)
    javax.naming.CommunicationException: Can't find SerialContextProvider
    at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.java:63)
    at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:120)
    at javax.naming.InitialContext.lookup(InitialContext.java:347)

    Hi,
    There r two ways to lookup. One is that u specify the provider while running the client. E.g:
    java -D java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
    -Djava.naming.provider.url=t3://localhost:7001
    or alternatively u can specify these two properties in the Properties object of your client. e.g:
    Properties props = new Properties();
    props.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
    props.put(Context.PROVIDER_URL,"t3://localhost:7001");
    Context ctx = null;
    Object obj = null;
    try
    ctx = new InitialContext(props);               
    obj = ctx.lookup("HelloJNDI");
    Which method to use is matter of convenience.
    Values of provider url & initialContext will change depending on the app server u r using.
    I hope this will help u.

  • How can i print lists from the reminder app

    Does anybody know how to print lists from the Reminder app ?

    There's no print menu in Reminders.
    You can take a screen shot and print that.  Hit command-shift-3 when Reminders is showing, then hit the spacebar, and then click on the Reminders window and you'll get a screen shot on your desktop.  You can then open that in Preview and print from there.
    A better solution though is to just use an iPhone and sync, and have your reminders with you :-)

Maybe you are looking for

  • Image Capture Opens

    Image Capture Opens when ipod plugs in or i boot osx how can i stop it? image capture has no preferences!!!

  • English + different language key layout/texts

    Hello! Could a kind soul please help me get directions to solve my problems with locale, keyboard layout, and font display? Here's what I'm trying to accomplish. System talks to me in English Date and time is in the international format (YMD) I can f

  • Opening links (maybe related to mac "newbe" query...)

    Hello. I can't seem to open links, especially pdf file from within webpages and have the text big enough to read... the browser window is full screen maximized but file is shown therein as the whole page. when this happens in other applications there

  • How can I get commnet history not displayed ?

    Hello All, I tryed to use EvCOM and EvCGT function of SAP BPC in my input schedule, and noticed that the both function displays the strings added the number of the history of the comment like "..(6)" I'd like these added number strings to not display

  • Omni Portlet HTML Format - Alternating Row Colors using ##OP_ROWNUM_MOD2##

    Some of the Portal Documentation makes note of how the variable field ##OP_ROWNUM_MOD2## could be utilized to laternate the ROW colors using the HTML format. Does anyone have an example of how this would be done? --Tim