Understand InitialContext lookup - Understanding concepts

I am new to EJB, I am trying to understand the concepts. I am trying to understand example posted on https://glassfish.dev.java.net/javaee5/ejb/examples/Sful.html.
What I don't understand is how Standalone Java Client is doing the lookup and against what is it doing the lookup. Is it just getting the reference from the class that's packaged in jar file ? If so, then how is it maintaining state of the object - isn't that just as using any other class in the package. I would have thought that there would be some trading service like CORBA where server registers the object and client gets the reference to the object. But, in Client examples that I see it isn't clear how it get's the reference to the object that could either be running on the same host or different host in different JVM i.e being deployed by App server.
I am trying to understand specifics and can't seem to get simple and good information about it. Could somebody help me in understanding this.
I want to start this discussion and probably if you guys help me I'll ask some more questions.

When you deploy an application containing an EJB that exposes a Remote interface, the EJB
container registers an object representing the Remote EJB in its naming service. The naming
service lives in the server JVM. The name of the Remote EJB object is vendor-specific. SUN's
approach for assigning global JNDI names (a.k.a. "mapped" names) is here :
https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#SessionBeanGlobalJNDINameAssignment
The portable way to retrieve an EJB reference is to define an EJB dependency and access that
dependency via a java:comp/env lookup or through dependency injection. However, those options
are not available to stand-alone Java clients, since stand-alone Java clients are not Java EE
components. Take a look at the approach used by the Application Client in the Sful example to
see the difference. There's more on the difference between Application Clients and stand-alone
Java clients here :
https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#AppClientDef
In the case of the stand-alone client, when the no-arg InitialContext is instantiated, the client
JVM bootstraps a naming provider that knows about the server's naming service. That
works because the appserv-rt.jar has a jndi.properties file that controls the bootstrapping.
Since the stand-alone java client can not use the Java EE component environment to access
the EJB dependency, it is forced to explicitly use a global JNDI name instead. In the example
you cited, the global JNDI name has defaulted to the fully qualified name of the remote business
interface.
--ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • EJBContext.lookup() vs InitialContext.lookup() @ EJB3.0

    current design of my application uses a helper class for retrieving the system resources. according the new ejb3.0 specs i can't use dependency injection in helper classes. so, if we wanna stay with the current design, we should continue with the 2.1 style initialcontext.lookup.
    my question is if brand new EJBContext.lookup()is just a wrapper that hides direct jndi usage, or there is any deep reason not to use InitialContext.lookup() anymore even if this means that the whole design should be rebuilt from scratch?
    thanks folks!

    Good question :-) EJBContext.lookup() is just a convenience method to make the lookup a bit easier to understand.
    -- It removes the JNDI API from the developer's view.
    -- It removes the notion of "java:comp/env" from the developer's view.
    -- It removes the need to catch a checked exception during the lookup.
    However, the object returned from EJBContext.lookup("abc") is exactly the same as the equivalent new InitialContext().lookup("java:comp/env/abc"). So, you can feel free to use the older more explicit JNDI component environment lookup wherever you'd like, but for code located directly within the bean class, it's easiest to use injection or EJBContext.lookup.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Hello, my English his my second languish, i hope i will be understandable and will understand you... I just use photoshop to modify a picture. First i renamed it, then transformed it, after i save it under the new name. My problem is that in the web site

    Hello, my English his my second languish, i hope i will be understandable and will understand you.

    First see if the image is in RGB, Image CMYK is not displayed on the Internet
    The second image name has to be imported in website programming. For example: On the website the image is figura.jpg name if you rename the image to figura1.jpg the site will not find the image.
    In Photoshop to save as web it will save us now for internet formats. PNG, JPG, Gif

  • NamingException initialContext.lookup

    I have imported a working eclipse J2EE project into JDeveloper 10.1.2.1.0 and fixed some compilation errors by adding the proper libraries. When I run the dcount-ejb project it serves up the login.jsp, but when I attempt to login to the app I get this error:
    05/11/02 13:18:16 $$$getRemoteHome() NamingException:
    initialContext.lookup of java:comp/env/ejb/UsersSBManager
    Error instantiating web-app JNDI-context: No location specified and no suitable instance of the type 'com.cde.decemberCount.ejbJar.users.ejb.SessionBean.UsersSBRemote' found for the ejb-ref ejb/UsersSBManager
    I ran "Verify Enterprise Bean" on UsersSBManager and received:
    Error : Referenced home interface      com.cde.decemberCount.ejbJar.users.ejb.EntityBean.UsersEBRemoteHome not found in project.
    Error : Referenced remote interface
         com.cde.decemberCount.ejbJar.users.ejb.EntityBean.UsersEBRemote
    not found in project.
    I have added the dcount-ejb.jar (containing all the beans including the UsersEBRemote) to my libraries and classpath.
    What else am I forgetting

    In continuing to troubleshoot this problem, I increased the size of the Embedded OC4J Server log and caught this error at the top of the file. I believe it is the core of the problem with the EJB's. I'm hoping its a simple configuration issue:
    05/11/03 08:59:30 Error instantiating application 'current-workspace-app' at file:/H:/DCount/dCount-oc4j-app.xml: Error initializing ejb-module; Exception Unable to find/read assembly info for H:\DCount\ProjectNotes\config\build\lib\classes\com\cde\decemberCount (META-INF/ejb-jar.xml)

  • Failng to understand stateless sessinon bean concept

    Hello all.
    I am new to EJB. having read the java spec, i still can't understand the
    stateless session bean concept.
    according to the spec, all instances of a bean are equivalent when they are
    not used by client. but what happens when a client changes values of fields
    in the instance he works with? are the member variable are like static
    fields, when all instances of the bean have reference to the same object ?
    if so, why the need to assign seperate instance to each client, why not
    just give them all the same instance reference?
    if not , then every instance can be changed independably of all the other instances , but then they are not
    equinalent anymore, are they? - they keep modification made by a certain client,
    and therefore are client specific, aren't they?
    If any one can clear this up for me - it will be great.
    thanks for your time, Oded.

    A stateless session bean does not hold any data across multiple client requests.
    A client gets hold of slsb, do some processing and exits and the bean is returned to the pool. A slsb does not even know which client it was handling. So when a new request comes from the same client, maybe this bean will handle the request or some other slsb (container will handle this).Hope this clears some of ur doubts.

  • Null . Unable to understand the null value concept

    Dear friends, I am very confusied about the behavior of ----"null"
    and i take a String.The String value will come from data base ---- String inputString[This string value will come from database], In data base the value is null.
    now i am checking if the string "inputString" is null --will perform a work  if not then perform another work.
    so--
    inputStringFromUser.equals(null)
    System.out.println("In if block");
    else
    System.out.println("In else block");
    but it not working if the data base field is blank.
    but if i do ---
    inputStringFromUser==null)
    System.out.println("In if block");
    else
    System.out.println("In else block");
    it is working fine . why???
    please tell me why it is happning.

    I did not get any null pointer exception when i test
    if(inputStringFromUser.equals(null)
    y previous query have cleared.
    But i fell i am little bit of confused for this ---
    "can't invoke methods on a null reference, that gives
    NullPointerException".Can any one please explain.Here's the deal and here's what they're trying to say without any metaphors...
    inputStringFromUser is a String object right? the equals method is inherited from the Object object (java.lang.Object)
    but if inputStringFromUser is null, it means there's no instance of that String object...so if it's null you cannot access the equals method...this is why you need to use the == operator to see if it's null.
    hope that makes sense.

  • InitialContext lookup over HTTP using a full PROVIDER_URL (including path)

    Hi,
    We have a standalone Java JMS client application that is sending messages to a queue on a WebLogic (WLS 9.2 MP3) server. It uses the WLInitialContextFactory (WebLogic implementation of InitialContextFactory) class to look up the initial context over HTTP when making the connection to send messages to the queue.
    This all works fine when the client connects directly to the server - i.e. supplies the address of the server as the PROVIDER_URL. However, in our infrastructure, we cannot connect directly from this client to the server; we need to go via a HTTP proxy.
    In a basic configuration HTTP proxy we set the provider URL to be the address of the proxy server, with the proxy is configured to route all requests straight through to the WebLogic server. This configuration also works fine - the JMS client can send messages successfully.
    Unfortunately, this basic proxy configuration is still not sufficient for our Production environment. Our production proxy "fronts" multiple servers, each one identified by the first portion of the URL. So, the proxy is be configured such that requests to "http://proxy/server1/test_request" will be routed on to "http://server1/test_request", whereas a request to "http://proxy/server2/test_request" will be routed to "http://server2/test_request". This configuration works fine for basic HTTP requests, to webpages etc.
    However, when we try we use this mechanism with our JMS client over HTTP, it is not working. We set the provider URL on the client to "http://proxy/server1" in order to send a message to server1. However, we find that the WLInitialContextFactory class seems to be ignoring the final part of the URL ("server1") and still sending requests directly to the root proxy address of "http://proxy", so it doesn't work.
    I appreciate that this can be viewed as a WebLogic specific implementation issue for their WLInitialContextFactory, and I've raised a query with their support people on this. From my own research however, it seems the behaviour of their factory is not different to most other implementations - i.e. the major implementations would all have this issue.
    I'm wondering if anyone is aware of any implementations that would handle the situation I've described. If not (or otherwise!) is there something crazy about our approach that noone has catered for it?! It seems a reasonable situation to me, but maybe I'm missing something!
    Any comments, advice, etc. would be greatly appreciated, thanks.
    Regards,
    Adrian
    Edited by: AdrianFitz on 08-Apr-2010 12:21

    Hi,
    Thanks for the quick response. Would you mind providing a bit more detail on your suggestion, as am not 100% sure I understand it fully.
    If I see what you are getting at, are you talking about configuring proxy settings on my client side, similar to how I have to configure my internet browser with proxy settings when accessing the internet from within my companys LAN?
    If I'm interpreting that right, then I guess my use of the word proxy might be a bit inaccurate or lead to some confusion. What my orginal post described as a proxy should have been more accurately describes as a reverse proxy (acting primarily as a load balancer).
    Ideally, other than changing the URL slightly, the client should be 'unaware' that it is going through a proxy at all.
    Hope that clarifies somewhat, any further comments would be great! Thanks.
    Regards,
    Adrian

  • Basic class understanding - trying to understand AS3

    I'm relatively new to AS3 and AS in general so forgive me...
    Is my understanding that there are no Abstract classes and
    you can't override or overload constructors of derived classes
    correct? Abstract classes aren't important for me but if it's
    possible I'd like to know how. But is there a way to overload
    default constructors and I'm just doing something wrong? Can we
    only override methods or can we overload them also. Work arounds
    would also be appreciated.
    Here's what I'm doing currently to make things work.
    -For a simple game I'm making, I'm not using FlexBuilder and
    don't want to for this project for specific reasons, so I'm using
    Flash and instead of using sprites and bitmaps I want to draw
    shapes in Flash and covert them into MovieClip symbols which I
    "link" for export as AS to use in my code. I want to make it a
    little modular so I can just change certain aspects of the code for
    different approaches.
    If I create a class Actor which extends MovieClip the default
    constructor has to be Actor() with no arguments. But I'd like my
    class to be able to have arguments like initial x and y
    coordinates. I know you can just create methods to initialize each
    part but I'd like to try and have a default constructor to do so.
    In Flash I notice that if you derive a written class or built
    in class it requires the standard default constructor, "which I may
    be wrong about and I hope I am and someone could show me what I'm
    doing wrong", I found if you derive a class based on a symbol you
    linked for export as AS I can create a new constructor with
    whatever argument(s) I want (so this is why I'm making this post,
    if I can do this couldn't there be a way to override
    constructors?).
    Here's how I'm doing it currently...
    1) So I create a base class called Actor which extends
    MovieClip save it as Actor.as and default constructor of Actor()
    add whatever properties I want.
    2) Then I create an object in my library, let's call it
    mcShip, then I link that symbol for export as ActionScript and have
    it's base class as Actor and name the class ShipMC.
    3) I then create a new .as file and call this one
    ShipActor.as, this class ShipActor extends ShipMC and then I create
    a default constructor ShipActor(gs:GameScreen, xA:Number,
    yA:Number) and this works fine
    (also I create a method in Actor class called ActorSuper and
    call it from ShipActor with passed in arguments, since I don't know
    of a way to overload the parent class' constructor)
    If I were to just have my mcShip with a base class of
    flash.display.MovieClip and I try to create ShipActor with the
    constructor above it says missing default constructor. The above 3
    steps is the only way I can get it to work for now. Is there a way
    to overload the constructor? If not are there any other work
    arounds?
    I'm only looking at this for object oriented approach more
    than anything. Sorry for the lengthy post but I didn't want any
    confusion, or any more confusion -.-
    Thanks for taking the time to read this post
    -John

    Your correct in that you cannot define abstract classes in
    ECMA based actionscript nor does Actionscript allow you to overload
    at all. There are work arounds for both though such as just have
    your overloaded methods use a single Object as its argument and
    that Object contain the different parameters.
    I find developing in the Flash IDE difficult at best so if
    you'd like another option besides flex builder you can use eclipse
    webtool kit with FDT. Its only got 30 days free but its worth it to
    buy it ( trust me ). A tip though is to install the latest flex sdk
    and change the source library to it so you can use Ant to build
    your swf's.
    For an object called Actor I would just extends the Sprite
    package instead of MovieClip unless you're going to manipulate its
    timeline ( why would you though ). If you need an tweening package
    check out GreenSock's TweenLite. Its better then flash's default
    one.

  • LoadBalance in InitialContext Lookup

    Hi,
    I'm having following requirement.An Ejb has been deplyed in a weblogic cluster which has two Servers Server A & B.
    In Server A the Ejb is in started mode,& in Server B it is in Stopped state.Now from the server B i'm using a standalone client to lookup the ejb using JNDI name & initial context.
    +          Hashtable env = new Hashtable();+
    +          env.put( javax.naming.Context.INITIAL_CONTEXT_FACTORY , "weblogic.jndi.WLInitialContextFactory" );+
    +          env.put( javax.naming.Context.PROVIDER_URL , "t3://SERVERB:9001,SERVERA:9001" );+
    +          ctx = new InitialContext( env );+
    I had given two URL's [ both Server A & Server B] in the initialcontext. What I'm expecting is the initialcontext will lookup serverB where the EJB is in stopped state, then it will lookup in Server A where the EJB is in started stated & communicate with it.
    But now i'm getting the exception, it is throw from ServerB where the EJB is in Stopped state.
    +Exception in thread "main" javax.naming.NameNotFoundException: Unable to resolve 'XXXEngineBean'. Resolved '' [Root exception is javax.naming.NameNotFoundException: Unable to resolve 'XXXEngineBean'. Resolved '']; remaining name 'XXXEngineBean'+
    +     at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:234)+
    Thanks in Advance

    Hi,
    this may be the same implementation problem of class loading inside SAP NetWeaver Java we stumled oger. I posted an OSS but they will not change it.
    If you have to EJBs in different enterprise applications, you MUST set an application reference from one enterprise application "A" (typically the calling with the lookup) to the enterprise application "B" that contains the EJB that is looked up.
    see [http://help.sap.com/saphelp_nw73/helpdata/en/4a/ee99c229370c9ee10000000a42189c/content.htm]
    "To look up a remote object, you must have its remote interface in the clientu2019s class path (for external clients) or have a class loader reference to it (for components and applications running on the server process)."
    This makes the class loader of "B" the parent class loader of "A". If you omit this reference, the object that is returned by the lookup is loaded by class loader of "B" and you try to cast it to the class of class loader "A" which of course fails.
    Even calling
    PortableRemoteObject.narrow(obj, MyEjbLocalHome .class);
    before the class cast does not help (because it does nothing to obj at all).
    How do you set an application reference?
    In META-INF/application-j2ee-engine.xml in enterprise applicatoin "A" enter
    <?xml version="1.0" encoding="UTF-8"?>
    <application-j2ee-engine xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="application-j2ee-engine.xsd">
      <reference reference-type="hard">
        <reference-target provider-name="VENDOR_NAME_OF_EAR_B" target-type="application">APP_NAME_OF_EAR_B</reference-target>
      </reference>
    </application-j2ee-engine>
    If you are working with Development Components, just add a dependency with "Runtime" and this is done automatically.
    BTW if you redeploy "B", "A" will be restarted because its parent class loader changed.
    Regards
    Rolf

  • Ramifications of caching results of InitialContext(().lookup?

    One of the thing we discovered during our early efforts to port a 5.1 app to
    7.0 was that in 7.0 the JNDI lookups were simply taking FOREVER. It was
    really horrible.
    So, the question is, what are the ramifications of caching the results of
    this:
    Context ctx = new InitialContext();
    SessionBeanHome = (SessionBeanHome) ctx.lookup("SessionBean")
    We're guessing that this will fail horrible in a clustered environment, but
    what about a stand alone environment?
    Thanx!
    Will Hartung
    ([email protected])

    Can you provide some statistics, how much time it used to take and how much
    is it taking now etc.
    In 70, We know that the first InitialContext() call will take some time, as
    it needs to initialize kernel and generate the hot-codegened initial context
    stub. But once you have this call done, next initialContext call should be
    pretty fast.
    If you want to avoid the hot-codegen cost of stub, use this work around.
    From the browser, try
    http://server:port/bea_wls_internal/classes/weblogic/jndi/internal/RootNamin
    gNode_WLStub.class
    Save this class in your client package. This may give some performance
    benefit.
    This needs that, your classpath servlet should be turned on. See docs for
    more info on this.
    But I don't recommend this. This may become an issue later and may generate
    version incompatibilities, if you upgrade server and forgot to re-pack the
    client etc. I am not sure though.
    Hope this helps.
    Cheers,
    ..maruthi
    "Will Hartung" <[email protected]> wrote in message
    news:3d6a8d58$[email protected]..
    One of the thing we discovered during our early efforts to port a 5.1 appto
    7.0 was that in 7.0 the JNDI lookups were simply taking FOREVER. It was
    really horrible.
    So, the question is, what are the ramifications of caching the results of
    this:
    Context ctx = new InitialContext();
    SessionBeanHome = (SessionBeanHome) ctx.lookup("SessionBean")
    We're guessing that this will fail horrible in a clustered environment,but
    what about a stand alone environment?
    Thanx!
    Will Hartung
    ([email protected])

  • Hi, guys: hard to understand XI IDoc to file,

    I have work through this scenario. My colleague have problem to understand it. I think it is a little hard to explain it.
    About logical system, We can say ERP send IDoc to  XI , and XI convert it to file. and then the logical system name should be XI client's.  But in XI, we always define business system or business service for other systems not XI itself.  And service FTP2 must have a logical system for IDoc related scenarios , others(RFC,JDBC, file and etc) don't  need.
    When we define logical system and partner profile for file system, we use RFC destination from ERP to XI.
    For ERP A to ERP B, it is easy to understand, we should define logical system for B system in A , which is identical in B.
    logical system, partner profile in SAP ERP, and business service/ business system in XI are both to represent a (logical)business system.
    -- if ftp2 use logical system of XI, then another system can't use it. and maybe it can't work, business system can't use XI's logical system.
    Any ideas? Am I right?

    HI Shen,
    You are try to understand this bit complicated concept is on right track.
    Let me explain this step wise.
    1. About logical system, We can say ERP send IDoc to XI , and XI convert it to file. and then the logical system name should be XI client's. But in XI, we always define business system or business service for other systems not XI itself. And service FTP2 must have a logical system for IDoc related scenarios , others(RFC,JDBC, file and etc) don't need.
    ---->
    Here XI is just middelware so While sending the IDOC from R/3 to XI you need the Logical system with Receiver Port as directing to XI client. The Receiver Logical system is not imp. incase of sender IDOC.
    But when you will be sending the IDOC from XI to R/3 then the Logical system should be maintained, because the inbound IDOC processing program will work as per the details of Contorl IDOC and the Logical system that will point from XI. This will not be the case for other RFC, JDBC, file etc, as they don't have any kind of Control -Records to be maintained.
    2. if ftp2 use logical system of XI, then another system can't use it. and maybe it can't work, business system can't use XI's logical system
    ---->
    Yes, Once you have used the Logical system name in any of the Business service or Business system then you can't re-use it. This makes possible the feature of Re-usability. You can create the multiple communication channels under this Business service/system
    Hope this will be clear now
    Thanks
    swarup
    Edited by: Swarup Sawant on Jun 25, 2008 10:24 AM

  • Understanding Star Schema Operations

    Hi All,
    I worked on Oracle Answers and have knowledge on Data Warehousing concepts. I have enough oracle documentation on OLAP, OBIEE, Data Warehousing.
    But i 'm not able to understand the star schema concepts in and out. I'm lost on all documents, where i'm getting the simple answer on the following topics:
    1. Is it necessary to create dimensions using CREATE DIMENTION or it can be a simple relational table structure with CREATE TABLE statement?
    2. What will be the steps to create a very basic/simple star schema using DML statements not using any tool?
    3. Where I can get very basic level step by step tutorial to create a very simple star schema by sql -> loading test data by sql commands -> then what queries we can use to get BI reports or using OBIEE to create a simple rpd.
    Please give me some idea on this as I have to create a small OBIEE repository where i have to do create the warehouse and ETL process, everything.
    Pls advise.
    Thanks in Advance.
    Sudipta

    No my question was on creating the star schema. If i have to create a very simple star schema then can I create the star schema with the following relational tables?
    create table dim_products (
    product_id number primary key,
    product_name varchar2(32),
    brand varchar2(32),
    category_name varchar(32),
    sub_category_name varchar2(32)
    create table dim_time (
    time_id number primary key,
    selling_date date,
    selling_day number(2),
    selling_month varchar2(12),
    selling_Quarter varchar2(6),
    year number(4)
    create table dim_region (
    region_id number primary key,
    store_name varchar2(32),
    city_name varchar2(32),
    state_name varchar2(32),
    country_name varchar2(32),
    region_name varchar2(32)
    create table fact_sales (
    sale_id number primary key,
    region_id number ,
    time_id number ,
    product_id number ,
    unit_sold number,
    constraint fact_sales1 foreign key (region_id) references dim_region (region_id),
    constraint fact_sales2 foreign key (time_id) references dim_time (time_id),
    constraint fact_sales3 foreign key (product_id) references dim_products (product_id)
    Or I have to create the DIMENSIONS explicitly, in order to building the hierarchy levels?
    Regards
    Sudipta

  • Hi..I really don't understand how can labview can be a server, can you explain and give me some examples with steps on how to make the labview as a server? Please......

    nn
    Solved!
    Go to Solution.

    erm ok i will explain...
    actually..i know that labview can be a client or server. when the labview be a client, it can access other enable activeX application such as excel or word. i manage to do that a little such as to open excel file and save it at another location by using activeX functions or using the report generation toolkit. yes, i already know and understand the flow or concept of how the labview can be a client. But by using others activeX application especially excel, how can we make the labview be a server? i just need a very easy example and few steps for me to understand how can labview be a server or how excel can control the labview properties?
    really desperate to increase new knowledge.....:-)
    thank you very much for helping me....

  • Prerequisites  to understand bpel

    Could you please tell me what are the technologies and what are the prerequisites required to understand the bpel processes.
    I am currently working in OA Framework and would like to understand the archiecture and the fundamentals of bpel server and processes.
    It would be great if you could provide me this informations or point to some document which would explain the basic fundamentals involved in bpel.
    thanks
    Raj.

    IMHO:
    Knowledge about general workflow concepts is helpfull.
    Understanding of XML
    Understanding of Xpath and XSLT
    Understanding the concepts of Queues (for JMS adapaters)
    Understanding the concepts of Queries (for Database adapaters)
    Familiar with JDeveloper
    Marc

  • Problem in using InitialContext to do a lookup of CMP EnitityBean.

    Hi,
    I am running WLS 5.1 SP6 on Windows98. I am trying to lookup a CMP entiry bean from
    Java 1.3 client. I can successfully create the InitialContext but having trouble in using it to do the lookup. I get the following error:
    jndiContext is javax.naming.InitialContext@61f24(This is line is the result of println : see code)
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at com.titan.cabin.Client_1.main(Client_1.java:21)
    My code of the Java 1.3 client is as follows:
    package com.titan.cabin;
    import com.titan.cabin.CabinHome;
    import com.titan.cabin.Cabin;
    import com.titan.cabin.CabinPK;
    import javax.naming.InitialContext;
    import javax.naming.Context;
    import javax.naming.NamingException;
    import java.rmi.RemoteException;
    import java.util.Properties;
    import java.util.Hashtable;
    public class Client_1 {
    public static void main(String [] args){
    try {
    InitialContext jndiContext = getWeblogicInitialContext();
    System.out.println("jndiContext is " + jndiContext);
    CabinHome home = (CabinHome)(jndiContext.lookup("CabinHome"));
    Cabin cabin_1 = home.create(1);
    System.out.println("created it!");
    cabin_1.setName("Master Suite");
    cabin_1.setDeckLevel(1);
    cabin_1.setShip(1);
    cabin_1.setBedCount(3);
    CabinPK pk = new CabinPK();
    pk.id = 1;
    System.out.println("keyed it! ="+ pk);
    Cabin cabin_2 = home.findByPrimaryKey(pk);
    System.out.println("found by key! ="+ cabin_2);
    System.out.println(cabin_2.getName());
    System.out.println(cabin_2.getDeckLevel());
    System.out.println(cabin_2.getShip());
    System.out.println(cabin_2.getBedCount());
    } catch (java.rmi.RemoteException re){re.printStackTrace();}
    catch (javax.naming.NamingException ne){ne.printStackTrace();}
    catch (javax.ejb.CreateException ce){ce.printStackTrace();}
    catch (javax.ejb.FinderException fe){fe.printStackTrace();}
    public static InitialContext getWeblogicInitialContext()
    throws javax.naming.NamingException {
    InitialContext ctx = null;
    Hashtable ht = new Hashtable();
    ht.put(Context.INITIAL_CONTEXT_FACTORY, weblogic.jndi.WLInitialContextFactory.class.getName());
    ht.put(Context.PROVIDER_URL, "t3://localhost:7001");
    ht.put(Context.SECURITY_PRINCIPAL, "system");
    ht.put(Context.SECURITY_CREDENTIALS, new weblogic.common.T3User("system", "askpanch"));
    try {
    ctx = new InitialContext(ht);
    // Use the context in your program
    catch (NamingException e) {
    System.out.println("InitialContext could not be created");
    System.out.println("The explanation is " + e.getExplanation());
    e.printStackTrace();
    // a failure occurred
    finally {
    try {ctx.close();}
    catch (Exception e) {
    // a failure occurred
    return ctx;
    The message printed by System.out.println shows that InitialContext is created but exception is thrown when it is used by the lookup method.
    My classpath is as follows:
    CLASSPATH=C:\VisualCafeEE\Java\Lib\ERADPUBLIC.JAR;C:\VisualCafeEE\Java\Lib\servlet.jar;C:\VisualCafeEE\Java\Lib\server.jar;C:\VisualCafeEE\Bin\Components\templa
    tes.jar;C:\VisualCafeEE\Java\Lib\javax_ejb.ZIP;C:\VisualCafeEE\Java\Lib\jndi.jar;C:\VisualCafeEE\Bin\Components\vcejbwl.jar;C:\VisualCafeEE\Bin\sb;C:\VisualCafe
    EE\Bin\sb\classes\sb.jar;.;;C:\VisualCafeEE\Java\Lib;C:\VisualCafeEE\Java\Lib\SYMCLASS.ZIP;C:\VisualCafeEE\Java\Lib\CLASSES.ZIP;C:\VisualCafeEE\Java\Lib\COLLECT
    IONS.ZIP;C:\VisualCafeEE\Java\Lib\ICEBROWSERBEAN.JAR;C:\VisualCafeEE\Java\Lib\SYMTOOLS.JAR;C:\VisualCafeEE\JFC\SWINGALL.JAR;C:\VisualCafeEE\Bin\Components\SFC.J
    AR;C:\VisualCafeEE\Bin\Components\SYMBEANS.JAR;C:\VisualCafeEE\Java\Lib\DBAW.ZIP;C:\VisualCafeEE\Bin\Components\DBAW_AWT.JAR;C:\VisualCafeEE\Bin\Components\Data
    bind.JAR;C:\VisualCafeEE\Java\Lib\ERADTOOLS.JAR;;C:\IBMVJava\eab\runtime30;C:\IBMVJava\eab\runtime20;;.;c:\Weblogic\classes;c:\weblogic\lib\weblogicaux.jar
    Any help to solove this problem from anybody is greatly appreciated. I am including some other related articles in this newsgroup for your ready reference(see below).
    Thanks a lot,
    Ashok Pancharya
    Email: [email protected]
    Sounds like your WL config is a bit different, perhaps a classpath issue or
    a missing .properties file or a different command line. For whatever
    reason, the factory does not know what class is supposed to be used as the
    initial context.
    Peace.
    Cameron Purdy
    [email protected]
    http://www.tangosol.com
    WebLogic Consulting Available
    "Chris Solar" <[email protected]> wrote in message
    news:[email protected]...
    Hi-
    I'm running WLS 5.1 on NT 4.0 (SP6).
    For some reason, I'm unable to use the default
    constructor to get an initial context. That is,
    if I try:
    InitialContext ctx = new InitialContext();
    I get a NoInitialContextException, as in:
    "Need to specify class name in environment or system
    property, or as an applet parameter, or in an application
    resource file: java.naming.factory.initial"
    This does not happen if I pass in a HashTable or Properties
    object containing a value for the initial context factory
    (even if it's just weblogic.jndi.WLInitialContextFactory).
    Colleagues of mine seem to be able to use
    the defaut constructor without any problems.
    What am I missing?
    -Chris.

    Thanks Gene. Good solution. I could solve the problem which is explained in my another article posted just before a minute you posted this response.
    Thanks again.
    Ashok Pancharya
    "Gene Chuang" <[email protected]> wrote:
    According to your getWeblogicInitialContext(), you are putting ctxt.close() in a finally block,
    which will always get executed, and then returning ctxt. Don't think you can do any lookups with a
    closed Context.
    Gene Chuang
    Join Kiko.com!
    "Ashok Pancharya" <[email protected]> wrote in message news:[email protected]...
    Hi,
    I am running WLS 5.1 SP6 on Windows98. I am trying to lookup a CMP entiry bean from
    Java 1.3 client. I can successfully create the InitialContext but having trouble in using it todo the lookup. I get the following error:
    jndiContext is javax.naming.InitialContext@61f24(This is line is the result of println : see code)
    javax.naming.NoInitialContextException: Need to specify class name in environment or systemproperty, or as an applet parameter, or in an application resource file:
    java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at com.titan.cabin.Client_1.main(Client_1.java:21)
    My code of the Java 1.3 client is as follows:
    package com.titan.cabin;
    import com.titan.cabin.CabinHome;
    import com.titan.cabin.Cabin;
    import com.titan.cabin.CabinPK;
    import javax.naming.InitialContext;
    import javax.naming.Context;
    import javax.naming.NamingException;
    import java.rmi.RemoteException;
    import java.util.Properties;
    import java.util.Hashtable;
    public class Client_1 {
    public static void main(String [] args){
    try {
    InitialContext jndiContext = getWeblogicInitialContext();
    System.out.println("jndiContext is " + jndiContext);
    CabinHome home = (CabinHome)(jndiContext.lookup("CabinHome"));
    Cabin cabin_1 = home.create(1);
    System.out.println("created it!");
    cabin_1.setName("Master Suite");
    cabin_1.setDeckLevel(1);
    cabin_1.setShip(1);
    cabin_1.setBedCount(3);
    CabinPK pk = new CabinPK();
    pk.id = 1;
    System.out.println("keyed it! ="+ pk);
    Cabin cabin_2 = home.findByPrimaryKey(pk);
    System.out.println("found by key! ="+ cabin_2);
    System.out.println(cabin_2.getName());
    System.out.println(cabin_2.getDeckLevel());
    System.out.println(cabin_2.getShip());
    System.out.println(cabin_2.getBedCount());
    } catch (java.rmi.RemoteException re){re.printStackTrace();}
    catch (javax.naming.NamingException ne){ne.printStackTrace();}
    catch (javax.ejb.CreateException ce){ce.printStackTrace();}
    catch (javax.ejb.FinderException fe){fe.printStackTrace();}
    public static InitialContext getWeblogicInitialContext()
    throws javax.naming.NamingException {
    InitialContext ctx = null;
    Hashtable ht = new Hashtable();
    ht.put(Context.INITIAL_CONTEXT_FACTORY,weblogic.jndi.WLInitialContextFactory.class.getName());
    ht.put(Context.PROVIDER_URL, "t3://localhost:7001");
    ht.put(Context.SECURITY_PRINCIPAL, "system");
    ht.put(Context.SECURITY_CREDENTIALS, new weblogic.common.T3User("system", "askpanch"));
    try {
    ctx = new InitialContext(ht);
    // Use the context in your program
    catch (NamingException e) {
    System.out.println("InitialContext could not be created");
    System.out.println("The explanation is " + e.getExplanation());
    e.printStackTrace();
    // a failure occurred
    finally {
    try {ctx.close();}
    catch (Exception e) {
    // a failure occurred
    return ctx;
    The message printed by System.out.println shows that InitialContext is created but exception isthrown when it is used by the lookup method.
    My classpath is as follows:
    CLASSPATH=C:\VisualCafeEE\Java\Lib\ERADPUBLIC.JAR;C:\VisualCafeEE\Java\Lib\servlet.jar;C:\VisualCafe
    EE\Java\Lib\server.jar;C:\VisualCafeEE\Bin\Components\templa
    >
    tes.jar;C:\VisualCafeEE\Java\Lib\javax_ejb.ZIP;C:\VisualCafeEE\Java\Lib\jndi.jar;C:\VisualCafeEE\Bin
    \Components\vcejbwl.jar;C:\VisualCafeEE\Bin\sb;C:\VisualCafe
    >
    EE\Bin\sb\classes\sb.jar;.;;C:\VisualCafeEE\Java\Lib;C:\VisualCafeEE\Java\Lib\SYMCLASS.ZIP;C:\Visual
    CafeEE\Java\Lib\CLASSES.ZIP;C:\VisualCafeEE\Java\Lib\COLLECT
    >
    IONS.ZIP;C:\VisualCafeEE\Java\Lib\ICEBROWSERBEAN.JAR;C:\VisualCafeEE\Java\Lib\SYMTOOLS.JAR;C:\Visual
    CafeEE\JFC\SWINGALL.JAR;C:\VisualCafeEE\Bin\Components\SFC.J
    >
    AR;C:\VisualCafeEE\Bin\Components\SYMBEANS.JAR;C:\VisualCafeEE\Java\Lib\DBAW.ZIP;C:\VisualCafeEE\Bin
    \Components\DBAW_AWT.JAR;C:\VisualCafeEE\Bin\Components\Data
    >
    bind.JAR;C:\VisualCafeEE\Java\Lib\ERADTOOLS.JAR;;C:\IBMVJava\eab\runtime30;C:\IBMVJava\eab\runtime20
    ;;.;c:\Weblogic\classes;c:\weblogic\lib\weblogicaux.jar
    Any help to solove this problem from anybody is greatly appreciated. I am including some otherrelated articles in this newsgroup for your ready reference(see below).
    Thanks a lot,
    Ashok Pancharya
    Email: [email protected]
    Sounds like your WL config is a bit different, perhaps a classpath issue or
    a missing .properties file or a different command line. For whatever
    reason, the factory does not know what class is supposed to be used as the
    initial context.
    Peace.
    Cameron Purdy
    [email protected]
    http://www.tangosol.com
    WebLogic Consulting Available
    "Chris Solar" <[email protected]> wrote in message
    news:[email protected]...
    Hi-
    I'm running WLS 5.1 on NT 4.0 (SP6).
    For some reason, I'm unable to use the default
    constructor to get an initial context. That is,
    if I try:
    InitialContext ctx = new InitialContext();
    I get a NoInitialContextException, as in:
    "Need to specify class name in environment or system
    property, or as an applet parameter, or in an application
    resource file: java.naming.factory.initial"
    This does not happen if I pass in a HashTable or Properties
    object containing a value for the initial context factory
    (even if it's just weblogic.jndi.WLInitialContextFactory).
    Colleagues of mine seem to be able to use
    the defaut constructor without any problems.
    What am I missing?
    -Chris.

Maybe you are looking for

  • How to use ONE IPod on TWO Computers

    I have an Desktop-PC using ITunes 5.0 and an IPod 20 GB. When I connect my IPod with my Laptop, the complete IPod is deleting by the ITunes on the Laptop. How can I use ONE IPod on TWO Computers without deleting the music hole time?!

  • Error when trying to create new single user

    When I fill out the "basic", "groups", and "home" sections of single user in Workgroup Manager and then go to click "save" and error pops up ... actually 4 errors. They say: Got Unexpected Error error of type -14134 on line 487 of UserBasicPluginView

  • Collect mailmessages with attachments (xml)

    I am getting some problems to collect a mail message with a XML attachment. For this scenario I use the Sender Mail adapter and I would like to collect several mail messages with attachments for 10 minutes and put them together in one file with the F

  • Assigning DHCP address range

    I am in the process of trying to create a guest network using my airport (2nd generation). I am trying to connect my new wireless Vizio to my network... I have decifered that I can no longer use the same IP address for all devices on my network in or

  • What is the best program for playing games,dics,3d settings such as "groove setting"

    what is the best program for playing games,dics,3d settings such as "groove setting"?