Java Hashtables.

Ok, the API documentation for Java Hashtables says that they use "open hashing". This means you can store two values under the same key- the storage space for each key is in some sort of collection, and it can be added to the collection. So, basically, that implies that code such as:
java.util.Hashtable h = new java.util.Hashtable();
h.put("A", "ABC");
h.put("A", "DEF");
System.out.println(h.get("A"));
System.out.println(h.get("A"));
System.out.println(h.get("A"));
would add bot ABC and DEF to the hash key entry. Unfortunately, the get statements above all print out "DEF".
The way I would get around it would be something like this:
Hashtable h = new Hashtable();
MyClass myInstance = new MyClass(1);
//Assume that MyClass.getKey() returns the desired Key for the hashtable.
if (h.containsKey(myInstance.getKey()){
h.put(myInstance.getKey(new LinkedList(myInstance));
else{
((List)(h.get(myInstance.getKey())).add(myInstance);
(I understand that ArrayList probably isn't the most efficient collection to use here, but I'm just trying to show the basic workaround.)
I have no problem working around this, however, the API documentation for it says,
"Note that the hash table is open: in the case of a "hash collision", a single bucket stores multiple entries, which must be searched sequentially."
This implies that the Hashtable entries are coded to automatically store multiple items. But, I don't see that implemented.
In fact, if you think about it, if you have to store your own collections in the hashtable's entry table, there really isn't anything at all in the actual implementation of the hashtable class itself that makes it open.
Like I said, I have no significant opposition to implementing such a workaround, however, the API leads me to believe that hashtable is implemented in a way that doesn't require me to, although the methods contained in it seem to show otherwise.
Is there a better way? Or is the API inconsistent? Or is my interpretation of "open" and "closed" hashing off-beat?
Thanks for the help guys,
Scott

Ok, the API documentation for Java Hashtables says
that they use "open hashing". This means you can
store two values under the same key- No, not under the same key, but under the same hashCode.
the storage
space for each key is in some sort of collection, and
it can be added to the collection. So, basically,
that implies that code such as:
java.util.Hashtable h = new java.util.Hashtable();
h.put("A", "ABC");
h.put("A", "DEF");
System.out.println(h.get("A"));
System.out.println(h.get("A"));
System.out.println(h.get("A"));
would add bot ABC and DEF to the hash key entry.No, that's not correct. The key has be to unique, and "A".equals("A") == true.
Kaj

Similar Messages

  • Need a java hashtable class that is more controlable

    Hi,
    I have a C hashtable code that I can easily remove an element in some specific bucket, and in some specific position of the linked list (for conflicted elelments). Also I can strictly specify the size of the hashtable, and the total elements in the hashtable.
    However for java Hashtable class, it seems I don't have the flexibility to remove an element in some specific positions (like what I did in C) , also it seems I cannot exactly control the size of the hashtable.
    Do I really need to translate my C code hashtable to my own Java Hashtable class to fulfill what I need? Or is there any better way to do it?
    Many thanks!
    TimY.

    Sorry that I didn't explain my need clearly in the first message, let me try to do it now:
    First, I need to fix the size of the hashtable because I don't want it consume too much of the memory. In my application, for example, I hope the maximum bucket size of my hash table less than 3000. And in each bucket, there are at most 10 conflicted elements are linked together, and they will be searched sequentially.
    Second, if more elements need to be added to the hashtable but there are already 10 elements in the corresponding bucket, I would like to use some replacement algorithm like LRU, CLOCK to evict one element, and then put the new element there. This is the reason why I need to remove a specific element in a bucket.
    Third, I wish the cost for lookup, add, remove is very low.
    So should I use some other Java classes to implement my requirement, instead of using Java Hashtable class directly?
    Many thanks for your prompt replies to my first message!
    Tim.Y

  • What is the simplest way to do reverse lookup at java Hashtable

    Is there a way to reverse lookup, given the value and obtain the key?

    Your best bet would be to design that in the first place instead of trying to use the original design for something it wasn't intended to do. For example, have a second hashtable where the values from the first hashtable are the keys and vice versa.

  • Can I send a Java HashTable using IDL and CORBA?

    I have code that uses a HashTable implementation of the Map datatype. I would like to be able to send this datatype using IDL and CORBA without trying to map it to Struct, if at all possible. I have just started with this yesterday, IDL that is, have successfully run the Hello World over the network and passed a string variable instead of just the string, and would welcome any help whatsoever.
    Thanks,
    Teresa Redmond

    - Don't transfer the Hashtable at all, but writea
    server, which gives access to the Hashtableentries
    I think what Martin means is: why not let yourserver
    actually do the work with the Hashtable in itself
    instead of making the client do it?
    Yes, exactly this is what I meant. And I will
    strengthen your arguments, why building a server for
    the Hashtables would probably be the best solution. So
    first double-check, whether you can go this way,
    before reading any further!
    But anyway, if you want to look deeper into
    serialization:
    - Create an ObjectOutputStream consisting of a
    ByteArrayOutputStream:
    ByteArrayOutputStream baos = new
    ByteArrayOutputStream(100);
    ObjectOutputStream oos = new
    ObjectOutputStream(baos);where "100" is the initial size in bytes.
    - Write to this stream with
    oos.writeObject(hashtable);
    oos.flush();- Send the data as a sequence of bytes, which can be
    accessed by:
    baos.toByteArray()- on the receiving side, create an ObjectInputStream
    from the received byteArray:
    ByteArrayInputStream bais = new
    ByteArrayInputStream(byteArray);
    ObjectInputStream ois = new
    ObjectInputStream(bais);- Then read the hashtable:
    Hashtable h =
    (Hashtable)ois.readObject();This is only a very coares description of the process,
    but should just give some pointers to the basic way to
    serialization.So, in the client, I could:
    Map m = new HashMap();
    //fill m
    baosSize = m.getsizeofm();//pseudo method
    ByteArrayOutputStream baos = new ByteArrayOutputStream(baosSize);
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    oos.writeObject(m);
    oos.flush();
    baos.toByteArray()and in the server code, I could:
    ByteArrayInputStream bais = new ByteArrayInputStream(byteArray);
    ObjectInputStream ois = new ObjectInputStream(bais);
    Map mh = (HashMap)ois.readObject();is that about right? If that's the case, how do I write the idl file? is this a string? say, "string baos;"?
    Thanks, guys, I really appreciate your help!

  • Java HashTable Help

    Hi, I am writing my own HashTable. I have the concept, and feel like my code "should" work but there's problems that are popping up that I can't pinpoint. I have test cases where I add to my HashTable, that seems to work ok. The problem is getting and removing. On some gets() the return data is right, other times null is returned when data should be. The same goes for remove. Below I have put the basic code used to take care of these three methods. I wrote my own HashNode also that contains everything the basic LLNode contains, plus a key. I think the problems are strictly in this class.
       * hTable is variable for a HashTable
       private HashNode[] hTable;
       * The constructor takes in an int that is the size
       * of the array and initialize the array to the given size.
       * @param sizeIn
       public HashTable(int sizeIn) {
           hTable = new HashNode[sizeIn];
       } //end of HashTable(int) Constructor
       * getHashKey() method narrows down the size of the hashtable
       * to a smaller size array.
       * @param key
       * @return int
       private int getHashKey(Object key) {
           return Math.abs(key.hashCode()) % hTable.length;
       } //end of getHashKey(Object) method
       * add is a method that will add data to an appropriate
       * location.  The location is found by using the
       * key passed in
       * @param key
       * @param data
       public void add(Object key, Object data) {
           HashNode temp = new HashNode(key, data);
           int index = getHashKey(key);
           if(hTable[index] == null)
          hTable[index] = temp;
           else {
          temp.setNext(hTable[index]);
          hTable[index] = temp;
           } //else
       } //end of add(Object, Object) method
       * get() method will return the data associated
       * with the given key.  If the data is not found
       * null is returned
       * @param key
       * @return Object
       public Object get(Object key) {
         Object result = null;
         int index = getHashKey(key);
         HashNode current = hTable[index];
         while(current != null && !current.getKey().equals(key)) {
           current = current.getNext();
         } //while
         if(current == null)
           return current;
         else
           return current.getData();
      } //end of get(Object) method
       * remove method will remove a HashNode from the HashTable
       * and the node removed will be the Node that contains the
       * key.  The data of the Node deleted will be returned.  If
       * no HashNode is in the HashTable with the key, null is returned
       * @param key
       * @return Object
      public Object remove(Object key) {
         Object result = null;
         int index = getHashKey(key);
         if(this.hTable[index] != null) {
           if(this.hTable[index].getKey().equals(key)) {
          result = this.hTable[index].getData();
          this.hTable[index] = this.hTable[index].getNext();
           } //if
           else {
          HashNode temp = hTable[index];
          while(temp.getNext() != null &&
                !temp.getNext().getKey().equals(key)) {
            temp = temp.getNext();
          } //while
          if(temp.getNext() == null)
            result = null;
          else {
            result = temp.getNext().getData();
            temp.setNext(temp.getNext().getNext());
          } //else
           } //else
         } //if
          return result;
       } //end of remove(Object)  As stated, I make a new HashTable, add with the parameters, but for my tests the first two gets return null, then it returns a right one, then two null, then two right. The more the tests the more sporadic the rghts and nulls show up. Thanks in advance.

    I you don't have a debugger, why don't you just write a dump() method that prints the whole structure. Call dump() after every add and remove. You'll immediately see when and where it goes wrong.

  • Casting Cf struct in Hashtable Java

    Hi;
    i need to convert a Coldfusion Struct in a Java Hashtable (as
    th CFMX manual tell);
    I have this java class:
    public class Pratica {
    private java.util.Hashtable my;
    public Pratica(){
    my=null;
    public Pratica(java.util.Hashtable dbprop){
    my=dbprop;
    public void set(java.util.Hashtable dbprop){
    my=dbprop;
    and in the CF page i have this code:
    <cfset ma = createObject("java","java.util.Hashtable")>
    <cfset ma.init(glb)> // glb is a struct
    <cfobject action="CREATE" type="JAVA" class="Pratica"
    name="pra">
    <cfset pra.init(ma)>
    but when i run...:
    "Unable to find a constructor for class Pratica that accepts
    parameters of type ( java.util.Hashtable )."
    I'm waiting your suggestions!!!
    thanks to all
    Andrea
    ps:sorry for my english.

    There does not seem to be a constructur for Hashtable that
    accepts a CF structure as a parameter. Take a look at the java
    documentation:
    http://java.sun.com/j2se/1.4.2/docs/api/java/util/Hashtable.html#Hashtable(int,%20float)
    Given, I haven't tried to go from CF struct to hashtable
    before - could you do something like this?
    1) Initialize an empty Hashtable
    <cfset myHashTable=
    createObject("java","java.util.Hashtable")>
    <cfset myHashTable.init()>
    2) loop over the CF structure collection and call the
    Hashtable's put() method to populate the hashtable
    <cfloop collection="#glb#" item="key">
    <cfset myHashTable.put(key, glb[key])>
    </cfloop>

  • Bug in Hashtable put?

    Hi,
    I am not sure if I just found a bug in java.util.Hashtable, but take a look at
    http://img112.imageshack.us/my.php?image=hashtablebug4je.png
    As you can see this Hashtable has a size of 5, but only 4 entries. The reason for this is the fact, that the last (fifth) put operation replaced the element at index 2. Any ideas how this can happen??
    Interestingly, the front end of my system finds the entries "kdSucheSortierkriterium", "kdSucheKonzernName", "kdSucheKonzernNr" (the item placed first at index 2) and "kdSucheKundeName". Gotta figure this one out; anyway the behaviour described above seems to occur independently from my system, as I only call (Hashtable).put.
    Any idea would be helpful...
    btw, "kdSucheKonzernName" etc. are the keys used in the Hashtable.

    Btw, unless you are debugging java.util.Hashtable (which you shouldn't do) you should have no need to look at the internals of Hashtable. And if you do, make sure that you check how a Hashtable is implemented, specifically how collisions are handled (hint: there are several possible strategies, the Java Hashtable uses a linked list).

  • Over riding hashtable get and put method

    Hi all
    Anyone have any idea about over ride HashTable get() and put(). Is it possible to over ride HashTable methods.

    Yes_me wrote:
    I want to change the structure of the java HashTable get and put method. As put method is having two object parameters I want to send one more parameter as String to it. Is it possible to change the structure in this way.What would you want to be returned when calling get()? I would go with the suggestion to create a class to keep that information. If you really want to, you can completely hide that information class inside your extended HashTable. You could create an overloaded put method that takes three parameters and then creates an instance of the information class and put that into the map. If you only want the data for display only, the get method could get the information class mapped to the given key, then simply return a nicely formatted String containing the two values.

  • Java Hash Collision Denial Of Service Vulnerability

    There is Java Hash Collision Denial Of Service Vulnerability according to these sources:
    http://tomcat.10.n6.nabble.com/SECURITY-Apache-Tomcat-and-the-hashtable-collision-DoS-vulnerability-td2405294.html
    http://www.nruns.com/_downloads/advisory28122011.pdf
    http://www.securityfocus.com/bid/51236
    It mentions that Oracle is not going to release the fix for Java. Does anyone knows if Oracle has any plan to release the fix or intend to ever fix it or not?
    Thanks,
    kymeng
    Edited by: user6992787 on Feb 10, 2012 12:08 PM

    I don't really see this as an Oracle problem - more a Tomcat problem. Any collection algorithm will have limitations and in this case the Tomcat team use the Java hashtable to make use of the O(1) performance when the hashes of the keys are effectively random and have accepted the possible worst case O(n^2) performance. Either they should have used a TreeMap with O(nlogn) performance OR they should create their own implementation of Map that that does not permit the DOS attack.
    I have never done any performance comparisons between HashMap and TreeMap but for many years now I pretty much always use a TreeMap since I rarely find performance a significant problem (of course I don't write high throughput applications such as Tomcat). I don't really see how Oracle should be involved in this problem; maybe the Tomcat team should be doing performance comparisons and/or research into algorithms that do not allow this DOS.

  • XML or Hashtable

    Hi
    Which is better, data in an XML file or Hashtable?

    If you want to send data to a different application then XML is going to be more practical. The other application might not even be written in Java, and wouldn't know what to do with a Java Hashtable.
    However if the other application already exists then you don't have this question. You should ask what the other application will accept. If you are just asking about "other applications" in general then don't. Ask the specific question when you know what the other application is.

  • Converting a hashtable to an array (CORBA sequence)

    Hi all,
    I wish to convert the contents of a hashtable to an array (well a CORBA sequence), but I am having a bit of trouble.
    I have a CORBA struct called 'Equipment', and an unbounded sequence of Equipment structs called 'EquipmentList':
              struct Equipment {
                   string name;
                   string description;
              typedef sequence<Equipment> EquipmentList;I have a Java hashtable called equipmentList which contains a list of equipment with key 'name' and corresponding value of 'description'.
    The following code is trying to convert from the hashtable to the CORBA sequence:
              Equipment equipList[] = new Equipment[equipmentList.size()]; // make sequence same size as hashtable.
              for (int i = 0; i < equipmentList.size(); i++) {
                   equipList[i] = new Equipment(); // make element a valid 'Equipment' object.
                   equipList.name = equipmentList.name; // give each sequence element value 'name' the value of the hashtable key value 'name'
                   equipList[i].description = equipmentList.description; // same with 'description' value
    I know the conversion is completely wrong, and it obviously brings up 2 errors a compile time:HireCompanyServer.java:81: cannot find symbol
    symbol : variable name
    location: class java.util.Hashtable
    equipList[i].name = equipmentList.name;
    ^
    HireCompanyServer.java:82: incompatible types
    found : java.lang.Object
    required: java.lang.String
    equipList[i].description = equipmentList.get(equipList[i
    ].name);
    ^
    Note: Some input files use unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    2 errors
    I know this might be a long-winded question, but I am having real difficulty fixing this, and would kindly appreciate some more advanced programmers to give me any hints or fixes for my code.
    Thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    JonBetts2004 wrote:
    I know this might be a long-winded question, but I am having real difficulty fixing this, and would kindly appreciate some more advanced programmers to give me any hints or fixes for my code.Not quite sure how 'struct' got in there, but unless you're using generics to set up your HashTable, you have to cast anything you get from your list to the correct type. Have a look at the HashTable method list and I think you'll work out what you want.

  • How to define Hashtable values, when the hashtable automatically grows?

    I have two hashtables in my code:
    Hashtable<String, Vector<SellerData>> productList
    Hashtable<String, Vector<String>> sellerList
    These hashtables are member variables of a class and they are defined in the constructor of that class. Also in the same constructor, there are loops that allocate memory for the vectors in these hashtables. However, the capacity of Java hashtables are automatically increased as more elements are inserted, I'm wondering how I can make sure Vectors in these newly added hashtable slots are also defined and have memory allocated for them?
    My current solution is that the user code does some checking to make sure vectors in above hashtables are defined, but I was wondering if there is some other way I could do this so the user code does not have to do any checking?
    Thanks,
    P.

    A few notes:
    1) Even though you assign a value to an attribute in the constructor, do NOT assume it will be assigned a value in your methods. Polymorphism will bite your behind on this one. Say you have the following class setup:class A {
      Integer a;
      public A() { X(); }
      public X() { // init code }
    class B extends A {
      public B()  { super(); a = new Integer(0); }
      public X() { System.err.println( a.toString() ); }
    }This will cause an exception since the constructor for B calls the constructor for A which calls B.X BEFORE you set a. Can't tell you how difficult it was to track this one down the first time it happened to me.
    But to your question! It is impossible unless you implement an extension for Hashtable as follows
    class MyHash extends Hashtable {
      // setup as a Hashtable<String, Vector> in constructor.
      public get(Object key) {
        Object ret = super.get( key );
        if ( ret = null )
          return new Vector();
        else
          return ret;
      // similar code for entrySet() and values()
      // if you need non-null values for these methods too.

  • Hashtable data to JavaScript

    Hi
    I need someone's help for the below scenario.
    I have a JavaScript variable(string). Based on the value of this, I need to select an item(ArrayList object) from a java Hashtable which contains key(countryName) and corresponding states(ArrayList).
    My requirement is:
    when I select an item(countryName) in the Dropdown1, Dropdown2 should display the list of corresponding states(ArrayList). I am trying to do this, by calling a method on the event "onChange" of Dropdown. But I am struggling to get the respective state list based on the country value.
    Thanks.

    If you don't want to use AJAX then another way is we need to set javascript hash using java hash.
    Below is a example of it. Might you get some help.
    <%
        Hashtable ht = new Hashtable();
        List l1 = new ArrayList();
        l1.add("city1");
        l1.add("city2");
        ht.put("a", l1);
        List l2 = new ArrayList();
        l2.add("city3");
        l2.add("city4");
        ht.put("b", l2);
    %>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
            <script type="text/javascript">
                var myHash = {};
                <%
                    Iterator it = ht.keySet().iterator();
                    while(it.hasNext())
                        String key = String.valueOf(it.next());
                        List l = (List)ht.get(key);
                        %>
                        myHash['<%= key%>'] = '<%= Arrays.toString(l.toArray(new String[l.size()]))%>';
                        <%
                %>
                function getCities(objSel)
                    if(objSel.value.length > 0)
                        alert(myHash[objSel.value])
            </script>
        </head>
        <body onload="alert(myHash);">
            <select onchange="getCities(this)">
                <option value="">Select One</option>
                <option value="a">a</option>
                <option value="b">b</option>
            </select>
        </body>
    </html>

  • How do we get a hashtable from a webservice?

    Hi,
    I want to get a Hashtable result from a webservice. I want to develop a webservice which recieves some company name, It has to display the list of users in that company and the result should be Hashtable. So I have to get a Hashtable as my webservice result?
    Actually I tried with apache axis, eclipse, tomcat giving the following error as no Deserializor found.
    So help to solve this problem....
    Regards,
    Kumar.
    [email protected]
    Client Code is as follows:
    String targetNamespace = "http://192.168.1.165:8080/GP_USER/services/Validation";
              try {
                   /* Service lookup */
                   ServiceFactory serviceFactory = ServiceFactory.newInstance();
                   javax.xml.rpc.Service service = serviceFactory
                             .createService(new QName(targetNamespace,
                                       "UserValidationService"));
                   Call call = (Call) service.createCall();
                   QName qn = new QName("http://bean.getprice.hgv.com", "tns1:UserDetails");
                   call.setProperty(Call.ENCODINGSTYLE_URI_PROPERTY, "");
                   call.setProperty(Call.OPERATION_STYLE_PROPERTY, "document");
                   // call.setProperty(Call.SOAPACTION_USE_PROPERTY, "literal");
                   call.setTargetEndpointAddress("http://192.168.1.165:8080/GP_USER/services/Validation");
                   call.removeAllParameters();
                   call.setPortTypeName(new QName(targetNamespace, "Validation"));
                   call.setOperationName(new QName(targetNamespace, "displayUsers"));
                   if (call.isParameterAndReturnSpecRequired(call.getOperationName())) {
                        call.addParameter("in0", new QName(
                                  "http://www.w3.org/2001/XMLSchema", "string"),
                                  String.class, javax.xml.rpc.ParameterMode.IN);
                        call.registerTypeMapping(UserDetails.class, qn, new BeanSerializerFactory (UserDetails.class, qn),
                        new BeanDeserializerFactory (UserDetails.class, qn));
                        //call.setReturnType(new QName("http://www.w3.org/2001/XMLSchema", "struct"));
                        QName qVec=new QName("http://www.w3.org/2001/XMLSchema","mapItem");
                        call.setReturnType(qVec);
                   /* Service invocation */
                   comp_name ="ggp";
                   //Hashtable ht = (Hashtable) call.invoke(new Object[] {comp_name});
                   System.out.println(call.invoke(new Object[] {comp_name}));
                   Enumeration e = ht.keys();
                   UserDetails ud;
                   while( e. hasMoreElements() ){
                   ud = (UserDetails) e.nextElement();
                   System.out.println(ud);

    You have to remember that when sending data over a WS using SOAP, you are essentially sending the objects as XML (text). Therefore, when you want to transfer a java Hashtable or any other java object, it must be serialized into into text form at serverside, sent over the network, and finally deserialized from text into the Hashtable at the clientside.
    You cannot just send arbitrary Java objects over a WS and expect Axis to understand them. Axis only maps a subset of XML basic datatypes of java objects. For example, Axis understands boolean, int, byte, etc. But for any object that Axis does not natively understand, you must create a custom serializer/deserializer to transfer complex java objects.
    The issue at hand is interoperability. Look at the link below. In particular, look at the section called "What Axis can send via SOAP with restricted Interoperability"
    http://ws.apache.org/axis/java/user-guide.html#XMLJavaDataMappingInAxis

  • [b]EJB Hotel RA Client Error - HELP[/b]

    1. Travel schema installed fine
    2. Web Client can successfully be run and all the buttons
    work fine
    3. The only file I modified was in config properties.
    Provider_Url = ormi://localhost:8888/OneEJBHotel
    4. in oc4j directory: principals file:
    user id is "admin", and password was given as
    "admin"
    4. deployment from jdeveloper is fine as follows:
    ---- Deployment started. ---- Jan 24, 2003 6:24:08 PM
    Wrote EJB JAR file to C:\oc4j\samples\ejb\OneEJBHotel\src\oracle\otnsamples\OneEJBHotel\OneEJBHotel.jar
    Wrote WAR file to C:\oc4j\samples\ejb\OneEJBHotel\src\oracle\otnsamples\OneEJBHotel\OneEJBHotel-Web.war
    Wrote EAR file to C:\oc4j\samples\ejb\OneEJBHotel\src\oracle\otnsamples\OneEJBHotel\OneEJBHotel-Web.ear
    Invoking OC4J admin tool...
    C:\jdeveloper\jdk\jre\bin\javaw.exe -jar C:\jdeveloper\j2ee\home\admin.jar ormi://DLEE/ admin **** -deploy -file C:\oc4j\samples\ejb\OneEJBHotel\src\oracle\otnsamples\OneEJBHotel\OneEJBHotel-Web.ear -deploymentName OneEJBHotel
    Auto-unpacking C:\oc4j\j2ee\home\applications\OneEJBHotel-Web.ear... done.
    Auto-unpacking C:\oc4j\j2ee\home\applications\OneEJBHotel-Web\OneEJBHotel-Web.war... done.
    Copying default deployment descriptor from archive at C:\oc4j\j2ee\home\applications\OneEJBHotel-Web/META-INF/orion-application.xml to deployment directory C:\oc4j\j2ee\home\application-deployments\OneEJBHotel...
    Auto-deploying OneEJBHotel (New server version detected)...
    Exit status of OC4J admin tool (-deploy): 0
    C:\jdeveloper\jdk\jre\bin\javaw.exe -jar C:\jdeveloper\j2ee\home\admin.jar ormi://DLEE/ admin **** -bindWebApp OneEJBHotel OneEJBHotel-Web http-web-site /OneEJBHotel
    Exit status of OC4J admin tool (-bindWebApp): 0
    Use the following context root(s) to test your web application(s):
    http://DLEE:8888/OneEJBHotel
    Elapsed time for deployment: 14 seconds
    ---- Deployment finished. ---- Jan 24, 2003 6:24:22 PM
    5. System Configuation
    jdeveloper: 9.0.3.1035
    DB: oracle 92010
    oc4j: 9.0.3.0.0
    6. When run from jdeveloper client: run Client.jpr
    the following errors were generated:
    Process exited with exit code 0.
    C:\jdeveloper\jdk\bin\javaw.exe -ojvm -classpath C:\oc4j\samples\ejb\OneEJBHotel\src\classes;C:\oc4j\samples\ejb\OneEJBHotel\config;C:\oc4j\samples\ejb\OneEJBHotel;C:\oc4j\samples\ejb\OneEJBHotel\src\web;C:\jdeveloper\jdev\lib\jdev-rt.jar;C:\jdeveloper\j2ee\home\lib\activation.jar;C:\jdeveloper\j2ee\home\lib\ejb.jar;C:\jdeveloper\j2ee\home\lib\jaas.jar;C:\jdeveloper\j2ee\home\lib\jaxp.jar;C:\jdeveloper\j2ee\home\lib\jcert.jar;C:\jdeveloper\j2ee\home\lib\jdbc.jar;C:\jdeveloper\j2ee\home\lib\jms.jar;C:\jdeveloper\j2ee\home\lib\jndi.jar;C:\jdeveloper\j2ee\home\lib\jnet.jar;C:\jdeveloper\j2ee\home\lib\jsse.jar;C:\jdeveloper\j2ee\home\lib\jta.jar;C:\jdeveloper\j2ee\home\lib\mail.jar;C:\jdeveloper\j2ee\home\oc4j.jar oracle.otnsamples.OneEJBHotel.client.EJBHotelSample
    javax.naming.NamingException: Lookup error: java.io.IOException: Server protocol was not ORMI, if uncertain about the port your server uses for ORMI then use the default, 23791; nested exception is:
         java.io.IOException: Server protocol was not ORMI, if uncertain about the port your server uses for ORMI then use the default, 23791
         java.lang.Object com.evermind.server.rmi.RMIContext.lookup(java.lang.String)
              RMIContext.java:134
         java.lang.Object javax.naming.InitialContext.lookup(java.lang.String)
              InitialContext.java:350
         void oracle.otnsamples.OneEJBHotel.client.EJBHotelSample.getHotelSystemBean()
              EJBHotelSample.java:132
         void oracle.otnsamples.OneEJBHotel.client.EJBHotelSample.main(java.lang.String[])
              EJBHotelSample.java:147
    Process exited with exit code 0.
    Thanks for help!
    David

    David,
    config.properties is used only by the client.jpr. Not by the Web.jpr
    config.properties file has been provided for looking up resources[EJB, Datasources] from JNDI tree of OC4J.
    Since servlet and other resources are in the same container[Single JVM] there is no need to specify the username, password, Provdier_URL at the time of lookup.
    Look at the init method of EJBHotelServlet.java :
    Context ctx = new InitialContext();
    // Acquire the home interface handle and call the create
    //method on it
    homeInterface = (HotelSystemHome)ctx.lookup("OneEJBHotel");
    Here servlet looks up EJB without any authentication information, as servlet and EJB are in the same container.
    Whereas Stand alone client is running outside the OC4J.
    So the stand alone client need to authentcate itself for looking up the resources from JNDI tree.
    Look at the getHotelSystemBean method of EJBHotelSample.java :
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, prop.getProperty("Initial_Context_Factory"));
    env.put(Context.SECURITY_PRINCIPAL, prop.getProperty("Principal"));
    env.put(Context.SECURITY_CREDENTIALS, prop.getProperty("Credential"));
    env.put(Context.PROVIDER_URL, prop.getProperty("Provider_Url") );
    // Associate the properties with the context
    Context ctx = new InitialContext(env);
    // Acquire the home interface handle and call the create
    //method on it
    homeInterface = (HotelSystemHome)ctx.lookup("OneEJBHotel");
    Here stand alone client looks up EJB by specifying the authentication information, as stand alone client and EJB are running in different JVM's.
    Hope this helps...
    Cheers
    --Venky                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Maybe you are looking for

  • Commitment item error at the time of Service entry Sheet

    Hi experts, I have created a service PO, in which I have given the GL. Now when I am going to post the service entry sheet, I am changing the GL account. But system is picking the commitment item with reference to the GL earlier provided in PO. I wan

  • DVD drive sharing issue

    Hi, how can I create my music library in iTune (to sync with my iPod) on my Macbook Air since remote DVD sharing from my other Macs does not let me do it? Apple selling point for not having a DVD drive on the Macbook Air is that you can use DVD drive

  • Problem With Cutom Configuration with Object Type

    Dear Guru's I am working WebUI, I am facing a problem with Custom Configuration. 1. The initial requirement to control the visibility for a dropdown event in ERP Quotation. 2. To this i copied the default configuration to custom configuration with cu

  • Audio Capture problem in Mac OS X 10.7.5 in Mac mini(in Silverlight)

    I got a mac mini and upgrade Mac OS X 10.6.x --> 10.7.5. However do not hearing the audio in Webpage using Silverlight.(10.6. version doing well) So, I found the solve this problem, that is a audio capture problem.( My device does not supported Stere

  • Hp pavilion all in one

    i cannot get my microsoft open says wrong password