Type of hashtable...

I want to create a hash table having following schema:
for a given tableSize, it creates array of Object class of length tableSize. Every Object in array is actually Vector, to implement binary tree.
here is sample code:
public static class Room extends Object{
        Vector _node = new Vector(); //every room contains a vector, for binary tree implementation
        public Room(){
        public int insert(int element){
        int index=0;
        //code here
        return index;
        //gets and sets here...
}Here how i create this array:
int tableSize = 7;
Room[] hashTable= new Room[tableSize];
int nodeNumber = hashTable[integerToInsert%tableSize].insert(integerToInsert);Problem is, the last line gives NullPointerException :(
What am I doing wrong? I feel a stupid mistake...

I am not reinventing hash table, but creating some "mutant" on purpose. I need to stay Vector and Room class. However, Room class can inherit whatever, but it must support
Room[] hashTable= new Room[tableSize];Moreover, I don't want to use any ready classes like java.util.Map, because with all types of key-value problems, collusions want to deal for myself.

Similar Messages

  • Hashtables and Objects, ugly.

    Let's see...
    I'll give you everything, then highlight problems.
    package Analyze;
    import java.io.*;
    import java.util.*;
    public class Work {
        public static int Operate(String directory, String filename, String directory2, String filename2, String ext, int number) {
            int sum=0;
            try{
                BufferedWriter out = new BufferedWriter(new FileWriter(directory+filename));
                BufferedReader in = new BufferedReader(new FileReader(directory2+filename2+ext));
                String str;
                int b;
                int w;
                int low=10000;
                int high=0;
                int count=0;
                Hashtable table=new Hashtable();
                while ((str = in.readLine()) != null) {
                    if  ((w=str.indexOf("Total Run Time"))>0)
                    {w=str.indexOf("Total Run Time");
                     String substr=str.substring(0, w-1);
                     String change="<TH>";
                     String newString=Replace.replace(str,substr,change);
                     int z=newString.indexOf(":");
                     String substr2=newString.substring(0, z+2);
                     String change2="";
                     String finalString=Replace.replace(newString, substr2, change2);
                     int i = Integer.parseInt(finalString);
                     int q=1;
                     if (table.get(new Integer(i))==null)
                        {table.put(new Integer(i),new Integer(q));}
                     if (table.get(new Integer(i))!=null)
                        {int v=Integer.parseInt(table.put(new Integer(i),new Integer(q)));
                         v=v+q;
                         table.put(new Integer(i), new Integer(v));
                     if (i>high)
                         high=i;
                     if (i<low)
                         low=i;
                     sum+=i;
                     count++;
                BufferedWriter instances = new BufferedWriter(new FileWriter("C:\\development\\test\\test_Local\\archives\\number"+Date.whatMonth()+Date.whatDay()+Date.whatYear()+"test"+number+".txt"));
                for (int n=0; n<=high; n++)
                    { if (table.get(new Integer(n))!=null)
                      {instances.write(table.get(new Integer(n))+" threads took "+n+" seconds.");
                        instances.flush();}
                instances.close();
                String strSum=""+sum;
                String strLow=""+low;
                String strHigh=""+high;
                double average=(double)sum/count;
                String strAverage=""+average;
                String strCount=""+count;
                out.write("<HTML> <BODY>");
                out.write("<P>These are the results of the stress test conducted for: "+Date.whatMonth()+"-"+Date.whatDay()+"-"+Date.whatYear()+"<P>");
                out.write("<BR><I>Total number of users ----- </I>"+strCount+" <B>(Note: This number is number of users multiplied by number of cycles.)</B>");
                out.write("<P><B>Time to complete in seconds: </B>"+strSum);
                out.write("<BR><B>The quickest thread took</B> "+strLow+" <B>seconds.</B>");
                out.write("<BR><B>The longest thread took</B> "+strHigh+" <B>seconds.</B>");
                out.write("<BR><B>The average is </B>"+strAverage+" <B>seconds.</B>");
                out.write("<P><P>The corresponding log file is: <a href=archives/"+filename2+Date.whatMonth()+Date.whatDay()+Date.whatYear()+".txt> Located in the archives bin. </A>");
                out.write("<P><P>The list of times and their instances is located :<a href=archives/number"+Date.whatMonth()+Date.whatDay()+Date.whatYear()+"test"+number+".txt> here </A>");
                NewFile.MakeFile(directory, "testlist.html");
                BufferedWriter lister = new BufferedWriter(new FileWriter(directory+"testlist.html", true));
                String strNum=""+number;
                lister.write("<a href="+filename+">Results from: "+Date.whatMonth()+"-"+Date.whatDay()+"-"+Date.whatYear()+"(Test number: "+strNum+")</A><P>");
                lister.close();
               /* File file=new File(directory+filename2);
                int compare=1;
                if (file.exists())
                {BufferedReader text = new BufferedReader(new FileReader(file));
                 String stuff;
                 if( (stuff=text.readLine())!=null)
                     compare=Integer.parseInt(stuff);
                 text.close();
                float second=((compare/sum)-1)*100;
                int benchmark=1500;
                float third=((benchmark/sum)-1)*100;
                String strThird;
                String strSecond;
                if (second < 0)
                    strSecond="<font color=red>"+second+"% </font>";
                else strSecond=""+second+"% ";
                if (third < 0)
                    strThird="<font color=red>"+third+"% </font>";
                else strThird=""+third+"% ";
                out.write("<BR><B>Compared to yesterday, there has been a </B>"+strSecond+"<B>change</B> (Note: Positive values shows the processes being done faster. Negative values demonstrate a dropoff in performance.)");
                out.write("<BR><B>Compared to the benchmark, there has been a </B>"+strThird+"<B>change</B> (Note: Positive values shows the processes being done faster. Negative values demonstrate a dropoff in performance.)");*/
                out.write("</BODY></HTML>");
                in.close();
                out.close();
                /* BufferedWriter cout = new BufferedWriter(new FileWriter("C:\\development\\test\\test_Local\\archive"+Date.whatMonth()+Date.whatDay()+".txt"));
                cout.write(strSum);
                cout.close(); */
               File fil = new File(directory2, filename2+ext);
                if (fil.exists()==false)
                    System.out.println("File doesn't exist!");
                File archive = new File("C:\\development\\test\\test_Local\\archives\\");
                if (archive.exists()==false)
                {archive.mkdir();
               /* File other=new File("C:\\development\\test\\test_Local\\archives\\"+filename2+Date.whatMonth()+Date.whatDay()+Date.whatYear()+".txt");
                boolean success= fil.renameTo(new File(archive, other.getName()));
                if(!success)
                {System.out.println("Could not move file");*/
            catch (IOException e)
            {System.out.println(e);}
            number++;
            return number;
    }Now, I don't really understand hashtables, so this may be completely wrong. However, here's the goal:
    I'm taking in a ton of ints, ranging from 1 to infinity. I want to create a hashtable which has the integer as the key, and the number of times it has come up as its value. Now, if an integer comes up more than once, I need to increase the value, I can't just throw it out. However, the hashtable keeps telling me that if I'm getting the value from a key I select and trying to put it into a new int, I'm an idiot because the value is of type Object. Now, how are objects going in, and not ints? Is my compiler just being crazy, or is it me?
    Also, is it necessary to create new Integers everytime I use a method from the hashtable? I haven't gotten past the compiling stage, so I don't know how the execution will go...
    Please note, everything except for the hashtable works. I have a classes that handle almost everything else, so Date.whatMonth() is really a valid command ;) Everything that's commented out is because I haven't completed the feature. Don't worry about that stuff.

    Okay, let's start with the return type.
    Hashtable.get(key) returns a value of type Object, as I'm sure you've noticed. It does this because that's as much as it can guarantee about the returned data; it could be any kind of Object, depending on what you put in. Java, however, remembers what kind of Object it is and stores its type internally.
    Thus...
    Object o = new Integer(1);
    System.out.println(o.intValue());...is illegal. Object.intValue() doesn't exist, and that's what you're asking it to do. However...
    Object o = new Integer(1);
    System.out.println(o.hashCode()); // legal because Object.hashCode() exists
    System.out.println( ((Integer)o).intValue() ); // legal because the Object was constructed as an Integer
    System.out.println( ((Short)o).shortValue() ); // throws a ClassCastException because the Object was not constructed as a ShortThus, all you need to do is recast the return value of Hashtable.get(Object) to the type that you know it should be. For example,
    Integer integer = (Integer)(my_hashtable.get(key_that_maps_to_integer));...is legal.
    Now, as for creating Integers every time... well, you probably shouldn't. I would recommend creating the following class to use as the value and the key. Note, however, that any object you create that is used as the key in a Hashtable should probably override the equals(Object) and hashCode() methods of Object.
    public class MutableInteger
        protected int m_value;
        public MutableInteger(int base)
            m_value = base;
        public int getValue()
            return m_value;
        public void setValue(int new_value)
            m_value = new_value;
        public int hashCode()
            // This must be done or all of the keys will map to the same hash code.  That would reduce the performance of the Hashtable to a linked list!
            return m_value;
        public boolean equals(Object o)
            // This must be done because, without it, no two MutableIntegers will be considered the same.
            if (o instanceof MutableInteger)
                // If the other MutableInteger has the same internal value, consider it legal.
                return (  ((MutableInteger)o).getValue() == m_value );  // Note the use of casting here.  instanceof has guaranteed that this cast is legal.
            } else
                // If the Object isn't a MutableInteger, it can't be equal to this one.
                return false;
    }Now, your code would read...
    MutableInteger key_object = new MutableInteger(0);   // Use as the key
    MutableInteger value_object = null;
    Hashtable table=new Hashtable();
    while ((str = in.readLine()) != null) {
        if ((w=str.indexOf("Total Run Time"))>0) {
            w=str.indexOf("Total Run Time");
            String substr=str.substring(0, w-1);
            String change="<TH>";
            String newString=Replace.replace(str,substr,change);
            int z=newString.indexOf(":");
            String substr2=newString.substring(0, z+2);
            String change2="";
            String finalString=Replace.replace(newString, substr2, change2);
            int i = Integer.parseInt(finalString);
            int q=1;
    /*new*/ key_object.setValue(i);
    /*dif*/ if (table.get(key_object)==null) {
    /*dif*/     table.put(key_object,new MutableInteger(q))  // Created as a MutableInteger.  The Hashtable won't remember, but the JVM will.
    /*new*/     key_object = new MutableInteger(0);  // Because the old one now belongs to the table.
    /*dif*/ if (table.get(key_object)!=null) {  // Won't this always be true?  You just put a value in there.
            // Am I correct in understanding that this code is designed to increase the value stored in the table by "q"?  If so, use the following code.
    /*new*/     value_object = (MutableInteger)(table.get(key_object));  // Note the cast.  We know that the Object returned was constructed as a MutableInteger; after all, we put it there.
    /*new*/     value_object.setValue(value_object.getValue()+1);
    /*new*/     table.put(key_object,value_object);
            if (i>high) high=i;
            if (i<low) low=i;
            sum+=i;
            count++;
    }Good luck, and have fun! ;)

  • Finding the min value in a hashtable

    Hi,
    I'm trying to work out the lowest value contained in a hashTable. So far I've got.
    import java.util.Enumeration;
    import java.util.Hashtable;
    import java.util.Vector;
    public class StoreValuesDouble extends Statistic {
          * Each object of the class (StoreValuesDouble) will have these attributes.
          * When you call the StoreValuesDouble class you can use
          * myDoubleValues (a Vector holding Double types),
          * Hashtable (a Hashtable using Double types as values and keys) and
          * nullValues (an Double currently set to 0.0).
         Vector<Double> myDoubleValues; //declare a variable myDoubleValues that is of data type Vector
         Hashtable<Double, Double> myValues; //declare a variable myvalues that is a data type Hashtable
         Double nullValues = 0.0; //Double attribute to count the number of null values contained in the vector
          * pass myDoubleValues to inValues
          * @param Vector /<Double/> a vector holding Double values
          * @param inValues the values in the vector
          * @return
         public void DoubleStat(Vector<Double> inValues) {
              myDoubleValues = inValues;
          * calculate the mean of myDoubleValues
          * @return mean of myDoubleValues as a double
         public double meanDouble() {
              double mean = 0;
              Double currentDouble;
              double nonNull = 0;
              for (double j = 0; j < myDoubleValues.size(); j++)
                   currentDouble = myDoubleValues.elementAt((int) j);
                   if (currentDouble != null) {
                        mean += currentDouble.doubleValue();
                        nonNull++;
              return mean / nonNull;
          * calculate the standard devitation of myDoubleValues
          * @return standard devitation of myDoubleValues as a double
         public double standardDeviationDouble() {
              double m = meanDouble();
              double t = 0.0;
              Double currentDouble;
              double n = 0;
              for (double j = 0; j < getDoubleValues(); j++) {
                   currentDouble = myDoubleValues.elementAt((int)j);
                   if (currentDouble != null) {
                        n = currentDouble.doubleValue();
                        t += (n - m) * (n - m);
              return Math.sqrt(t / (myDoubleValues.size() - 1.0));// n - 1 as sample varience
          * return the number of values of myDoubleValues to help calculate the mean & standard deviation
          * @return the size of myDoubleValues as a Double
         public double getDoubleValues() {
              return myDoubleValues.size();
          * compute the number of null values
          * @return a double value representing the number of null values
         public Double getDoubleNull() {
              Double nbNull = 0.0;
              // test if myIntValues is null
              if (myDoubleValues == null) {
                   System.out.println("Please enter values that are not null!");
                   return 0.0;
              // if not null, parse all values
                   // for each value, test if it is null or not
                   Double currentDouble;
                   for (double i = 0; i < myDoubleValues.size(); i++) {
                        currentDouble = myDoubleValues.elementAt((int)i);
                        if (currentDouble != null) {
                             /// nothing to do
                        else {
                             nbNull++;
              return nbNull;
    //find the MIN values in the Hashtable to give us the range (with the MAX value)
         public Double MinDouble()
              Double MinDouble = null;
              Double currentValue;
              for (double j = 0; j < myDoubleValues.size(); j++)
                   currentValue = myDoubleValues.elementAt((int) j);
                   if (currentValue != null){
                   if (currentValue <= MinDouble) {
                        MinDouble = currentValue;
              return MinDouble;
         /*find the MAX value in the Hashtable to give us the range (with the MIN value)
         public double MAX()
          * Create an instance of StoreValuesDouble to hold vector values and number of times the values
          * appear. StoreValuesDouble automatically contains the variables defined above
          * (myDoubleValues, myValues and nullValues) we have to initialise myDoubleValues and myValues
          * as they have been defined but not initialised. nullValues has been defined (int) and initialised (0).
          * @param Vector /<Double/> a vector holding Double values
          * @param inValues the values in the vector
          * @return
         public StoreValuesDouble(Vector<Double> inValues) {
              myDoubleValues = inValues; //the attribute myDoubleValues defined in the StoreValuesDouble class
              //is the inValues parameter, this allows us to store the Vector in inValues
              myValues = new Hashtable<Double, Double>(); // create an instance of/initialise Hashtable
          * Now define the methods to make the instance StoreValuesDouble do what we want it to do
          * (ie parse all the double values of the myDoubleValues Vector attribute.
         public void computeDoubleValues() {
              Double currentDouble;//local variable to store the current read Double object
               * Use a for loop to read through all the values contained in the vector
              for (double i = 0; i < myDoubleValues.size(); i++) {
                   currentDouble = myDoubleValues.elementAt((int)i);
                   //currentDouble is now the Double object stored at i
                   //to check that i is not null we use the if statment
                   if (currentDouble != null) {
                        //i is not null so we want to add it to the hashtable. Rather than writing a lot of code
                        //here to do checking and adding we just call a method that can be written seperately
                        updateDoubleTable(currentDouble);
                   else {
                        //i is null so we just count it by adding it to our nullValues attribute
                        nullValues++;
          * Update the current distribution of Doubles
          * @param Double for the value of the key
          * @param inDouble for the value entered into the Hashtable (the object)
         public void updateDoubleTable(Double inDouble) {
              //First test that variable inDouble is not null
              if (inDouble != null) {
                   //update the table myValues this involves two tasks
                   //1)see if the double object has already been seen
                   //so we create a local variable to test the Hashtable
                   boolean alreadyPresent;
                   alreadyPresent = myValues.containsKey(inDouble);
                   //here we check whether inDouble is already in myValues
                   if (alreadyPresent) {
                        //if it is present we need to increase the counter
                        Double counter = myValues.get(inDouble);
                        //local variable counter to get the value associated to the key inDouble
                        Double newCounter = new Double(counter.intValue() + 1.0);
                        //update counter values and then ...
                        myValues.put(inDouble, newCounter);
                        //put into myValues
                        //as Hashtable can store only Objects, we cannot use primitive types
                        // so we use Objects related to primitive types as Integer, Float, Double
                        // or Boolean (here, we use Double)
                   } else {
                        //store the double and set it's counter to 1
                        myValues.put(inDouble, new Double(1));
              } else {
                   //do nothing
         //now we want to display the values
         public void displayDoubleTable() {
              // to display the distribution, we need to parse all the keys of the
              // hashtable and access to the value associated to each key
              Enumeration<Double> keys = myValues.keys();
              Double currentKey;
              Double currentValue;
              System.out.println("");
              System.out.println("Hashtable Information:");
              System.out.println("");
              System.out.println(myDoubleValues.size() + " Double objects in initial vector");
              System.out.println("");
              while (keys.hasMoreElements()) {
                   currentKey = keys.nextElement();
                   currentValue = myValues.get(currentKey);
                   System.out.println("The value " + currentKey.doubleValue()
                             + " has been seen " + currentValue.doubleValue()
                             + " time(s) in the initial Vector");
              System.out.println("");
              System.out.println("There were " + nullValues
                        + " null Double object(s) in the inital Vector");
         }As part of the StoreValuesDouble class. And to display it.
    package statistics;
    import java.util.Vector;
    public class TestStatDouble {
         static Vector<Double> doubleVector;
          * Create and initialise a vector of values and compute the mean,
          * standard deviation, distribution and MIN/MAX values.
         public static void main(String[] args) {
               // initialise the values in initValues
              initValues();
              // create an instance of StoreValuesDouble taking double as the parameter
              StoreValuesDouble is = new StoreValuesDouble(doubleVector);
              //Display the results
              displayVectorContent(doubleVector);
              System.out.println("");
              System.out.println("Number of null values: " + is.getDoubleNull());
              System.out.println("Number of non-null values is: " +(is.getDoubleValues() - is.getDoubleNull()));
              System.out.println("Number of all values: " + is.getDoubleValues());
              System.out.println("The mean is: " + is.meanDouble());
              System.out.println("Standard deviation is: " + is.standardDeviationDouble());
              System.out.println("The lowest value is " + is.MinDouble());
              System.out.println("");
               * now I want to display the results from the displayTable method in the StoreValuesDouble
               * class so I create an instance of StoreValuesDouble and use the computeDoubleValues and
               * displayDoubleTable methods.
              StoreValuesDouble storeValues = new StoreValuesDouble(doubleVector);
              storeValues.computeDoubleValues();
              storeValues.displayDoubleTable();
          * create the class method initValues() to add values to the Vector doubleVector
         public static void initValues()
              doubleVector = new Vector<Double>();
              doubleVector.addElement(null);
              doubleVector.addElement(new Double(10.9));
              doubleVector.addElement(new Double(15.95));
              doubleVector.addElement(new Double(17));
              doubleVector.addElement(null);
              doubleVector.addElement(new Double(1));
              doubleVector.addElement(new Double(4));
              doubleVector.addElement(new Double(10.499));
              doubleVector.addElement(null);
              doubleVector.addElement(new Double(10.4999));
              doubleVector.addElement(new Double(17));
              doubleVector.addElement(new Double(-15));
              doubleVector.addElement(null);
              doubleVector.addElement(new Double(14));
              doubleVector.addElement(new Double(20));
              doubleVector.addElement(new Double(-3));
              doubleVector.addElement(null);
              doubleVector.addElement(new Double(9));
              doubleVector.addElement(new Double(1.5));
              doubleVector.addElement(null);
              doubleVector.addElement(new Double(10.22));
              doubleVector.addElement(new Double(15.23));
              doubleVector.addElement(new Double(17.91));
              doubleVector.addElement(null);
          * class method to print values contained in the vector doubleVector to the console.
          * @param doubleVector the Vector to be displayed
         public static void displayVectorContent(Vector doubleVector)
              Double currentDouble;
              System.out.println("Double values within the Vector:");
              for (int i=0; i<doubleVector.size();i++)
                   try
                        currentDouble = (Double) doubleVector.elementAt(i);
                        if (currentDouble != null)
                             System.out.print(currentDouble.toString() + " ");
                   catch(ClassCastException cce)
                        System.out.print(cce.getMessage() + " ");
                        cce.printStackTrace();
              System.out.println("");
         It compiles fine but when I try and run it I get a
    Exception in thread "main" java.lang.NullPointerException
         at statistics.StoreValuesDouble.MinDouble(StoreValuesDouble.java:139)
         at statistics.TestStatDouble.main(TestStatDouble.java:37)
    TestStatDouble 37 is
    System.out.println("The lowest value is " + is.MinDouble());139 is
    if (currentValue <= MinDouble) {I guess the problem's in my if loop but I'm not sure why. Any help would be appreciated.
    Message was edited by:
    Ali_D

    Couple of points about your code:
    1. Don't declare your instance variables as solid types, declare them using their interfaces (where applicable), so in your case don't specifiy that you are using Vector or Hashtable, use List and Map. This will allow you to easily change your code to use a different collection, if and when appropriate. Also the unnecessary overhead of Vectors synchronisation means that you should use ArrayList instead of vector (that means that you will have to use get(int) instead of elementAt() but that's a very small price to pay.
    2. Declare local variables as close to their point of usage as possible. (Unless you need to do this for your course work, in which case you don't have a choice).
    3. Use the appropriate data type. For your count of null values you should be using an int or a long (you can't have a fractional count value!) Also, this should have been obvious to you, when you had to cast the value to an int for use with your lists. (Using double as an index is a very bad idea... And before you go posting the question, do a search on why floating point precision may not give you the results you expect)
    4. Code defencively... e.g. in your meanDouble() method, you set nonNull to 0, and then you do a division using that value. What do you think is going to happen if your loop doesn't execute once? Division by zero... You should handle these cases, rather than letting them fail ignominiously.
    5. If you are doing code like this...    if (currentDouble != null) {
            // / nothing to do
        } else {
            nbNull++;
        } Why have the empty block? You should just do the inverse.
        if (currentDouble == null) {
            nbNull++;
        } Far simpler, and expresses exactly what you are trying to do, not what you are not trying to do.
    6. Enumeration --- What version of java is that course being run in? I can see that you are using autoboxing, so it has to be 1.5 so, WHY is your lecturer encouraging the use of Vectors, Hashtables, and Enumerations!?!?!
    Anyway, that should be enough to be going on with.

  • Generated wsdl in eclipse [help]

    my server side code is return hashtable to client thru webservice.
    Below is some part of my WSDL generated.
    <xs:element name="Subscription" type="tns:Subscription" />
      <xs:element name="SubscriptionResponse" type="tns:SubscriptionResponse" />
    - <xs:complexType name="Subscription">
    - <xs:sequence>
      <xs:element minOccurs="0" name="customerID" type="xs:anyType" />
      </xs:sequence>
      </xs:complexType>
    - <xs:complexType name="SubscriptionResponse">
    - <xs:sequence>
      <xs:element minOccurs="0" name="return" type="tns:hashtable" />
      </xs:sequence>
      </xs:complexType>
    - <xs:complexType name="hashtable">
    - <xs:complexContent>
    - <xs:extension base="tns:dictionary">
      <xs:sequence />
      </xs:extension>
      </xs:complexContent>
      </xs:complexType>
      <xs:complexType abstract="true" name="dictionary" />
      </xs:schema>
      </types>i dun understand why i get this <xs:extension base="tns:dictionary">, can anyone clarify on this to me pls....

    it's java.util.Dictionary;

  • Deserialisation error

    I really need some help for this one.
    Last week this was running fine, but today when i try it without any changes, all of a sudden it keeps coming up with this deserialisation error. Any suggestions to what is going wrong?
    Ill post the wsdl and the client code so hopefully if im doing something wrong somebody will be able to pinpoint it as im new to this game although had the Hello example working aswell!
    Error message
    Endpoint address = http://localhost:8080/lbp/lbp
    deserialization error: java.lang.NullPointerException
         at com.sun.xml.rpc.encoding.ObjectSerializerBase.deserialize(ObjectSerializerBase.java:214)
         at com.sun.xml.rpc.encoding.ReferenceableSerializerImpl.deserialize(ReferenceableSerializerImpl.java:134)
         at com.sun.xml.rpc.client.dii.CallInvokerImpl._readFirstBodyElement(CallInvokerImpl.java:222)
         at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:158)
         at com.sun.xml.rpc.client.dii.CallInvokerImpl.doInvoke(CallInvokerImpl.java:61)
         at com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:353)
         at lbp.LBPServlet.init(LBPServlet.java:120)
         at javax.servlet.GenericServlet.init(GenericServlet.java:256)
         at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1044)
         at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:712)
         at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:416)
         at org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:180)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:286)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at filters.ExampleFilter.doFilter(ExampleFilter.java:149)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at filters.ExampleFilter.doFilter(ExampleFilter.java:149)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:258)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:256)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:210)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:513)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:196)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:175)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
         at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:383)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:156)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:577)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:974)
         at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:207)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:647)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:499)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:575)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:649)
         at java.lang.Thread.run(Thread.java:534)
    CAUSE:
    java.lang.NullPointerException
         at com.sun.xml.rpc.encoding.soap.SOAPResponseSerializer.doDeserialize(SOAPResponseSerializer.java:149)
         at com.sun.xml.rpc.encoding.ObjectSerializerBase.deserialize(ObjectSerializerBase.java:167)
         at com.sun.xml.rpc.encoding.ReferenceableSerializerImpl.deserialize(ReferenceableSerializerImpl.java:134)
         at com.sun.xml.rpc.client.dii.CallInvokerImpl._readFirstBodyElement(CallInvokerImpl.java:222)
         at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:158)
         at com.sun.xml.rpc.client.dii.CallInvokerImpl.doInvoke(CallInvokerImpl.java:61)
         at com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:353)
         at lbp.LBPServlet.init(LBPServlet.java:120)
         at javax.servlet.GenericServlet.init(GenericServlet.java:256)
         at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1044)
         at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:712)
         at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:416)
         at org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:180)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:286)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at filters.ExampleFilter.doFilter(ExampleFilter.java:149)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at filters.ExampleFilter.doFilter(ExampleFilter.java:149)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:258)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:256)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:210)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:513)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:196)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:175)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
         at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:383)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:156)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:577)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:974)
         at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:207)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:647)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:499)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:575)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:649)
         at java.lang.Thread.run(Thread.java:534)
    CAUSE:
    java.lang.NullPointerException
         at com.sun.xml.rpc.encoding.soap.SOAPResponseSerializer.doDeserialize(SOAPResponseSerializer.java:149)
         at com.sun.xml.rpc.encoding.ObjectSerializerBase.deserialize(ObjectSerializerBase.java:167)
         at com.sun.xml.rpc.encoding.ReferenceableSerializerImpl.deserialize(ReferenceableSerializerImpl.java:134)
         at com.sun.xml.rpc.client.dii.CallInvokerImpl._readFirstBodyElement(CallInvokerImpl.java:222)
         at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:158)
         at com.sun.xml.rpc.client.dii.CallInvokerImpl.doInvoke(CallInvokerImpl.java:61)
         at com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:353)
         at lbp.LBPServlet.init(LBPServlet.java:120)
         at javax.servlet.GenericServlet.init(GenericServlet.java:256)
         at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1044)
         at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:712)
         at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:416)
         at org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:180)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:286)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at filters.ExampleFilter.doFilter(ExampleFilter.java:149)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at filters.ExampleFilter.doFilter(ExampleFilter.java:149)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:258)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:256)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:210)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:513)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:196)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:175)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
         at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:383)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:156)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:577)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:974)
         at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:207)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:647)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:499)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:575)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:649)
         at java.lang.Thread.run(Thread.java:534)
    Client code
         String endpointaddress = "http://localhost:8080/lbp/lbp";
    //String qnameService = "MyHelloService";
    //String qnamePort = "HelloIF";
    String qnameService = "LBPService";
    String qnamePort = "LBPIF";
    String BODY_NAMESPACE_VALUE =
    "urn:Foo";
    String ENCODING_STYLE_PROPERTY =
    "javax.xml.rpc.encodingstyle.namespace.uri";
    String NS_XSD =
    "http://www.w3.org/2001/XMLSchema";
    String URI_ENCODING =
    "http://schemas.xmlsoap.org/soap/encoding/";
    //out.println("Endpoint address = " + args[0]);
         System.out.println("Endpoint address = " + endpointaddress);
    try {
    ServiceFactory factory =
    ServiceFactory.newInstance();
    Service service =
    factory.createService(new QName(qnameService));
    QName port = new QName(qnamePort);
    Call call = service.createCall(port);
    call.setTargetEndpointAddress(endpointaddress);
    call.setProperty(Call.SOAPACTION_USE_PROPERTY,
    new Boolean(true));
    call.setProperty(Call.SOAPACTION_URI_PROPERTY, "");
    call.setProperty(ENCODING_STYLE_PROPERTY, URI_ENCODING);
    QName QNAME_TYPE_STRING = new QName(NS_XSD, "string");
    //This example here probably doesnt BUT DOES - BONUS!
    QName QNAME_TYPE_BOOLEAN = new QName(NS_XSD, "Boolean");
    call.setReturnType(QNAME_TYPE_BOOLEAN);
    call.setOperationName(new QName(BODY_NAMESPACE_VALUE,
    "createnewuser"));
    call.addParameter("String_1", QNAME_TYPE_STRING,
    ParameterMode.IN);
    call.addParameter("String_2", QNAME_TYPE_STRING,
    ParameterMode.IN);
    call.addParameter("String_3", QNAME_TYPE_STRING,
    ParameterMode.IN);
    call.addParameter("String_4", QNAME_TYPE_STRING,
    ParameterMode.IN);
    call.addParameter("String_5", QNAME_TYPE_STRING,
    ParameterMode.IN);
    call.addParameter("String_6", QNAME_TYPE_STRING,
    ParameterMode.IN);
    String[] params = { "Delboy!"," del","del","del","del","del" };
    Boolean result = (Boolean)call.invoke(params);
    System.out.println(result);
    WSDL
    <?xml version="1.0" encoding="UTF-8" ?>
    - <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="urn:Foo" xmlns:ns2="http://java.sun.com/jax-rpc-ri/internal" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" name="LBPService" targetNamespace="urn:Foo">
    - <types>
    - <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://java.sun.com/jax-rpc-ri/internal" xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://java.sun.com/jax-rpc-ri/internal">
    <import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
    - <complexType name="hashtable">
    - <complexContent>
    - <extension base="tns:map">
    <sequence />
    </extension>
    </complexContent>
    </complexType>
    - <complexType name="map">
    - <complexContent>
    - <restriction base="soap11-enc:Array">
    <attribute ref="soap11-enc:arrayType" wsdl:arrayType="tns:mapEntry[]" />
    </restriction>
    </complexContent>
    </complexType>
    - <complexType name="mapEntry">
    - <sequence>
    <element name="key" type="anyType" />
    <element name="value" type="anyType" />
    </sequence>
    </complexType>
    </schema>
    </types>
    - <message name="LBPIF_createnewuser">
    <part name="String_1" type="xsd:string" />
    <part name="String_2" type="xsd:string" />
    <part name="String_3" type="xsd:string" />
    <part name="String_4" type="xsd:string" />
    <part name="String_5" type="xsd:string" />
    <part name="String_6" type="xsd:string" />
    </message>
    - <message name="LBPIF_createnewuserResponse">
    <part name="result" type="xsd:boolean" />
    </message>
    - <message name="LBPIF_login">
    <part name="String_1" type="xsd:string" />
    <part name="String_2" type="xsd:string" />
    </message>
    - <message name="LBPIF_loginResponse">
    <part name="result" type="ns2:hashtable" />
    </message>
    - <message name="LBPIF_sayGoodbye">
    <part name="String_1" type="xsd:string" />
    </message>
    - <message name="LBPIF_sayGoodbyeResponse">
    <part name="result" type="xsd:string" />
    </message>
    - <message name="LBPIF_sayHello">
    <part name="String_1" type="xsd:string" />
    </message>
    - <message name="LBPIF_sayHelloResponse">
    <part name="result" type="xsd:string" />
    </message>
    - <portType name="LBPIF">
    - <operation name="createnewuser" parameterOrder="String_1 String_2 String_3 String_4 String_5 String_6">
    <input message="tns:LBPIF_createnewuser" />
    <output message="tns:LBPIF_createnewuserResponse" />
    </operation>
    - <operation name="login" parameterOrder="String_1 String_2">
    <input message="tns:LBPIF_login" />
    <output message="tns:LBPIF_loginResponse" />
    </operation>
    - <operation name="sayGoodbye" parameterOrder="String_1">
    <input message="tns:LBPIF_sayGoodbye" />
    <output message="tns:LBPIF_sayGoodbyeResponse" />
    </operation>
    - <operation name="sayHello" parameterOrder="String_1">
    <input message="tns:LBPIF_sayHello" />
    <output message="tns:LBPIF_sayHelloResponse" />
    </operation>
    </portType>
    - <binding name="LBPIFBinding" type="tns:LBPIF">
    - <operation name="createnewuser">
    - <input>
    <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="urn:Foo" />
    </input>
    - <output>
    <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="urn:Foo" />
    </output>
    <soap:operation soapAction="" />
    </operation>
    - <operation name="login">
    - <input>
    <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="urn:Foo" />
    </input>
    - <output>
    <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="urn:Foo" />
    </output>
    <soap:operation soapAction="" />
    </operation>
    - <operation name="sayGoodbye">
    - <input>
    <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="urn:Foo" />
    </input>
    - <output>
    <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="urn:Foo" />
    </output>
    <soap:operation soapAction="" />
    </operation>
    - <operation name="sayHello">
    - <input>
    <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="urn:Foo" />
    </input>
    - <output>
    <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="urn:Foo" />
    </output>
    <soap:operation soapAction="" />
    </operation>
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc" />
    </binding>
    - <service name="LBPService">
    - <port name="LBPIFPort" binding="tns:LBPIFBinding">
    <soap:address xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" location="http://localhost:8080/lbp/lbp" />
    </port>
    </service>
    </definitions>

    i get the same problem i use:
    QName QNAME_TYPE_STRING = new QName(NS_XSD,"string");
    call.setReturnType(QNAME_TYPE_STRING);
    call.setOperationName(new QName(BODY_NAMESPACE_VALUE, "sayHello"));
    call.setOperationName(new QName(BODY_NAMESPACE_VALUE, "sayGoodbye"));
    call.addParameter("String_1", QNAME_TYPE_STRING, ParameterMode.IN);
    call.addParameter("String_2", QNAME_TYPE_STRING, ParameterMode.IN);
    String[] params = { "client running hello", "client running goodbye"};
    String result = (String)call.invoke(params);
    System.out.println(result);
    my error is as follows:
    run-client:
    [java] Endpoint address = http://localhost:8080/hello-jaxrpc/hello
    [java] java.rmi.RemoteException: JAXRPC.TIE.01: caught exception while hand
    ling request: deserialization error: unexpected XML reader state. expected: END
    but found: START: String_2
    [java] at com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:36
    9)
    [java] at dii.HelloClient.main(Unknown Source)
    run:
    have u figured this out yet dell trotter!

  • HashTable cannot be resolved to a Type

    Hey Guys,
    I want to use a HashTable to assign Integer object values to the to String keys defined by the getActionCommand() methods of an array of JButtons. Now I tried to construct a HashTable like this:
    private HashTable<String, Integer> commandParser = new HashTable<String, Integer>();Eclipse gives me the error "HashTable cannot be resolved to a Type" .
    I thought I had done it all as was stated in the APIs. What?s wrong here?
    Sum1 hlp pls i cant figger ths oot ;-)
    EDIT: While I?m here, I get a warning:
    The serializable class BuildPane does not declare a static final serialVersionUID field of type long
    for every one of my classes.
    What is that about? I ignored it because it?s just a warning, but always safe, never sorry.
    Edited by: AikmanAgain on Mar 29, 2008 5:29 AM

    AikmanAgain wrote:
    Hey Guys,
    I want to use a HashTable to assign Integer object values to the to String keys defined by the getActionCommand() methods of an array of JButtons. Now I tried to construct a HashTable like this:
    private HashTable<String, Integer> commandParser = new HashTable<String, Integer>();Eclipse gives me the error "HashTable cannot be resolved to a Type" .
    I thought I had done it all as was stated in the APIs. What?s wrong here?There is no class called HashTable in the JRE. Look again ... and remember Java is case sensitive.
    The serializable class BuildPane does not declare a static final serialVersionUID field of type long
    for every one of my classes.
    What is that about? I ignored it because it?s just a warning, but always safe, never sorry.The serialVersionUID is a field that's used in serialization (as the name and the warning should have suggested).
    Google for any serialization tutorial and you'll learn what it's good for.

  • Building hashtable for INPUT types dynamically

    In my jsp I want to define a method which can build and return a hashtable of all the input types defined inside a form. For example if my form looks like :
    <form name="detail_form" method="post" action="">
    <input type="text" name="asset_name" size="15" value="ABC">
    <input type="text" name="asset_desc" size="45" value="Laptop">
    <input type="hidden" name="employee_id_key" value="58975">
    <input type="hidden" name="asset_id_key" value="15">
    </form>
    then my method will be like :
    <%!
    public Map getCurrentData()
    Map paras=new HashMap();
    paras.put ("asset_name", "ABC");
    paras.put ("asset_desc", "Laptop");
    paras.put ("employee_id_key", "58975");
    paras.put ("asset_id_key", "15");
    return paras;          
    %>
    Now the problem is :
    since the code inside the form can be dynamic (like there can be different number of INPUT types with different names) so I want my method getCurrentData() to be dynamic. That probably means some sort of loop to go through all the INPUT types in the form and storing it in hashtable. But I dont know how to do it in java. Can anybody help me please. Thanks

    I am not exactly sure what you mean by "input types" but you could use the request.getParameterMap() method after the form is submitted. So for example you would have your form like <form ... action="nextpage.jsp"> and on nextpage.jsp you could call request.getParameterMap() to create a map of all the paramaters and their values. Here is what I mean...
    <form name="detail_form" method="post" action="nextpage.jsp">
    <input type="text" name="asset_name" size="15" value="ABC">
    <input type="text" name="asset_desc" size="45" value="Laptop">
    <input type="hidden" name="employee_id_key" value="58975">
    <input type="hidden" name="asset_id_key" value="15">
    </form>
    then on nexpage.jsp you could say
    <% Map myMap = request.getParamaterMap(); %>
    Good Luck
    Zac

  • How to obtain Hashtable element (array) base type?

    Hi,
         I have read the thread
              http://forum.java.sun.com/thread.jspa?forumID=52&threadID=531561
         on determining the base type of an object array.
         I tried applying the technique to my Hashtable where the element are arrays, this is how I am setting up my Hashtable to pass on to my native method
    Hashtable ht = new Hashtable();
    Float Kd[] = new Float[1];
    Kd[0] = 0.1f;
    Float from[] = new Float[3];
    from[0] = -4.0f;
    from[1] = 2.0f;
    from[2] = 1.0f;
    Integer indices[] = new Integer[4];
    indices[0] = 217;
    indices[1] = 17;
    indices[2] = 769;
    indices[3] = 23;
         myNativeMethod("dbname",ht);
         In my native method, I have the following which is able to determine the array size so I think it is kind of working/correct but when I tried to determine the base type of the array, I keep getting Bus error.
         Here is my native code (as part of my SWIG code)
         Should I be handling arrays obtained from Hashtable differently, can someone point out to me what the correct approach is?
    Regards
    8<------8<------8<------8<------8<------8<------8<------8<------
    if ($input != 0) {
    std::cout << "SWIG ...parameterlist..." << std::endl;
    // Generated typemap code
    const jclass hashtable = jenv->FindClass("java/util/Hashtable");
    if (hashtable != 0) {
    const jclass enumeration = jenv->FindClass("java/util/Enumeration");
    const jmethodID keys =
         jenv->GetMethodID(hashtable, "keys",
                   "()Ljava/util/Enumeration;");
    const jmethodID get =
         jenv->GetMethodID(hashtable, "get",
                   "(Ljava/lang/Object;)Ljava/lang/Object;");
    if (enumeration != 0) {
         const jmethodID hasMoreElements =
         jenv->GetMethodID(enumeration,
                   "hasMoreElements", "()Z");
         const jmethodID nextElement =
         jenv->GetMethodID(enumeration,
                   "nextElement", "()Ljava/lang/Object;");
         for (jobject keyset = jenv->CallObjectMethod($input, keys);
         jenv->CallBooleanMethod(keyset, hasMoreElements) == JNI_TRUE;) {
         jstring key = (jstring)jenv->CallObjectMethod(keyset, nextElement);
         jarray value = (jarray)jenv->CallObjectMethod($input, get, key);
         jclass valueClass = jenv->GetObjectClass(value);
         jclass valueClassClass = jenv->GetObjectClass(valueClass);
         const jmethodID getName =
         jenv->GetMethodID(valueClass,
                   "getName", "()Ljava/lang/String;");
         jstring valueClassClassName =
         (jstring)jenv->CallObjectMethod(value, getName);
         const char *vccptr = jenv->GetStringUTFChars(valueClassClassName,
                                  0);
         std::cout << "vccptr is " << vccptr << std::endl;
         jenv->ReleaseStringUTFChars(valueClassClassName, vccptr);
         const char *keyptr = jenv->GetStringUTFChars(key, 0);
         std::cout << "key is " << keyptr << std::endl;
         int numElements = jenv->GetArrayLength(value);
         std::cout << "value array size is " << numElements << std::endl;
         // const char *valptr = jenv->GetStringUTFChars(value, 0);
         // $1 = CSLAddNameValue($1, keyptr, valptr);
         jenv->ReleaseStringUTFChars(key, keyptr);
         // jenv->ReleaseStringUTFChars(value, valptr);
    8<------8<------8<------8<------8<------8<------8<------8<------
    Regards
    Message was edited by:
    nicholas_yue

    You've asked the same thing before. Assuming that you've defined the function prototype correctly when you built the DLL from the VI, you should be able to call it and get the results from it. You do not need to change the return type when you build the DLL. Read the information at http://zone.ni.com/devzone/conceptd.nsf/webmain/7D6A20FE02EDBF318625690700704CF3. Even though it was written for LabVIEW 6, the section on Accessing LabVIEW 6x Arrays from Microsoft Visual C++ is still valid.

  • Hashtable equalent data type in PLSQL

    Hi,
    From java i am calling stored procedure, i want to pass hashtable to it.Data in hashtable consists of key and value. Key is some integer and value is an Object[](array)
    So i want to know datatype equal to Hashtable in PLSQL.
    Can anyone help out in solving about problem.
    --Kalyan

    Look Associative Arrays (Index-By Tables) :
    create or replace package Kalyan
    IS
    type t1 is record (empno number, ename varchar2(200), hiredate date,....);
    type t2 is table of t1 index by binary_integer;
    procedure f1(par1 in out t2);
    end;

  • Hashtable with incompatible types

    HI, I', stuck with this. I'm trying to create a Hashtable wich will use a String as the Key and that will store my own object, but, when I try to get the information from the Hash, the compiler throws this Error:
    tst.java:48: incompatible types
    found : java.lang.Object
    required: Entra_Usuario
    U = usuario.get(usu);
    The code (simplified is)
    public class tst
    public static void main(String[] unused)
         Hashtable usuario = new Hashtable();
    Entra_Usuario U = new Entra_Usuario(...Some parms);
         usuario.put(usu,U);
         try
              while((ra = reg.readLine()) !=null)
              ... get data from fiel
                   usu= somthing from file
                   U = usuario.get(usu); <=== Here is where the compiler complains
                   if (U== null)
                        U = new Entra_Usuario(... );
                        usuario.put(usu,U);
                   else
                        U.update( ..... )
         } catch (Excep...          
    And Class Entra_Usuario is defined as:
    public class Entra_Usuario
         String Fecha_Ini=null;
         String Fecha_Fin=null;
         String Hora_Ini=null;
         String Hora_Fin=null;
         String IP=null;
         String Usuario=null;                
         public Entra_Usuario(some parms ...)
              public void Update(.. some parms .)
    Thx ni advance for your help
    Regards Alejandro

    you have to cast it :
    U = (Entra_Usuario)usuario.get(usu);

  • How can I get the total "values" in a hashtable ?

    i know that i can get the total values in a hashtable by hash.elements() method. It returns an
    enumeration with all the values present in this hashtable. this is fine upto here.
    Now the preoblem is:
    According to what rule this enumeration will be returned. I mean..
    If i added in key A with value a,
    then key B with value b;
    then key C with value c;
    then key D with value d;
    (They all are objects of type String)
    now i call ... hash.elements(); Suppose it returns Enumeration enum;.
    Now in what order they all are present in this hashtable.
    Meaning is that if i move arond this enum in what sequence they all will be returned.
    option A ) In the same order as they were inserted in hashtable.
    option B ) According to LIFO;
    option C) There is no fix rules , simply it return all the elements and u cannot judge that the first element in enum was really the first element inserted in the hashtable and the second element of enum was really the second element inserted in the hashtable.
    What do u think..which option is correct ?
    Ny idea will highly appreciated.
    Thanks in advance.
    Sanjeev Dhiman

    hi, i am again..
    boss ! this is not true..u just change the order and or change the keys and something like ...
    "Sanjeev", "hello"
    "Dhiman", "hi"
    "Technosys" ,"Services"
    u will find that its not LIFO..really i was thinking before coding my project that option A is correct and with knowledge i wrote 3 - 4 classes but when i run the programm its starts throwing errors.
    so, i posted this question. I think "apppu" is right.
    I think , firstly hash is calculated for each value and that value is returned which can be received in a fastest way and hence not necessarily in LIFO and FIFO..
    Thanks to u also as u gave ur precious time for me.
    Once again.
    Thank you very much.
    Sanjeev Dhiman

  • Need help in using hashtable as a property of a form bean

    Hi,
    Is it possible to use a hashtable as a property of the bean.
    Well this is the problem i have
    I am using a hashtable as property and i want it to store from(/retrive into} form as ints/strings
    I have a
    JSP Page
    SampleAction --Action
    SampleForm --ActionForm
    Sample(bean)
    =============
    JSP Page
    (within the html:form tag)
    <html:text property="sample.number" />
    ====================
    struts-config links to
    SampleAction
    SampleForm
    ==============
    SampleForm
    Sample sample = new Sample();
    reset(){ ...impl...}
    validate(){.... impl.....}
    =================
    Sample.java
    private Hashtable prop = new Hashtable();
    public int getNumber()
       return ((Integer)prop.get("number")).intValue();
    public void setNumber(int number)
       prop.put("number",new Integer(number));
    ====================================
    this setup understandbly gives me a error like this
    no getter method for property sample.number
    PLEASE DO remember that i have a large number of mixed types in my form that needs to be populated into the bean and i detest using that many variables(in the bean)
    I NEED TO A KNOW A SOLN. PLEASE
    Thanx in advance
    cheers
    Ash

    Hi,
    I think the solution for your problem is
    put a form tag in your jsp page.
    name it as your form name defined in the struts-config.xml.
    in your case
    it is 'sample'.
    And make changes in the html:text tag like,
    <html:text name="sample" property="number" />
    Hope it will work.. have fun !!!

  • Need to run a prog on 1.4 which is running on 1.5. .....using two hashtable

    hello,
    I've developed a program which is prefectly working on java 1.5.0 version.
    but when run on java1.4.0. it gives run time error in this code.
    first i'm getting error in second hashtable. put function where i'm using key as an integer.this is running on 1.5 version but have to change key as string on 1.4. but after that it is still not working properly.
    I want that when i clicked on open then it must show both file
    1. that have hdr extension
    2. that have same name as the corrseponding .hdr file but without extension.
    this program show desired result on 1.5 but on 1.4 it display only .hdr file.
    pls. help me regarding this .
    // class hdr file filter
    import java.io.File;
    import java.util.Hashtable;
    import java.util.Enumeration;
    import javax.swing.*;
    import javax.swing.filechooser.*;
    public class hdrFileFilter extends FileFilter {
    private Hashtable filters = null;
    private Hashtable noextensionfilter = null;
    private String noextensionname=null;
    private String extensionname = null;
    private String description = null;
    private String fullDescription = null;
    private boolean useExtensionsInDescription = true;
    private String fname = null;
    public File noextensionarray[];
    int count=0;
    int counthdr=0;
    int i=0;     
         //all files are accepted.
    public hdrFileFilter()
         this.filters = new Hashtable();
         //Creates a file filter that accepts files with the given extension.
    public hdrFileFilter(String extension)
         this(extension,null);
         //Creates a file filter that accepts the given file type.
    public hdrFileFilter(String extension, String description)
         this();
         if(extension!=null)
         addExtension(extension);
         if(description!=null) setDescription(description);
         //Return true if this file should be shown in the directory pane,false if it shouldn't.
    public boolean accept(File f) {
         if(f != null) {
         if(f.isDirectory()) {
              return true;
         String extension = getExtension(f);
         if(extension != null && filters.get(getExtension(f)) != null)
              fname=f.getName();
              extensionname=fname.substring(0,fname.lastIndexOf('.'));
              counthdr+=1;
              return true;
         if(extension == null)
              noextensionfilter=new Hashtable(20);
              noextensionname=f.getName();          
              noextensionfilter.put(count,noextensionname);
              count=count + 1;
              if(noextensionfilter.get(count) == extensionname)
                   noextensionarray=new File[20];
                   noextensionarray=f
                   System.out.println("file:" +noextensionarray[i]);
                   i++;
                   return true;               
         return false;
         //Return the extension portion of the file's name .
    public String getExtension(File f)
              if(f != null)
                   String filename = f.getName();
                   int i = filename.lastIndexOf('.');
                   if(i>0 && i<filename.length()-1)
                        return filename.substring(i+1).toLowerCase();
              return null;
         //Adds a filetype "dot" extension to filter against.
    public void addExtension(String extension)
         if(filters == null)
         filters = new Hashtable(20);
         filters.put(extension.toLowerCase(), this);
         fullDescription = null;
    public String getDescription()
              if(fullDescription == null)
                   if(description == null || isExtensionListInDescription())
                        fullDescription = description==null ? "(" : description + " (";
                        // build the description from the extension list
                        Enumeration extensions = filters.keys();
                        if(extensions != null)
                             Object nn=extensions.nextElement();
                             fullDescription += "." + nn;     
                             while (extensions.hasMoreElements())
                                  fullDescription += ", ." + nn;
                        fullDescription += ")";
                   else
                        fullDescription = description;
              return fullDescription;
    public void setDescription(String description)
         this.description = description;
         fullDescription = null;
    public void setExtensionListInDescription(boolean b) {
         useExtensionsInDescription = b;
         fullDescription = null;
              public boolean isExtensionListInDescription()
              return useExtensionsInDescription;

    Might be fixable if you do something like
    javac -target 1.4
    Bytecodes are different in 1.5 and thus not backward compatible

  • Problem with doubleValue() method and hashtable

    Hi,
    I made a type double variable named tempNumber.
    and I used this to put that number in a hashtable
    CODE 1 : hash.put(key, new Double(tempNumber));
    Then I wrote this code to retrieve it.
    CODE 2: (hash.get(st.sval)).doubleValue();
    Note: I am using streamtokenizer to get the nexttoken, so st.sval is a string representation of the token.
    Now my problem is when I compile CODE 2, I get an error message saying that "method doubleValue() not found in java.lang.Object". Whats going on here??
    I am using java 1.1 by the way.
    Thanks in advance...

    Hash table stored and returns objects. You have to typecast the return value of get() method to Double and then call doubleValue() on it.
    Its something as follows
    ((Double)hash.get(key)).doubleValue()

  • Trying to solve the hashtable problem;

    this is a test of a part of my programming, trying to solve the hashtable
    i took out the erronous part and change some of it.i'm trying to print out a table of data with 4 column
    import java.util.*;
    public class test {
         // creating a global hashtable name "b" its
         //static just for the convieniet of it
    static Hashtable b = new Hashtable();
    public static void addItem(String keyid, String t, double p, int q){
    // array size of 4 for my value in hashtable "b"
    String [] array = new String [4];
    // puting all my variables into string array
    //including my keyid as the first in array[0]      
         array[0]=keyid;
         array[1]=t;
         array[2]= String.valueOf(p);//casting of double type to string
         array[3]= String.valueOf(q);//casting of int type to string
         b.put(id,array);//setting key = id and value = my array[]
    public static void main (String args[]) throws Exception {
         String numb = "009", piss="theone";
         double cost = 19.50;
         int a = 1;
         String [] testItem;
         addItem(numb,piss,cost,a); //call of method additem;
         Enumeration e = b.keys();
    // Get all values
    while ( e.hasMoreElements())
    {            tempItem = (String [])e.nextElement(); **// error msg here**
         System.out.println("array element 1"+tempItem[1]);
         System.out.println("array element 2"+tempItem[2]);
         System.out.println("array element 3"+tempItem[3]);
    this is my error msg "ClassCastException: java.lang.String cannot be cast to [Ljava.lang.String;"
    1 =====>cannot find symbol
    symbol  : variable id
    location: class test
            b.put(id,array);//setting key = id and value = my array[]
    2 ===>cannot find symbol
    symbol : variable tempItem
    location: class test
    tempItem = (String [])e.nextElement();
    3 ====>cannot find symbol
    symbol : variable tempItem
    location: class test
    System.out.println("array element 1"+tempItem[1]);
    is there anyway to solve this or anyone can provide me with an alternative way of printing a table with 4 col?

    you should learn to post your code inside code tags
    mangotree wrote:
    1 =====>cannot find symbol
    symbol : variable id
    location: class test
    b.put(id,array);//setting key = id and value = my array[]there is nothing called "id"
    mangotree wrote:
    2 ===>cannot find symbol
    symbol : variable tempItem
    location: class test
    tempItem = (String [])e.nextElement();
    3 ====>cannot find symbol
    symbol : variable tempItem
    location: class test
    System.out.println("array element 1"+tempItem[1]);there is nothing called "tempItem"
    mangotree wrote:
    this is my error msg "ClassCastException: java.lang.String cannot be cast to [Ljava.lang.String;"
    here you are iterating through the keys of the hash table ("b.keys()"), and your key is a String, not a String[; perhaps you want the value instead?

Maybe you are looking for

  • Restoring iTunes library after hard drive crash

    The hard drive on my Macbook pro (mid-2009) crashed. I took it to the genius bar for a diagnostic. The drive was physically fine so they wiped it and reinstalled Mavericks, which is now running 10.9.4. I am restoring user files from Time Machine indi

  • Photos do not automatically open in osx mail

    Recently I have found that in mail, attachmnets that are photos no longer appear automatically in the preview pane. Instead a question mark appears where the photo should be. If , however, I use the quick look option all the photos are there. I would

  • B&W boot options.

    Hi all, I have a Rev. 1 (piece o' $h*t IDE controller) G3/400. This computer has been the source of my headaches for months. I have tryed at least 15 different HD's and none will work for more than 5 minutes before a crash. I have even put an apple O

  • Some pages appear blank until I refresh the page then it displays normally

    When selecting some websites the page is blank until I refresh.

  • AFP and Windows Server 2003 (SP2)

    Hello, I have a problem when i connect my MAC with Windows Server 2003 by a AFP connection the connection drops after +/- 10 min. I need this AFP connection because i work with a OMNIS database that locks when i use a SMB connection. Can somebody tel