Class Object array!!! HELP

Customer[] C = new Customer[100];
// Trying to call a constructor from an object of a class Customers
C[1].("01", Tom Evans", 6500,"36 Lakes st ", "05/07/2004", 900); // it want let me do this !!! :(Please tell me what are my alternatives appart from calling every single getter and setter.

C[1] = new Customer(<params>);

Similar Messages

  • Object Array Help

    Why is it that when i give the user[0] a certain name (with the setName method), all users (user[0] to user[100]) get that name?
    public class UserProfileDataBase
        public User [] arr = new User [100];
        public UserProfileDataBase () throws IncompatibleClassChangeError
         arr [0] = new User ("s1", "s2", "s3", "t", "al", 0, 0, 0);
         for (int i = 0 ; i < arr.length ; i++)
             arr = new User ("s1", "s2", "s3", "t", "al", i, 0, 0);
         for (int r = 0 ; r < 10 ; r++)
         System.out.println ("index " + r + " is " + arr [r].getName () + " " + arr [r].getAge());
         arr [0].setName ("ADMINA");
         arr [0].setSurname ("ADMINA");
         arr [0].setCode (1111);
         for (int r = 0 ; r < 10 ; r++)
         System.out.println ("index " + r + " is " + arr [r].getName ());
    public static void main (String [] args)
         new UserProfileDataBase ();
    THIS IS THE USER CLASS:::
    public class User
        private static String name = new String ();
        private static String sur = new String ();
        private static int accCode;
        private static String gender = new String ();
        private static String town = new String ();
        private static String alias = new String ();
        private static int age;
        private static int status = 0; //0 is void, 1 is active and 2 is deceased.
        public User (String n, String sn, String gen, String t, String al, int a, int code, int st)
         name = n;
         sur = sn;
         gender = gen;
         town = t;
         alias = al;
         age = a;
         accCode = code;
        public static String getSurname ()
         return sur;
        public void setSurname (String s)
         sur = s;
        public static int getCode ()
         return accCode;
        public void setCode (int s)
         accCode = s;
        public static String getGender ()
         return gender;
        public void setGender (String s)
         gender = s;
        public static String getName ()
         return name;
        public void setName (String s)
        System.out.println ("setName Pointer for name " + s);
         name = s;
        public static String getTown ()
         return town;
        public void setTown (String s)
         town = s;
        public static String getAlias ()
         return alias;
        public void setAlias (String s)
         alias = s;
        public static int getAge ()
         return age;
        public void setAge (int s)
         age = s;
        public static int getStatus ()
         return status;
        public void setStatus (int s)
         status = s;

    The fields are defined for the class. The instances don't have them.

  • Re: Beginner needs help using a array of class objects, and quick

    Dear Cynthiaw,
    I just read your Beginner needs help using a array of class objects, and quick of Dec 7, 2006 9:25 PM . I really like your nice example.
    I also want to put a question on the forum and display the source code of my classe in a pretty way as you did : with colors, indentation, ... But how ? In html, I assume. How did you generate the html code of your three classes ? By help of your IDE ? NetBeans ? References ?
    I already posted my question with six source code classes ... in text mode --> Awful : See "Polymorphism did you say ?"
    Is there a way to discard and replace a post (with html source code) in the Sun forum ?
    Thanks for your help.
    Chavada

    chavada wrote:
    Dear Cynthiaw,
    I just read your Beginner needs help using a array of class objects, and quick of Dec 7, 2006 9:25 PM . I really like your nice example.You think she's still around almost a year later?
    I also want to put a question on the forum and display the source code of my classe in a pretty way as you did : with colors, indentation, ... But how ?Just use [code] and [/code] around it, or use the CODE button
    [code]
    public class Foo() {
      * This is the bar method
      public void bar() {
        // do stuff
    }[/code]

  • Multidimensional array in jquery class/object

    I'm trying to get into javascript and jquery for a hobby project of mine. Now I've used the last 4 hours trying to find a guide on how to create class objects that can contain the following information
    Identification : id
    Group : group
    Persons : array(firstname : name, lastname : name)
    Anyone know of a tutorial that can show me how to do this?
    I found this page where I can see that an object can contain an array, but it doesn't state whether it is possible to use a multidimensional array.
    And this page just describes the object with normal values.
    Any pointers in the right direction are appreciated.

    There are no classes in JavaScript. It uses a different style of objects and what you found is indeed what you need.
    Well, it might help to think about it as a dynamic, runtime-modifiable object system. An Object is not described by class, but by instructions for its creation.
    Here you have your object. Note that you can use variables everywhere.
    var id = 123;
    var test = {"Identification": id,
    "Group": "users",
    "Persons": [{"firstname":"john", "lastname":"doe"},{"firstname":"jane","lastname":"doe"}]
    This is identical to the following code. (The first one is a lot nicer, though.)
    var id = 123;
    var test = new Object();
    test.Identification = id;
    test["Group"] = "users;
    test.Persons = new Array();
    test.Persons.push({"lastname":"doe","lastname":"john"});
    test.Persons.push({"lastname":"doe","lastname":"jane"});
    As you can see, you can dynamically add new properties to an object. You can use both the dot-syntax (object.property) and the hash syntax (object["property"]) in JavaScript.

  • Create array of arbitrary dimensions / get Class object for primitive types

    Here's an interesting problem: is there any way to code for the creation of an n-dimensional array where n is only known at runtime (input by user, etc.)?
    java.lang.reflect.Array has a newInstance method which returns an array of an arbitrary number of dimensions specified by the int[] argument, which would give me what I want. However, the other argument is a Class object representing the component type of the array. If you want to use this method to get an array of a primitive type, is it possible to get a Class object representing a primitive type?

    That doesn't help, since the whole problem is that the number of dimensions aren't known until runtime. You can't simply declare a variable of type int[][] or use an int[][] cast, since the number of []'s is variable.
    The int.class construction was partly what I was looking for. This returns the array needed (assuming some read method):
    int dimensions = read();
    int size = read();
    int[] index = new int[dimensions];
    for (int i = 0; i < dimensions; i++)
        index[i] = size;
    Object myArray = Array.newInstance(int.class, index);The only problem is, as an Object, I can't use myArray usefully as an array. And I can't use a cast, since that requires a fixed number of dimensions.

  • Create Class objects from an Array of File Objects

    Hi There,
    I'm having extreme difficulty in trying to convert an array of file objects to Class objects. My problem is as follows: I'm using Jfilechooser to select a directory and get an array of files of which are all .class files. I want to create Class objects from these .class files. Therefore, i can extract all the constructor, method and field information. I eventually want this class information to display in a JTree. Very similar to the explorer used in Netbeans. I've already created some code below, but it seems to be throwing a NoSuchMethodError exception. Can anyone please help??
    Thanks in advance,
    Vikash
    /* the following is the class im using */
    class FileClassLoader extends ClassLoader {
    private File file;
    public FileClassLoader (File ff) {
    this.file = ff;
    protected synchronized Class loadClass() throws ClassNotFoundException {
    Class c = null;
    try {
    // Get size of class file
    int size = (int)file.length();
    // Reserve space to read
    byte buff[] = new byte[size];
    // Get stream to read from
    FileInputStream fis = new FileInputStream(file);
    DataInputStream dis = new DataInputStream (fis);
    // Read in data
    dis.readFully (buff);
    // close stream
    dis.close();
    // get class name and remove ".class"
    String classname = null;
    String filename = file.getName();
    int i = filename.lastIndexOf('.');
    if(i>0 && i<filename.length()-1) {
    classname = filename.substring(0,i);
    // create class object from bytes
    c = defineClass (classname, buff, 0, buff.length);
    resolveClass (c);
    } catch (java.io.IOException e) {
    e.printStackTrace();
    return c;
    } // end of method loadClass
    } // end of class FileClassLoader
    /* The above class is used in the following button action in my gui */
    /* At the moment im trying to output the data to standard output */
    private void SelectPackage_but2ActionPerformed(java.awt.event.ActionEvent evt) {
    final JFileChooser f = new JFileChooser();
    f.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    int rVal = f.showOpenDialog(Remedy.this);
    // selects directory
    File dir = f.getSelectedFile();
    // gets a list of files within the directory
    File[] allfiles = dir.listFiles();
    // for loop to filter out all the .class files
    for (int k=0; k < allfiles.length; k++) {
    if (allfiles[k].getName().endsWith(".class")) {
    try {
    System.out.println("File name: " + allfiles[k].getName()); // used for debugging
    FileClassLoader loader = new FileClassLoader(allfiles[k]);
    Class cl = loader.loadClass();
    //Class cl = null;
    Class[] interfaces = cl.getInterfaces();
    java.lang.reflect.Method[] methods = cl.getDeclaredMethods();
    java.lang.reflect.Field[] fields = cl.getDeclaredFields();
    System.out.println("Class Name: " + cl.getName());
    //print out methods
    for (int m=0; m < methods.length; m++) {
    System.out.println("Method: " + methods[m].getName());
    // print out fields
    for (int fld=0; fld < fields.length; fld++) {
    System.out.println("Field: " + fields[fld].getName());
    } catch (Exception e) {
    e.printStackTrace();
    } // end of if loop
    } // end of for loop
    packageName2.setText(dir.getPath());
    }

    It's throwing the exeption on the line:
    FileClassLoader loader = new FileClassLoader(allfiles[k]);
    I'm sure its something to do with the extended class i've created. but i cant seem to figure it out..
    Thanks if you can figure it out

  • Need help with class object? Please somoen

    hey guys,
    It's been few days since i'm working on making a small bingogame program but i'm getting stuck frequantly.
    I've different classes, in the main class i'm asking the user to input number of players who would like to play then i'm asking the player's name and how many bingoCards each player wants.
    I'm stroing all that info in a BingoPlayer class's array object. But for some reason when i get out from the loop and try to retrive the info from that array it only gives me the last input entry (player's name & number of cards) at any index of the array.
    Can please someone tell me how i can store the given information for each player in that object array on different indices of the array?
    I'm providing the code where i've the problems:
    public class BingoGame
        public static BingoPlayer players[] = new BingoPlayer[5];
        public static void main() throws IOException {
            int numPlayers = 0;
            int numCards [] = new int [5];
            String name [] = new String[4];
            BufferedReader input = new BufferedReader (new InputStreamReader(System.in)); //allows input
    // ask for the number players who wants to play
            System.out.print("Please enter the number of players in this game (2-5): ");
            numPlayers = Integer.parseInt(input.readLine());
    // make sure the entered value is within range
            while (numPlayers < 2 || numPlayers > 5) {
                System.out.println("Invalid number of players ");
                System.out.print("Please enter the number of players in this game (2-5): ");
                numPlayers = Integer.parseInt(input.readLine());
            System.out.println();
    //ask for the names and numebr of cards for entered number of players
    // and make sure the number of cards are within the range,
    //and assign the players that many cards using the BingoPlayer object 
            for (int i = 1; i <= numPlayers; i++) {
                System.out.print("Please enter name of player " + i + " : ");
                name[i] = input.readLine();
                System.out.println();
                System.out.print("Please enter the number of cards (1-5) for player " + i + " : ");
                numCards[i] = Integer.parseInt(input.readLine());
                while (numCards[i] < 1 || numCards[i] > 5) {
                    System.out.println("Invalid number of cards for the player " + i);
                    System.out.print("Please enter the number of cards (1-5) for player " + i + " : ");
                    numCards[i] = Integer.parseInt(input.readLine());
                System.out.println();
                players[i] = new BingoPlayer(name, numCards[i]);
    * here it only prints out the information for the last player, instead it should return the information for both of the player
    for (int k = 1; k <= numPlayers; k ++) {
    System.out.println(players[k]);
    //players[k].genCards();
    for example if i enter 2 players:
    Player1: name: Jami, number of cards 1
    Player2: name: Joey, number of cards 2
    in the last loop it just prints out :"Joey, 2" 2 times instead of printing out: "Jami, 1" & "Joey, 2"
    Please someone help! i really need to complete this within 2 days. Thanks in advance

    Without seeing BingoPlayer's implementation, all it
    would be would be a guess.
    My guess: The name and numCards members of that class
    are declared as static, so all instances share the
    same values.Thanks it worked, declaring them static was the main probelm..thank you very much

  • Loading and viewing XML when a class object is created..Help Please

    Hello,
    I have writing a simple class which has a method that gets invoke when the object of the class is created. I am able to view the loaded XML content when I trace it with in my class method, but cannot assign the content to a instance variable using the mutator method. So the process goes like this:
    Class object is instantiated
    Class construtor then calls the loadXML method which laods the XML
    And then assigns the XML to a class instance variable.
    So now if I would like to access the loaded XML through class object, I should be able to see the loaded xml content which I am not able to see. I have spent over few hours and cannot get the class object to display the loaded XML content. I would highly appreciate it if someone can help in the right direction, please.
    [code]
    package com.as3.app
        import flash.display.*;
        import flash.events.*;
        import flash.text.*;
        import flash.net.*;
        public class Cars extends MovieClip {
               public var _CarList:Object;
               public function Quiz()
                  super();
                  loadCars();
    // ===========================================================
    //           CARS GETTER SETTER
    // ===========================================================
            public function set Cars(val:XML):void
                this._CarList = val;
            public function get Cars():XML
                return this._CarList;
    // ===========================================================
    //            LOAD QUESTIONS FROM XML
    // ===========================================================
            public function loadcars()
                var myXML:XML;
                var myLoader:URLLoader = new URLLoader();
                myLoader.load(new URLRequest("xml/cars.xml"));
                myLoader.addEventListener(Event.COMPLETE, processXML);
                function processXML(e:Event):void
                    myXML = new XML(e.target.data);  
                    Cars = myXML;                 // Assigning the loaded xml data via mutator method to the _CarList;
    //=============================================================  
                                  INSTANTIATING THE CLASS OBJECT
    //=============================================================
    package com.as3.app
        import flash.display.*;
        import flash.events.*;
        import flash.text.*;
        import flash.net.*;
        import com.as3.app.*;
        public class DocumentClass extends MovieClip {
            public var c:Car;
            public function DocumentClass()
                super();
                c = new Cars();  
                trace(c.Cars);
    [/code

    where you have:
                super();
                c = new Cars();  
                trace(c.Cars);
    c.Cars will not trace as the loaded xml, because it will not have loaded in time. After some time it should presumably have the correct value.
    loading operations in actionscript are asynchronous, so your nested function which is acting as the listener ( function processXML(e:Event):void) only ever executes when the raw xml data has loaded and that is (I believe, not 100% sure) always at least one frame subsequent to the current one.
    In general I would consider it bad practise to use nested functions like that, but I don't think its contributing to your issues here. I think its just a timing issue given how things work in flash....
    Additional observation:
    your Cars constructor calls loadCars() and your loadCars method is defined as:
    public function loadcars()
    I assume its just a typo in the forum that the uppercase is missing in the function name....

  • Array of class objects

    I was wondering how would you declare an array of class objects. Here is my situation:
    I'm working on a project dealing with bank accounts. Each customer has a specific ID and a balance. I have to handle transactions for each customer at different times, so I was thinking that I need an array of class objects; however, I dont know how to initialize them.
    Here's what I did:
    BankAccount [ ] myAccount = new BankAccount[10];
    // 10 = 10 customers
    How do I initialize the objects?
    Thankz

    I was wondering how would you declare an array of
    class objects. Here is my situation:
    I'm working on a project dealing with bank accounts.
    Each customer has a specific ID and a balance. I have
    to handle transactions for each customer at different
    times, so I was thinking that I need an array of
    class objects; however, I dont know how to initialize
    them.
    Here's what I did:
    BankAccount [ ] myAccount = new BankAccount[10];
    // 10 = 10 customers
    How do I initialize the objects?
    Thankz
    HAI
    Use the hashtable
    and store the classObject of each customer with the corresponding Id in it
    and whenever u want to recover a class match the Id and get the corresponding class
    that is the best way to solve ur problem
    Regards
    kamal

  • Class Object into Byte Array

    Is there a way to copy a class object into a byte array? If so, how?

    hi check out
    http://forum.java.sun.com/thread.jspa?threadID=562268&
    messageID=2766098This does not work in j2me. WriteObject does not exist, and there are no serialsation interfaces in j2me. So you'll have to do that on your own.
    look here: http://java.sun.com/developer/J2METechTips/2002/tt0226.html

  • I need help with a Object Array

    I am having trouble and this maybe really simple seeing that I am fairly new to java but I have text that is being broken down in to preset part with those parts stored in Object arrays.
    Now I also have a object array inside my object array. Within the second object array are the broken down parts of the text and I want to compare this text with another string so for example this is what I am trying
    boolean found = false;
    for (int i = 0; i < FirstObjectArray.length ;i++)
         Object[] SecondObjectArray = (Object[]) FirstObjectArray;
         if(SecondObjectArray[0] == "string")
              found = true;
              break;
         else
              found = false;
    }Help would be very appreciated.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    astlanda wrote:
    Sure, you're right.
    [public boolean equals(Object obj)|http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html#equals%28java.lang.Object%29]
    sharkura said all the OP needs at the moment. I just wanted to clarify a bit why You don't use == 99.999% of the time with objects, and never with String.
    I have argued elsewhere in these forums that it is inappropriate to tell anyone that you never use == to compare objects. This has not always been accepted. I have, on rare occasions, known experienced developers to blindly compare two objects with equals(), and cite the professor that taught them, 15 years iin the past, that object references are never compared using ==, but always with equals().
    However, the cases where == is appropriate and equals() is not are indeed rare, but not, in my experience, non-existent. In my statement, I probably exaggerated. And String is a case where I can probably accept that you will probably never go wrong with equals(). If the String has been pooled (see String::intern()), you can actually use either. From the javadocs: "*It follows that for any two strings s and t, s.intern() == t.intern() is true if and only if s.equals(t) is true.*"
    ¦ {Þ                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • About Class Object  as Array

    Hello.. I'm beginner in Java Programming
    Now i learn about Array.. i'm not understand about use class object become array. for example i'm create class object Card.
    Then i call Card object to CardTest as main object and Card object called as array.
    can you tell me about how to work Card object as array in CardTest ?
    Edited by: 994075 on Mar 14, 2013 11:55 PM

    994075 wrote:
    yup..thanks guru :DI'm no guru, I just bought a decent Java book 10 years ago and here I am.
    so i guess Object Class can be array :).I don't get that statement. You can store objects in an array, if that's what you mean. An array itself is also an object.
    but i'm not understrand if static method in Card object can be called automatically when Card initialized in CardTest?a) research constructors
    b) you usually don't need static methods, its just something that people new to the language tend to overuse because then you don't have to create object instances. Forget about static methods, try to make it work using regular non-static methods.
    And you really should read and study more, you're coming to the forum way too soon. First get a solid knowledge base, the only thing you're doing now is asking questions that you could have answered for yourself by studying more.

  • Arrays of arbitrary dimensions / Class object for primitive types

    Here's an interesting problem: is there any way to code for the creation of an n-dimensional array where n is only known at runtime (input by user, etc.)?
    java.lang.reflect.Array has a newInstance method which returns an array of an arbitrary number of dimensions specified by the int[] argument, which would give me what I want. However, the other argument is a Class object representing the component type of the array. If you want to use this method to get an array of a primitive type, is it possible to get a Class object representing a primitive type?

    Devil is in the detailspublic class Test2 {
      public static void main(String[] args) {
        Object[] myArray = new Object[10];
        fillDimensionalArray(myArray, 5, 5);
      public static void fillDimensionalArray(Object[] array, int dim, int size) {
        if (dim==1) {
          for (int i=0; i<size; i++) {
            array[i] = new int[size];
            for (int j=0; j<size; j++) ((int[])array)[j]=999;
    } else {
    for (int i=0; i<array.length; i++) {
    array[i] = new Object[size];
    for (int j=0; j<size; j++) {
    fillDimensionalArray( (Object[]) array[i], dim - 1, size);

  • Please help how to set/get a class object in hashtable or hashmap?

    Hi, everybody.
    I'd like to generate a class-object list in hashtable.
    However, compilation is error. Here is my code:
    Hashtable ht = new Hashtable();
    Class tmp_obj;
    tmp_obj = Class.forName("my_class_name_1");
    ht.put("my_class_name_1", tmp_obj);
    tmp_obj = Class.forName("my_class_name_2");
    ht.put("my_class_name_2", tmp_obj);
    Class selected_object = ht.get("my_class_name");
    ^here compilation error: incompitable types
    Could anybody tell me where is wrong in my code and how to
    correct it?
    Thank you in advance.
    Jeff

    Look at the javadoc for Hashtable. The get method returns an Object. You will need to cast it to a Class object.
    Class selected_object = (Class)ht.get( "my_class_name" );If you are using JDK5.0, then you should look up generics.

  • Problem with Dynamically accessing EJB Class objects in WL 7.0 SP1

    I am trying to build a component which has the ability to instantiate and execute
    an known EJB method on the fly.
    I have managed to build the component but when I try and execute it I get a ClassNotFoundException.
    I know that the EJB I am trying to invoke is deployed and available on the server,
    as I can see it in the console, I also seen to have been able to get the remote
    interface of the object, my problem occurs when I try and access the class object
    so I can perform a create on the object and then execute my method
    The code I have written is below:
    private Object getRemoteObject(Context pCtx, String pJNDIName, String pHomeBean)
    throws Exception {
         String homeCreate = "create";
         Class []homeCreateParam = { };
         Object []homeCreateParamValues = {};           
    try {  
    //This call seems to work and doesn't throw an exception     
    Object home = pCtx.lookup(pJNDIName);
    //However this call throws a java.lang.ClassNotFoundException
    Class homeBean = Class.forName(pHomeBean);
    Method homeCreateMethod = homeBean.getMethod(homeCreate,homeCreateParam);
    return homeCreateMethod.invoke(home, homeCreateParamValues);
    } catch (NamingException ne) {             
    logStandardErrorMessage("The client was unable to lookup the EJBHome.
    Please make sure ");
    logStandardErrorMessage("that you have deployed the ejb with the JNDI
    name "+pJNDIName+" on the WebLogic server ");
    throw ne;
    } catch (Exception e) {
    logStandardErrorMessage(e.toString());
    throw e;     
    Any advice would be really appreciated, I'm fast running out of ideas, I suspect
    it has something to do with the class loader but I'm not sure how to resolve it
    Regards
    Jo Corless

    Hello Joanne,
    Congratulations! I'm very happy that you've managed to fix your problem. It's
    always essential to understand how to package applications when deploying on BEA
    WebLogic. Usually, by throwing everything into an EAR file solves just about all
    the class loader problems. :-) Let us know if you have any further problems that
    we can assist you with.
    Best regards,
    Ryan LeCompte
    [email protected]
    http://www.louisiana.edu/~rml7669
    "Joanne Corless" <[email protected]> wrote:
    >
    >
    I've fixed it!!!!!!!!
    Thanks to everyone who gave me help!!!!
    The class loader was the culprit which is what I suspected all along.
    As soon
    as I put the 2 jar files I was using into an EAR file the problem went
    away!!!!!
    Thanks again
    Jo Corless
    "Ryan LeCompte" <[email protected]> wrote:
    Hello Joanne,
    As Mr. Woollen mentioned, I also believe it's a problem with the class
    loader.
    You need to be careful how you arrange your EJBs, because WebLogic has
    a specific
    method in which it loads classes in an EAR, JAR, and WAR file(s). Please
    refer
    to http://dev2dev.bea.com/articles/musser.jsp for more information about
    BEA WebLogic
    class loading mechanisms and caveats. Also, try printing out the various
    methods
    that are available on the object that was returned to you via reflection.
    For
    example, use the getMethods() method, which returns an array of Method
    objects
    that you can subsequently cycle through and print out the various method
    names.
    This way you can discover if the class found/returned to you is indeed
    the one
    you intend to locate.
    Hope this helps,
    Ryan LeCompte
    [email protected]
    http://www.louisiana.edu/~rml7669
    Rob Woollen <[email protected]> wrote:
    I believe the issue is the home interface class for this EJB is not
    available in the class loader which is doing the reflection.
    If you do:
    getClass().getClassLoader().loadClass(homeInterfaceClassName)
    I suspect it will fail. Reflection still requires that the class be
    loadable.
    -- Rob
    Joanne Corless wrote:
    Hi Slava,
    If I make my code look like you describe below I get a compliationerror telling
    me that
    home.getMethod() is not recognised (no such method)
    If I change it slightly and use
    Method homeCreateMethod =
    home.getClass().getMethod(homeCreate,homeCreateParam);
    The code will compile OK but when executed it still throws a NoSuchMethodException
    Any ideas ?
    Thanks for your help so far
    Regards
    Jo Corless
    Your code should look like
    Object home = pCtx.lookup(pJNDIName);
    Method homeCreateMethod =
    home.getMethod(homeCreate,homeCreateParam);
    return homeCreateMethod.invoke(home, homeCreateParamValues);
    Regards,
    Slava Imeshev
    "Joanne Corless" <[email protected]> wrote in message
    news:[email protected]...
    Hi Ryan,
    I also wanted to mention that if you do a "header search" in this
    particular
    newsgroup
    with the search query as "reflection", you will see many previousmessages
    regarding
    reflection and EJBs. I believe you could learn a lot from thedifficulties
    that
    others have faced and solved.I tried that and although there was a number of similar cases noneof them
    actually
    seem to fix my issue. Thanks for the suggestion though
    Are the EJBs that you are trying to access accessible via your
    system
    classpath?
    Try to avoid having them accessible via the main system classpath,and
    only bundle
    them in your appropriate EJB jar files (contained in an EAR file,for
    example).Maybe I should have laid the problem out a little clearer.
    I have a number of EJB's bundled up in a JAR file which is hot deployedto
    the
    server. Within this first JAR file is an EJB (SSB) component that
    needs
    to
    be
    able to invoke a known method on another EJB. This second EJB may
    or
    may
    not be
    within the first JAR file but it also will be hot deployed.
    The component trying to invoke the method on the 2nd EJB has to
    be
    able to
    create
    an instance of the 2nd EJB without actually knowing anything bar
    a
    JNDI
    Name which
    is passed in at runtime.
    I can get as far as doing the
    Object home = pCtx.lookup(pJNDIName);
    This returned a class with the name
    "com.csc.edc.projects.allders.httppostoffice.postman.PostmanBean_mp8qy2_Home
    Impl_WLStub"
    My problem seems to occur when I try and invoke the create method
    Method homeCreate = home.getClass().getMethod("create", new Class[0]);
    My code throws a java.lang.NoSuchMethodException at this point so
    I
    am
    unable
    to progress to the next step of :
    Object bean = homeCreate.invoke(home, null);
    So I can return the instantiated bean back to the calling client.
    Why am I getting the NoSuchMethodException, is is because I am gettinga
    stub
    back rather than the home interface and if so how do I get the truehome
    interface
    from the bean
    Thanks in advance
    Jo Corless

Maybe you are looking for

  • I recently found my old Ipod 4, I cant download apps

    I restarted it and removed all restrictions and it still refuses to work -.-, ive looked up EVERYTHING i have searche dover and over and it doesnt work WHAT THE **** IS WRONG WITH THIS STUPID ******* THING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :'(

  • MRP recommendation -- Do a Stock transfer instead of Purch or prodn Order..

    With the MRP report recommendations you can either select to  fulfill the recomendation by Purchase Order or Production Order. is it possible to add another option i.e Stock Transfer. I.E Customer has mutliple warehouses in different regions and they

  • Java fx text editor

    Hi guys, I'm new of Java Fx technology, that I find fantastic! What I want know is to embed in my java fx application a rich text editor (like a smart word processor). What I need is this: 1) open a document format in text editor 2) perform formattin

  • Wheres my launch triangle in FB 4.5?

    Could someone please tell me why the triangle used to launch a project is not on my toolbar in Flash Builder 4.5? Instead I have a similar triangle with a red tool box and a tool tip that reads External Tools. I just imported my project from Flash Bu

  • Why does the frame color change to black when I copy and paste between documents?

    Copying and pasting between documents in Indesign. The color of the text stays the same but the lines and frames change from a specified color to black. Also changes when I drag and drop can anyone tell me how to fix this?