New @ RMI need help with  java.rmi.UnmarshalException: error unmarshalling

Hi @ all out there,
I'm new with Java RMI and have to write a EventSystem for an college project where clients can subscribe to a topic and get notified when someone publishes a message to the subscribed topic.
At server-side I have a class called EventSystem that provides methods for subscribing and unsubscribing from topics, and also for posting messages (for publishers).
To subscribe i thought that the client must specify the topic and also itself ( means that a client calls in this way: obj.subscribe("mytopic", this).
The EventSystem handles a list of all clients, and whenever a new message is posted it goes trough all clients and invokes the handleMessage(String msg) method that all Clients have to provide.
On my local machine without RMi this concept works just great.
I now tried to get it working using RMI , but I get the following Exception when starting the client (the server starts fine) :
Looking up for rmiregistry at 138.232.248.22:1099
Subscriber exception:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
        java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
        java.io.InvalidClassException: SubscriberImpl; SubscriberImpl; class invalid for deserialization
        at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:336)
        at sun.rmi.transport.Transport$1.run(Transport.java:159)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
        at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
        at java.lang.Thread.run(Thread.java:619)
        at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
        at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
        at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142)
        at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:178)
        at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132)
        at $Proxy0.subscribe(Unknown Source)
        at SubscriberImpl.main(SubscriberImpl.java:48)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
        java.io.InvalidClassException: SubscriberImpl; SubscriberImpl; class invalid for deserialization
        at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:293)
        at sun.rmi.transport.Transport$1.run(Transport.java:159)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
        at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.io.InvalidClassException: SubscriberImpl; SubscriberImpl; class invalid for deserialization
        at java.io.ObjectStreamClass.checkDeserialize(ObjectStreamClass.java:713)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1733)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
        at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:306)
        at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:290)
        ... 9 more
Caused by: java.io.InvalidClassException: SubscriberImpl; class invalid for deserialization
        at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:587)
        at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1583)
        at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
        ... 13 moreI googled now for 2 hours but can't resolve the problem alone. As far as I can understand I have to serialize Objects that I want to send to the server, right?
So how can i do this? I've never used serialization till now.
any ideas how to solve this problem?
greets from italy and sorry for my very weak english
bd_italy

A class has been modified after deployment. Stop the Registry, clean, recompile, and redeploy.

Similar Messages

  • Need help with Java always get error

    hey guys need help
    this the problem i get :
    I go to certain websites and I get this error with firefox.
    This Site requires that JavaScript be enabled.
    It is enabled.
    This is the one of the errors in java script console with firefox.
    Error: [Exception... "'Component does not have requested interface' when calling method: [nsIInterfaceRequestor::getInterface]" nsresult: "0x80004002 (NS_NOINTERFACE)" location: "<unknown>" data: no]
    I have installed the java script from there home site and did a test and says everything is fine. Any ideas?
    please help

    Hi 49ers,
    Sorry not to have any real idea of how to help you out here, but this is a Java forum, not JavaScript.
    Some Firefox expert may stumble across your post and be able to offer some advice (I hope they do) but this isn't really the best place to post such questions.
    Try here: http://www.webdeveloper.com/forum/forumdisplay.php?s=&forumid=3
    Good luck!
    Chris.

  • Need help with java.lang.UnsatisfiedLink Error

    hello,
    i'm trying to access a channel using Java Channel Access(JCA) on HP UX
    [please ref for documentation: http://www.aps.anl.gov/xfd/SoftDist/swBCDA/jca/doc/index.html]. I set the java.library.path to the directory where my JCA libraries are. But I get the following error and finally core dump when I try to load the library, libjca.sl or even when I comment out the lines that load the library.
    Any help would be appreciated. Thanks, Srik.
    My Source code looks like this:
    try{
    System.out.println(System.getProperty("java.library.path"));
    try{
         //System.loadLibrary("libjca.a");
         System.loadLibrary("libjca.sl");
    }catch(UnsatisfiedLinkError ule){
         ule.printStackTrace();
    Ca chanAcc = new Ca();
    chanAcc.init();
    System.out.println("Hello: Connected to Channel");
    PV procvar = new PV("ioc:heartbeat");
    chanAcc.flushIO();
    String host = procvar.hostName();
    System.out.println("Host: "+host);
    procvar.clear();
    chanAcc.exit();
    }catch(Exception e){
    e.printStackTrace();
    Error:
    java.lang.UnsatisfiedLinkError: no libjca.sl in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1419)
    at java.lang.Runtime.loadLibrary0(Runtime.java:788)
    at java.lang.System.loadLibrary(System.java:832)
    at ChAccess.main(ChAccess.java:12)
    aCC runtime: Error 215 from shl_findsym(/cs/prohome/lib/libcsue.sl.v5,_shlInit)
    /usr/lib/dld.sl: Unresolved symbol: typeid__XTQ2_3std9exception_ (data) from /cs/prohome/lib/libcsue.sl.v5
    /usr/lib/dld.sl: Unresolved symbol: Cclassic_table__Q2_3std5ctypeXTc_ (data) from /cs/prohome/lib/libcsue.sl.v5
    /usr/lib/dld.sl: Unresolved symbol: __nullref__Q2_3std12basic_stringXTcTQ2_3std11char_traitsXTc_TQ2_3std9allocatorXTc__ (data) from /cs/prohome/lib/libcsue.sl.v5
    /usr/lib/dld.sl: Unresolved symbol: __ct__Q3_3std8ios_base4InitFv_1 (code) from /cs/prohome/lib/libcsue.sl.v5
    /usr/lib/dld.sl: Unresolved symbol: Cfire_event__Q2_3std8ios_baseFQ3_3std8ios_base5eventb (code) from /cs/prohome/lib/libcsue.sl.v5
    /usr/lib/dld.sl: Unresolved symbol: __dt__Q2_3std9exceptionFv (code) from /cs/prohome/lib/libcsue.sl.v5
    /usr/lib/dld.sl: Unresolved symbol: Cinitfacet__Q2_3std5ctypeXTc_FRCQ2_3std6locale (code) from /cs/prohome/lib/libcsue.sl.v5
    /usr/lib/dld.sl: Unresolved symbol: Cvformat__Q2_3std14__rw_exceptionFiPd (code) from /cs/prohome/lib/libcsue.sl.v5
    /usr/lib/dld.sl: Unresolved symbol: do_out__Q2_3std14codecvt_bynameXTwTcT9mbstate_t_CFR9mbstate_tPCwT2RPCwPcT5RPc (code) from /cs/prohome/lib/libcsue.sl.v5
    /usr/lib/dld.sl: Unresolved symbol: __dt__15_HPMutexWrapperFv (code) from /cs/prohome/lib/libcsue.sl.v5
    /usr/lib/dld.sl: Unresolved symbol: do_in__Q2_3std14codecvt_bynameXTwTcT9mbstate_t_CFR9mbstate_tPCcT2RPCcPwT5RPw (code) from /cs/prohome/lib/libcsue.sl.v5
    /usr/lib/dld.sl: Unresolved symbol: __dt__Q3_3std8ios_base4InitFv (code) from /cs/prohome/lib/libcsue.sl.v5
    ABORT instruction (core dumped)

    hi jonas..
    thanks for the reply. actually I set SHLIB_PATH on HP UX which is the equivalent of LD_LIBRARY_PATH and i'm trying to load the library using
    System.loadLibrary(..) and i type out the path using System.getProperty to make sure that the path to the library is included.
    but still i'm getting the error.
    i'd appreciate any suggestions.
    thanks in advance.

  • Urgent: im new and need help with this task!

    I need help with converting the pseudo code to java code, Any help will b greatly appreciated!
    // Declare a variable of type int, called "choice".
    // Generate a random number between 0 inclusive and 7
    // exclusive, and store that number into the variable
    // "choice". (How do you generate a random number? Use the
    // nextInt(int) method inside the random object, which takes
    // a single int parameter. You can read about this method
    // here:
    // http://java.sun.com/j2se/1.5.0/docs/api/java/util/Random.html
    // If "choice" is equal to 0, then create and return a new
    // IBlock object, passing "game" as the parameter to IBlock's
    // constructor.
    // Otherwise, if "choice" is equal to 1, then create and
    // return a new TBlock object, passing "game" as the
    // parameter.
    // Otherwise, if "choice" is equal to 2, then create and
    // return a new OBlock object, passing "game" as the
    // parameter.
    // Otherwise, .... etc ....
    // (please continue to do this for all of the 7 kinds of block
    // that can be created)

    import java.util.*;
    public class Echo{
         public static void main(String[] args)     {
              //System.out.println("enter ur choice");
    Random r=new Random();
    int choice=r.nextInt(6);
         switch(choice)
         case 0:
              IBlock object0=new IBlock("games");
              break;
         case 1:
              TBlock object1=new TBlock("games");
              break;
         case 2:
              OBlock object2=new OBlock("games");
              break;
         case 3:
              LBlock object3=new LBlock("games");
              break;
         case 4:
              JBlock object4=new JBlock("games");
              break;
         case 5:
              SBlock object5=new SBlock("games");
              break;
         case 6:
              ZBlock object6=new ZBlock("games");
              break;
    class TBlock
         TBlock(String s)
              System.out.print("TBlock called"+"\n value passed is "+s);
    class IBlock
         IBlock(String s)
              System.out.print("IBlock called"+"\n value passed is "+s);
    class JBlock
         JBlock(String s)
              System.out.print("JBlock called"+"\n value passed is "+s);
    class OBlock
         OBlock(String s)
              System.out.print("OBlock called"+"\n value passed is "+s);
    class LBlock
         LBlock(String s)
              System.out.print("LBlock called"+"\n value passed is "+s);
    class SBlock
         SBlock(String s)
              System.out.print("SBlock called"+"\n value passed is "+s);
    class ZBlock
         ZBlock(String s)
              System.out.print("ZBlock called"+"\n value passed is "+s);
    }

  • I need help with Mavericks Server: an error occurred while configuring your server.  I

    I need help with Mavricks Server, I get the following: an error occurred while configuring your server.  I have deleted the Server.app several times along with the associated com.apple and Server folder.  Any more help would be appreciated.

    There are usually some log files around, related to the installation.  See if Console.app (Applications > Utilities) shows anything relevant to the error, when you've done a fresh install of Server.app and tried the configuration.

  • Need help with java will even pay

    I need extreme help. I just don't have time lately to write these programs and I have fallen extremely behind. Basically all I need is to pass this class and right now until I can get some more help I just can't make the deadlines. If someone could help me I will pay you just like a tutor.
    Requirements for Lab.
    You will need to develop a variety of classes for this lab. Specifically, you need to create:
    +1. a "PersonGUI" class that displays fields for a person's: firstName, lastName, identificationNum, and sex.+
    +2. a "StudentGUI" class that provides Java components for the entry of: classification (freshman, sophomore, junior, senior, or graduate student), and Checkboxes for (a student being in the Honor's program and/or in the ROTC).+
    +3. a "FacultyGUI" class that provides Java components for the entry of: rank (instructor, assistant, associate, or full professor), years of service, and salary.+
    +4. a "Statistics" class that, when instantiated, creates an object containing an instance variable for each of the the statistical values outlined below. (Each of these instance variables should be declared to be "private".)+
    Your main Lab6 class should provide a means for the user to:
    +1. Specify the kind of personal data to be entered (Student or Faculty), and+
    +2. Then, depending on the choice made, appropriate fields should be displayed to allow the user to input appropriate information for the type of personal data being entered, and+
    +3. Controls that support the following functionality:+
    * a "CANCEL" control that will terminate any operation currently being performed and return the user to the "Startup" window.
    * a "SAVE" control that will cause the just entered data to be harvested from the graphical user interface and the appropriate statistics to be updated. Note: this function may NOT be performed if any of the student or faculty member data fields have not been filled in.
    * a "RESET" control that will erase all information recorded to date (i.e., all summary variables are reset to zero).
    * a "CLEAR" control that will erase all fields for the personal data currently being entered.
    * and a "DISPLAY TOTALS" control that will display, when pressed, the following data:
    +1. For students:+
    +1. total number of students entered so far,+
    +2. number who are male and number who are female,+
    +3. number of freshmen, sophomores, juniors, seniors, and graduate students,+
    +4. number of students who are in the Honor's program and number who are in the ROTC.+
    +2. For faculty:+
    +1. total number of faculty entered so far,+
    +2. number who are male and number who are female,+
    +3. the name and salary of the highest paid faculty member on campus.+
    Your program should validate numeric data to the extent:
    +1. no numeric field (id number, years of service, or salary) may be left blank by the user. If done so, the user should be alerted to enter a numeric value.+
    +2. when the user enters a "years of service" value for a faculty member - the value entered should be verified to be a valid integer value in the range 1 to 50. If the data entered is outside the valid range or is not a valid integer - your program should reject the value and prompt the user that invalid data has been entered and that a new value is necessary.+
    +3. when a faculty salary is entered, verify that it is a floating-point value in the range $35,000 to $200,000. Handle invalid data as described above.+
    +4. Similarly, if an invalid integer value is entered for the identification number, the value should be rejected and the user prompted to reenter.+
    +5. Information should not be saved, nor should statistical values be updated, until all numeric data has been validated.+
    Note -- You will be graded on appropriate use of instance vs. local variables, use of methods, and passing parameters and returning appropriate values.
    +1. The 'Statistics" class MUST provide "mutator" and "accessor" methods that are required to access values or to modify the values of any variable. REMEMBER ALL VARIABLES ARE DECLARED TO BE "private"!!+
    +2. You should implement methods to verify the data, as detailed above. The methods should return boolean values indicating whether the data is acceptable or not.+

    Sorry to hear about your problems - lack of time, having fallen behind, imminent failure etc - but none of these are Java problems.
    This site deals with Java problems: compiler or runtime behaviour that people can't understand. If you have problems of that sort (and especially if solving those problems would help with the problems you did describe) then post them.
    Otherwise you would seem to be in the wrong place.

  • Need help with java

    ok so i have a midterm and need help this question that is gonna be on the midterm. i dont know how to do it and its worth 16 marks!!!! here it is
    the UW Orchestra wants to produce a CD containing all the pieces of music
    from its upcoming concert. In order to do that, it needs to calculate the total length of time for the
    CD. In addition, the conductor wishes to know which piece of music has the longest duration.
    Sample output for the program.
    The Swan (3.88)
    The Bee (0.98)
    Claire de Lune (6.02)
    Liebesfreund (3.38)
    Ragtime (3.48)
    The total time for the CD is 18.74 minutes.
    The longest piece is Claire de Lune.
    Do not include the HTML that is required to embed the program into a Web page (that is, show
    only what you would write between <script> and </script> tags).
    [4 marks] In the following space, define a function, Print, that takes two parameters, Title and
    Length, and outputs a line of text such that Title appears in italics, followed by Length in
    parentheses. The function also returns the value of Length.
    For example, Print("My World",30) will output the line
    My World (30)
    and return the value 30.
    Put your JavaScript program for the remainder of this question in the space provided on the next
    two pages.
    [9 marks]. For each piece of music, your program should input the title of the piece and the
    duration (in minutes) for that piece, and it should output a line showing those values using the
    Print function just defined. After all pieces have been listed, the program should output the
    total length of time for the CD, adding in 0.25 minutes between each piece of music (which is
    needed on the CD to separate the pieces).
    [3 marks] The program should also output the name of the piece that has the longest playing
    time.
    Use reasonable variable names, indentation and good programming style. Documentation and
    comments are not required, but you may add them to explain any assumptions you might want to
    make. You need not check that the input is valid, and you may assume that no two pieces have the
    same duration.
    can anyone help me out! i would be indebt of ur kindness if u can help me out!

    This forum is for Java, not JavaScript. The two have nothing to do with each other.
    And anyway, this is your studying, so you should try to do it, put forth your best effort, and ask specific questions (on the proper fourm).

  • Need help with java J2Se 5.0 upgrade 2

    Having problems with Java when playing on Pogo, the Vaults of Atlantis. When loading, I am getting a message that says that I need to remove and download again, java. That it is not working correctly. I did that yesterday, 05/27/05 and am still experiencing the problem but only after signing off from Pogo and AOL and then trying to sign back on again later in the day. I have to shutdown my computer and bring it back up again and then I can load the Vaults of Atlantis. I have noticed that when I do sign-off from Pogo and AOL, that my java cup stays on in my deskbar. Is that supposed to be normal or is it supposed to disappear? If it is supposed to disappear, what can I do to fix that problem?
    Please, can anyone help?

    Go here http://www.java.com/en/ and click "Download Now".
    If that has problems, click the "Manual Download" link and download the "Windows (Offline Installation)".
    If there are problems, review the Help information to resolve.

  • Need help with Java fonts (broken in 10.4.9)

    Hi, folks,
    There was a post late last year (maybe October?) that explained how to fix a problem with Java fonts. (OK...I know NOTHING, but I am able to follow directions!)
    I play games on Yahoo.com (Literati and Word Racer) that now have unreadable fonts since I upgraded 3 days ago. I seem to remember last year's fix had something to do with disabling fonts. I just can't remember what to do and have spent an hour looking for the post.
    If you can find it - or tell me what to do - I'd appreciate it. Remember, I need really specific directions.
    Thanks.
    iMac duo core   Mac OS X (10.4.9)  

    I am able to set up a new account and work but even after deleting all preferences the problem persists in my admin account.
    I'll try to look for any font corruption and clear font cache but having to reinstall the OS is a real drag. Not sure why PS should corrupt the OS, itself.
    Any chance I can uninstall and remove PS then install again?

  • Need help with Java programming installation question

    Sorry for my lack of knowledge about Java programming, but:....
    A while back I thought I had updated my Java Runtime Environment programming. But I now apparently have two programs installed, perhaps through my not handling the installation properly. Those are:
    J2SE Runtime Environment 5.0 update 5.0 (a 118MB file)
    and:
    Java 2 Runtime Environment, SE v 1.4.2_05 (a 108MB file)
    Do I need both of these installed? If not, which should I uninstall?
    Or, should I just leave it alone, and not worry about it?
    Yeah, I don't have much in the way of technical knowledge...
    Any help or advice would be appreciated. Thank you.
    Bob VanHorst

    Thanks for the feedback. I think I'll do just that. Once in a while I have a problem with Java not bringing up a webcam shot, but when that happens, it seems to be more website based than a general condition.

  • Need Help with Java Homework

    This is my first post here, seeking some help with my java homework. I am required to create a program to write out a receipt for a pizza company: name of company, total number of pizzas, costs (including tax etc), and print out the receipt after taking an order from the customer.
    This is a beginner's java class and my book isn't very good at explaining (mainly because it says "will be discussed in ch 14" when we're in ch 1-3 and it's an essential part of the program).
    But anyways, if anyone is up right now, would be helpful for some help. I have a general idea of what I wanna do, but the program so far is very messy and incomplete and having trouble getting it to look nice and proper.

    well there were two ways of doing this, im only 2 weeks new in java so bear with me.....I was gonna set 3 classes, one appclass, one order form, and one receipt. I was told you can combine the order and receipt in 1 class, but I thought doing 3 woudl be better to help me learn more...anyways, I haven't worked on the appclass yet, but for the order I have a very messy set of codes. I know that it's wrong but it's a start, im looking for any input cause the book does not explain very much.
    For the order class, I will be doing showinputdialog boxes for how many pizzas, the sizes, and the toppings. Here is what I have so far ( i know it is VERY messy and disorganized but I am a bit lost in where I should go next):
    * @author AlexNguyen
    * To take the order with number of pizzas and toppings
    package project2;
    import javax.swing.JOptionPane;
    public class Order {
         public int NumberOfPizzas;
         public char Pepperoni;
         public char Sausage;
         public char Cheese;
         public Order(int n) {
         NumberOfPizzas = n;
         JOptionPane.showInputDialog("Enter Number of Pizzas"));
    String ptype; {
         public void start();
         public void takeOrder();
         public void writeReceipt();
              public void takeOrder();
              ptype = Topping
    public String selectPizza(char P, char S, char C) {
         Pepperoni = P;
         Sausage = S;
         Cheese = C;
    public void numPizza(int numberOfPizzas) {
         num = numberOfPizzas;
    JOptionPane.showInputDialog("Topping for Pizza?");
    JOptionPane.showInputDialog("Pizza Size?");
    JOptionPane.showInputDialog("Number of Pizzas?");
    }

  • Need Help with Java Desktop CP Icon

    I just formatted and reinstalled Windows XP Home SP2 and installed the JRE 1.5.0.02. I usually see an icon in my Control Panel but it only appears in the Administrator's CP which I can reach in Safe Mode of course, but it would be easier to deal with if it appeared somewhere on my desktop/taskbar or CP (I am also an Admin). In Safe Mode I made sure that the right settings were made for displaying, but it doesn't.
    I know precious little about Java so I need help here.

    This forum is dedicated to Sun's Java Desktop System, an alternative desktop operating environment. Try reposting here:
    http://forum.java.sun.com/forum.jspa?forumID=54

  • Need help with Java Script to perform a calculation in Adobe Acrobat Pro 9 form

    I have a form (test) that I am creating in Adobe Acrobat Pro 9.
    I need help creating custom Java Script so I can get the desired answer.
    1) There are several questions in each group that require a numerical answer between 0-4
    2) There is a total field set up to sum the answers from all above questions
    3) The final "score" takes the answer from Step 2 above and divides by the total possible answer
    Any help on what Java Script I need to complete this would be greatly appreciated!
    I've attached a "spreadsheet" that shows it in more detail as well as what formulas I used in Excel to get the desired end result.
    Thanks in advance.

    Have you tried the "The field is the average of:"?

  • Need help with Java classwork

    I am a student who is new to Java (less than a week) and we were given some problems to solve. I got all of them except this one, and was wondering if yall could hep me out. Here it is:
    Given a strand of DNA determine the percentage of cytosine and guanine nucleotides present in the genome. The strand is represented by a string containing only the lowercase characters 'c', 'g', 't', and 'a'. Your method should return the percentage (between 0.0 and 1.0) of 'c' (cytosine) and 'g' (guanine) in the genome. For example, if half of the nucleotides are 'c' or 'g' your method should return 0.5.
    The teacher has a set of solutions that test my code and sees if it works for all scenarios. Here is my code:
    public class DNAcgcount
    public double ratio(String dna)
    int count = 0;
    int size = dna.length();
    for (char item_from_dna: dna.toCharArray())
    if ((item_from_dna == 'c') || (item_from_dna == 'g'))
    count ++;
    return count/size;
    and everytime i test it I get an error message for 8/12 of the tests saying :
    runtime exception:java.lang.ArithmeticException: / by zerojava.lang.ArithmeticException: / by zero at DNAcgcount.ratio(DNAcgcount.java:20) at Tester$1.run(Tester.java:45) ""
    Any help would be greatly appreciated!
    Edited by: 03blackgt on Nov 19, 2007 7:39 AM

    03blackgt wrote:
    runtime exception:java.lang.ArithmeticException: / by zerojava.lang.ArithmeticException: / by zero at DNAcgcount.ratio(DNAcgcount.java:20) at Tester$1.run(Tester.java:45) ""
    This error message is telling you that you're dividing by zero on line 20 of DNAcgcount. Find that line and figure out when the denominator can be 0, and what you can do to prevent that.

  • New laptop need help with itunes.

    okay so i got a new laptop for xmas and i want to transfer my songs from my old desktop to my laptop. is there a way i can load my ipod onto my laptop and use that to transfer songs.
    my friend said that when i plug in my ipod to my blank itunes it will erase my songs. is there a way to download my songs to my laptop from my ipod?
    i really need help!
    THanks for the help.
    xo kaiit
    windows dell Windows XP

    Your friend is right. the iPod cannot be used to update iTunes. I had the same problem about a year ago, and I just transferred each song using my jumpdrive. It's painstakingly boring, but it will work without wiping anything clean.

Maybe you are looking for

  • Is there any way to change the default search parameters in Mail?

    When I do a search it only checks "Today" instead of "Inbox."  So then I have to select Inbox and reenter my search.  Not a huge deal, but a bit bothersome. Any way to just set it to search "Inbox" by default instead of "Today?"

  • Can't get rid of $$!!X# Norton Utilities login screen

    Ages ago - ages-- I dumped Symantic and Norton Utilities from my work Mac and my laptops. Erased every fine I could find with Norton or Symantec in it. Yet everytime I boot up my mac or laptop, I get a Norton message window (shortly after most of the

  • Error in assigning the tax group in SRM-IMS

    Hi All, I am getting an error "Error in assigning the tax group" and when checking thru BBP_PD, message number BBP_PD, 047. When posting a non PO based invoices from IMS this error is appearing however when I am creating same invoice from XML and pos

  • Dividing a pricing condition in several invoices

    In the client the invoices are split based on the customer purchase order number in the sales order. But only one invoice is required to be printed for the same customer. Because in the custom they pay a custom fee for each invoice. Now they prepare

  • Object Execution Question

    I need to use two user defined objects set object A and object B here is the pesudocode: while(x != -1) setUserDefinedObject(input) // ten miliseconds pass getUserDefinedObject(output from class)how do I tell it after the allocated time to continue o