Question abput Extending Classes

Hi,
Would anyone know if the following is valid??
class A extends B{}
class B extends A{}
Thanks in advance...

It is a cyclic inheritance error if a class or interface inherits from itself, even directly (i.e., it appears as its super-class or in its list of super-interfaces) or indirectly (i.e, one of its super-class or one of its super-interfaces inherits from it)A cyclic inheritance error is reported

Similar Messages

  • Question about extending classes

    Hi
    I've created my own class that extends javax.swing.JTextField as follows:
    public class myTextField extends javax.swing.JTextField{
         public myTextField(){
              super();
              initialize();
         protected void initialize()
              super.setEditable(false);
              super.setHorizontalAlignment(javax.swing.JTextField.LEFT);
              super.setBorder(null);
              super.setSelectionColor(null);
    }Dunno if this is the best way to do it, but it works, so I'm happy!
    My question is: Is it possible to have more than one definition in this class?
    For example, a myTextField2 that extends JTextField with completly different attributes (eg, different back ground colour etc) or do I have to create a new class?

    For example, a myTextField2 that extends JTextField
    with completly different attributes (eg, different
    back ground colour etc) No, but you can create another constructor that accepts different arguments.
    public myTextField(Color c)Like that. By the way class names should start with an upper-case character.

  • Can not filter the data with the extended class

    Hi,
    I have a quick question about PortableObject format. I have created a class which extends PortableObject interface and implemented serializer methods as well. I have updated it in the pof-config.xml file as well. If I insert the objects of this type of object in the cache, they get inserted properly and I can filter the values based on the getters defined in the class. Everything works fine here.
    Now, I am trying to extend the existing class that I have. We have our custom API which we have built for our domain objects. I need to store these objects in the cache. So, naturally I need to implement PortableObject interface to do that. So, instead of creating a new class with new set of getters and setters and local fields, I am extending our domain class to create a new class which implements PortableObject interface. Instead of defining the local fields and getters and setters i am reusing the ones provided by my existing class. Now, I can insert the objects of the new class to the cache. But I can not filter the values for the objects of this new class.
    Let me show you what exactly I am trying to achieve by giving a small example:
    Domain Class:
    class Person
    private String person_name;
    *public String getPerson_name() {return person_name;}*
    *public String setPerson_name(person_name) {this.person_name = person_name;}*
    The new class implementing PortableObject interface:
    class ExtPerson extends Person implements PortableObject
    public static final PERSON_NAME = 0;
    *public void readExternal(PofReader reader) throws IOException{*
    setPerson_name(reader.readString(PERSON_NAME));
    *public void writeExternal(PofWriter writer) throws IOException{*
    writer.writeString(PERSON_NAME, getPerson_name());
    *// And HashCode, Equals and ToString methods, all implemented using the getter from the Person class*
    So, if I create a new class ExtPerson without extending the Person class and write all the methods, store the objects in the cache and perform the following query, I get the size printed
    System.out.println((cache.entrySet(new EqualsFilter("getPerson_name","ABC"))).size());
    But if I use the extended class and insert the values into the cache and if I use the same query to filter, I get 0 printed on the console.
    System.out.println((cache.entrySet(new EqualsFilter("getPerson_name","ABC"))).size());
    So, can anyone tell what exactly is causing this?
    Thanks!

    Well, just a quick question. It seems that I can not get ContainsAnyFilter or ContainsAllFilter working.
    EqualsFilter is actually working properly.
    I am preparing a Set of Strings and passing it to ContainsAnyFilter or ContainsAllFilter and it is returning me 0 records.
    E.g.:
    Set<String> setStr = new HashSet<String>();
    setStr.add("ABC");
    setStr.add("DEF");
    System.out.println((cache2.entrySet(new ContainsAnyFilter("getPerson_name", setStr))).size());
    I get 0 in my output
    If I try this:
    System.out.println((cache.entrySet(new EqualsFilter("getPerson_name","ABC"))).size());
    System.out.println((cache.entrySet(new EqualsFilter("getPerson_name","DEF"))).size());
    I get 1 for each of the query.
    If I club all these EqualsFilter in a Filter[] array and create an AnyFilter or AllFilter and pass it to the query, it works fine.
    List<Object> lst = new ArrayList<Object>();
              lst.add("ABC");
              lst.add("DEF");
    Filter[] filter = new Filter[lst.size()];
         for(int i=0;i<lst.size();i++)
              filter[i] = new EqualsFilter("getPerson_name",lst.get(i).toString());
    AnyFilter fil = new AnyFilter(filter);
    System.out.println((cache4.entrySet(fil)).size());
    I get the desired result here, which is 2.
    Am I missing something here?

  • Question Re: Extending AbstractList

    Hi,
    I'm trying to create a custom collection class (MyList) which functions similarly to a LinkedList and will contain elements of MyClass but where I can override the add(), remove() and get() methods. Rather than having those methods operate on the position of the element in the list I want them to function by examining a specific value of each MyClass element (using a for each loop and MyClass.getId() for example). I would also make add() check for duplicate ID's before adding a new MyClass to the list. Additionally, I'd like maintain the for each looping ability of a list externally so from MyOtherClass I can loop on MyList directly. Anyway, my research led me to conclude that extending AbstractList was the approach I needed to take, although I've listed other alternatives that occurred to me below.
    There are a couple of things I'm confused about though and I'm having a hard time find answers to these specific questions.
    1. Do I need a instance variable which will hold the items in my list? For example, do I need to have an ArrayList<MyClass> or LinkedList<MyClass> internally in MyList? If so, I'm confused on how to make the for (MyClass myClass : MyList) loop work.
    2. If I don't have the above, what's the proper way to implement the size() method?
    3. This is my class declaration...it works but it feels wrong...is it actually the correct way to do it?
    public class MyList extends AbstractList<MyClass>4. I'm using this class as a singleton using what I read was a thread safe method (code follows). Are there additional considerations I need to make for the overridden methods or the class declaration? I'm using a public static final instance variable like this:
    public final static MyList INSTANCE = new MyList();And then accessing it like this:
    MyList myList = MyList.INSTANCE;Probably overly complicated but I need to make sure my app is only ever using one list. Anyway, I've tried very hard to find some examples but no joy. In the end I think I have 3 choices:
    1. Copy LinkedList and change the methods I need. For some reason that feels like major overkill. I'm willing to do it if it's the best way though.
    2. I could extend LinkedList but that presents a couple of problems also. First, it's not a good idea to extend concrete classes (or so I read) and second, I can't then override the add method which is the whole point.
    3. The last alternative my limited brain power can come up with, but which makes me lose the for each looping I think, is to just make a non-extending class and manipulate an internal LinkedList. I also lose the ability to have my parameter be a List instead of MyList.
    While I could probably force any of the above to work I'm trying to bend my brain, learn something new, and come up with an elegant solution. Any feedback or advice is appreciated.
    Thanks,
    Pablo

    You can do that. Do you intend to modify the set from multiple threads, or create it in one thread and iterate over it in multiple others?Yes, items can be added and removed from multiple threads, as well as updated.
    I don't recall you saying that. It sounds like you might actually want a SortedMap.True, I didn't explicitly state that, but I believe I did imply it by saying I wanted to override add(), get() and remove() to use the id.
    I have no idea what you mean by that first bit. Do you mean you want a single iterator used by multiple threads, as opposed to multiple threads each having their own iterator?Sorry, I have a hard time explaining myself when trying to learn something new I guess. Yes, multiple threads will need their own iterator I believe. There is a display table showing various properties of each item, then there are currently two different processes which poll the list for specific statuses of each item (like ReadyToSend or Pending) and do independent tasks. These processes are based on a single abstract class since they are both web service clients but with different request/response implementations. My thought was that each of these processes (3 so far) would need their own iterator or possibly their own subsets from the master list based on status. I haven't gotten that far so I don't know. Another process is checking for newly submitted requests which come from an external system via files. It parses the file, stores the object values in the database, and then adds the item to the list. Rather than adding the item directly I was going to pass only the item ID to the add() method and use the factory class I've already created to create a new item from the database to add to the list. This is to pick up valid timestamp values from the record (they're inserted using CURRENT_TIMESTAMP rather than Timestamp objects). The alternative was to store the item and then read it back again. That seemed less elegant. This is the only process doing adds. The ID is actually an externally derived number which is supposed to always be unique but there's nothing to prevent a duplicate. I planned on using the list to control duplicates. If a duplicate is added it's status would be changed in the database to indicate that and it would not be added to the list.
    [Clarification] While the list itself will be accessed from multiple locations, I don't expect any individual item to be accessed simultaneously. I have a feeling that's an important distinction. The processes reading and modifying each item will be working on specific their own specific item status.
    A lot of this is still roughed out only and needs more refactoring. I started the refactoring by working on the list first. I was passing around an open ResultSet which I know is bad but it allowed me to flesh out the rest more quickly. Good idea or not it's what I did.
    Anyway, there would seem to be multiple classes needing access to the list for multiple reasons and yet the list needs singularity to prevent duplicate tasking. I didn't want to get into having to remove the item from one list and add it to a different one when the status changed. I figured the easiest thing to do was have a master list class of some type and have all the various classes use that as a singleton.
    Sorry, not a very succinct explanation I guess but we weren't getting far with me beating around the bush with abstract MyXXX examples. Does this change your thoughts on my implementation idea?
    Read that chapter of Effective Java. If the chapter you're referring to is Chapter 3, I finally found it and I will read it. There is also a Chapter 5 which deals with Generics but doesn't have any mention of equals() which I'm reading also. And, I ordered the book. ;-)
    The bottom line is I still don't understand how I can have a single instance of a TreeMap or SortedMap or MapOfNarnia without having a class to contain it and offer it to calling classes. I realize this is probably a stupid question, but exactly how would I do that without doing something like my last MyClasses example?
    Unfortunately I don't have an infinite amount of time to finish this project so I may have to go with a less elegant solution than I hoped. I'm still learning generics and collections and it's obvious I've got quite a bit to learn before I can use them effectively. That being said, which of my bad ideas is the least bad?
    By the way, I just want to say I really do appreciate the effort all you experts put into to answering questions for us newbs. I realize it's a significant investment of your time and I appreciate it.
    Edited by: Pablo_Vadear on Dec 24, 2009 5:14 AM

  • Passing Optional Parameter Via Extended Class Constructor

    Following is a snippet of code I copied and have a question about when extending DataGridColumn class to sort numeric for colums that have numeric values:
    CustomAdvancedDataGridColumn(columnName:String=null,numeric:Object=null)
    super(columnName);
    initCompare(numeric);
    function initCompare(numeric:Object):void
    if (numeric == NUMERIC) {
    sortCompareFunction = numericCompare;
    The extended class is supposed to receive variable "numeric" type Object in the constructor which is then supposed to be used in the initCompare function to determine if a column contains numeric values.  This code didn't work for me as numeric variable remains null.  To get it working I added a new public static const and private propery "numeric" and obtained it with get() set() to see if should the column should sort numeric.  This works but you have to set the property in the extended datagrid column FLEX  tag.
    My question is how is the variable numeric in the code snippet above supposed to get it's new data for the initCompare function?  I can't get it to be anything other than null.
    Thanks for any insights...I'm new to FLEX.
    Jason

    Still searching for a solution.
    Please note, that I'm using the syntax described in
    <a href="http://help.sap.com/businessobject/product_guides/boexir31/en/xi3-1_url_reporting_opendocument_en.pdf">http://help.sap.com/businessobject/product_guides/boexir31/en/xi3-1_url_reporting_opendocument_en.pdf</a>
    on page 65.
    So did I get anything wrong? Help would be really appreciated, also Workarounds if there's no solution for the problem.

  • Authoring Tool "Inherit Class" vs "New Class" vs "Extended Class" Scenario Help

    Hi Community,
    I am currently creating the ground work needed to create Self Service Portal Request Offerings to be used by end users and then take that input and automate it with Orchestrator.
    I'm pretty comfortable with the overall process of how this is done, but I was hoping to get guidance from the community to make sure that I don't waste my time by editing my existing management pack incorrectly from the beginning.
    We currently have a Whole bunch of SR and IR Templates in a Management Pack - lets call it: "Company.Templates.MP" now what I want to do is edit this MP and add new List and String Properties to hold the responses provided from the
    Self Service Portal so that I can use a Runbook Activity to feed these responses into Orchestrator.
    Now what I have done is "Extended" the existing "Service Request" and "Incident" classes and created the new properties in each extended class. Now that I have Extended the default Classes I believe that the properties now apply
    to EVERY existing and new SR and IR.
    My question is... Do you think I have done this correctly?
    I have a gut feeling that I have done it wrong and I should revert my MP changes and then instead of extending the existing IR and SR Classes which affect all existing Work Items, I should create a new SR and IR class which would then be used to create new
    Templates which are then ONLY ones that contain the new properties that would be used for Runbook Automation.
    The feedback I receive will be VERY MUCHLY appreciated...

    Answering your implicit question in the title:
    Inherit is where you create a new class that has all the properties of the parent and then some new ones also, but people can still use the parent for regular work. This is for specialization, like say you want a new type of incident to
    cover firewall problems, and need new properties for the IP and Ports from the portal.
    Extended would be where you add properties to a class that make sense for all of those and all inheriting classes. say the client has a cost of IT tracking system where every Incident and Service Request needs to be assigned a cost of effort
    code, you would create two extensions for Incident and Service request, and point them at the same enum list. you wouldn't extend WorkItem, because changes, activities, released etc wouldn't use a simple cost estimate list value, and you wouldn't inherit off
    of SR and IR because all user requests should have this property, even if some of them are blank  
    New would be a class from scratch that inherits from Entity. This is hardly ever what you want to do, because even completely new things are either work items or config items, and should, where ever possible, inherit from one of those
    basil classes
    Now to your explicit question: No, i think you've done exactly what the situation called for. every SR should have this value, even if it is empty for the historical items.
    two side notes: 1) any item that refers to the base of an extension will continue to work as expected, but  2) Offerings are always the exception. The net of these two rule of thumb guidelines is that your existing templates should continue to work
    without modification, but you may have to recreate the offering before you can use the new property in a question.  
    AFAIK you cannot extend an abstract calls (ex. Work Item), but I could be wrong.
    http://codebeaver.blogspot.dk/

  • References when extending class

    I have a general question about extending a class.
    If I have
    public class B extends A
    does Java create a reference to A and B?
    Imagine I call a method of A with super from a method of B, this method is not static, so I must have a reference, I think.
    Thanks Caroline

    If a class B is a subclass of A, the class A is instantiated when B is instantiated.
    class A{
      A(){;}// default constructor of A
    class B extends A{ // default constructor of B
      B(){
          super();// A is instantiated
    }(The reference to B already refers to A.)

  • Can't get extended class to work with asbstract class

    I am having trouble working an extended class to work with my base abstract class. I keep getting this error message: "Fiction.java:4: invalid method declaration; return type required" public FictionBook()" Can someone give me some advice and or guidance on what I need to do? Thanks.
    Here is my abstract class:
    import javax.swing.*;
    public abstract class Book
         protected String bookTitle;
         protected double bookPrice;
         public abstract double setPrice();
    public Book()
              setBookPrice();
    public double getBookPrice()
              return bookPrice;
    public abstract void setBookPrice();
    Here is the extended class that I have:
    import javax.swing.*;
    public class Fiction extends Book
         public Fiction()
              super();
              setBookPrice();
         public void setBookPrice();
              bookPrice = 24.95;
         public String toString()
              return("Fiction Book Price is $" + bookPrice);
    }

    Fiction.java:2: Fiction is not abstract and does not override abstract method setPrice() in BookThis one is pretty straightfoward: Book declares an abstract setPrice() method. In effect is promises "every concrete subclass of Book will define an implementation of setPrice()". But your Fiction class does not do this - it does not give an implementation of setPrice() even though as a Book it is required to do so. That is what the compiler is complaining about.
    Fiction.java:6: call to super must be first statement in constructorThis one is slightly cryptic. If you use super() it must be as the first line of a constructor. You are using it as the first line of Fiction() so that looks OK - until you realise that Fiction() is not a constructor! That's because you declare it as a method returning void. Remove the "void" and the compiler will recognise it as a constructor and will be happy about your use of super().
    Edited by: pbrockway2 on Sep 13, 2008 12:13 PM
    Just a general point: it might be worth writing very brief comments for your abstract class to say what the methods are supposed to do. It isn't really clear what setBookPrice() is supposed to do given that it isn't passed any argument. Likewise setPrice(), how does it differ from setBookPrice()? what is the double value that it returns?

  • 'My Application Page' is not allowed here because it does not extend class 'System.Web.UI.Page'

    I have a custom SharePoint 2010 solution that includes an aspx page. The aspx page in is in the /layouts folder within the solution and I created it by just adding an application page to the solution. I am trying to create a parent-child relationship between
    two different lists in SharePoint. From the parent I have a custom button on the ribbon that creates a child item with the ID of the parent stamped on it.
    The page is just a processing page that forwards on parameters from the parent to the new child item. (i.e. the ID value)
    The code generated when I add the aspx page is below:
    <%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
    <%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
    <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
    <%@ Import Namespace="Microsoft.SharePoint" %>
    <%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="processingpage.aspx.cs" Inherits="MY.Solution.Layouts.MY.Solution.processingpage" MasterPageFile="~/_layouts/application.master" %>
    <asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
    </asp:Content>
    <asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
    </asp:Content>
    <asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server"> Processing Page </asp:Content>
    <asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server" > Processing Page </asp:Content>
    The code behind is as follows:
    using System;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.Administration;
    using Microsoft.SharePoint.WebControls;
    using Microsoft.SharePoint.Utilities;
    using System.Reflection;
    namespace MY.Solution.Layouts.MY.Solution
    public partial class processingpage : LayoutsPageBase
    protected void Page_Load(object sender, EventArgs e)
    try
    //Get a reference to the SPWeb object
    SPWeb oWeb = SPContext.Current.Web;
    //Use the Parameters That Are Passed In
    SPList thisList = oWeb.Lists[new Guid(Request.QueryString["List"])];
    SPListItem thisItem = thisList.GetItemById(int.Parse(Request.QueryString["ID"]));
    sContentType = thisItem["ContentType"].ToString();
    sContentTypeID = thisItem.ContentTypeId.ToString();
    if (sContentType == "Some Content Type")
    sContentTypeID = "";
    sAIID = thisItem["ID"].ToString();
    //Redirect to newform.aspx with the Appropriate parameters.
    Context.Response.Redirect(oWeb.Url + "/Lists/Blist" + "/NewForm.aspx?AIID=" + sAIAuditID.ToString() + "&ContentTypeId=" + sContentTypeID + "&ParentItemID" + Context.Request["ID"]);
    else if (sContentType == "Some Content Type")
    sContentTypeID = "";
    sAIID = thisItem["AIID"].ToString();
    //Redirect to newform.aspx with the Appropriate parameters.
    Context.Response.Redirect(oWeb.Url + "/Lists/AList" + "/NewForm.aspx?AIID=" + sAIID.ToString() + "&ContentTypeId=" + sContentTypeID + "&ParentItemID" + Context.Request["ID"]);
    else if (sContentType == "Some Content Type")
    sContentTypeID = "";
    sAICID = thisItem["AICID"].ToString();
    //Redirect to newform.aspx with the Appropriate parameters.
    Context.Response.Redirect(oWeb.Url + "/Lists/CList" + "/NewForm.aspx?AICID=" + sAICID.ToString() + "&ContentTypeId=" + sContentTypeID + "&ParentItemID" + Context.Request["ID"]);
    else
    LoggingService.LogError("MY.Solution - Processing Page", "No Applicable Content Type Found.");
    catch (Exception ex)
    LoggingService.LogError("My.Solution - Processing Page", ex.Message);
    finally
    //DO SOME FINAL THINGS HERE WHEN REQUIRED.
    In the page I need to use Request.QueryString to get the values from the URL. But when I deploy the solution and load the page I get the error:
    'MY.Solution.Layouts.MY.Solution.processingpage' is not allowed here because it does not extend class 'System.Web.UI.Page'.
    When I change the line:
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="processingpage.aspx.cs" Inherits="MY.Solution.Layouts.MY.Solution.processingpage" MasterPageFile="~/_layouts/application.master" %>
    to inherit as follows:
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="processingpage.aspx.cs" Inherits="Microsoft.SharePoint.WebControls.LayoutsPageBase" MasterPageFile="~/_layouts/application.master" %>
    it does not work either.
    If I change it to inherit like below:
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="processingpage.aspx.cs" Inherits="System.Web.UI.Page" MasterPageFile="~/_layouts/application.master" %>
    it also does not work.
    What does this error actually mean?  And why doesn't the default code generated by Visual Studio work?

    @NadeemYousuf I have tried this too and it didn't work.  
    What does the error even mean?  And why does the error appear with default Visual Studio code?  In my example I have just added a basic application page with no other code in it and it still does not work.

  • NoClassDefFoundError extending class in separate JAR

    I have a class Foo which gets called from my servlet (extends HttpServlet) class. Both Foo and the servlet class are located in WEB-INF/classes and are deployed as part of the war file. Class Foo extends class Bar, which is a different .jar file located in the /WEB-INF/lib directory of the webapp. When I attempt to create an instance of Foo, I get the following exception:
    java.lang.NoClassDefFoundError: /general/client/common/beans/Bar
         at java.lang.ClassLoader.defineClass1(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
         at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
         at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
         at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1267)
         at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
         at server.DBServlet.createFoo(DBServlet.java:236)
         at server.DBServlet.processInput(DBServlet.java:333)
         at server.DBServlet.doGet(DBServlet.java:154)
         at server.DBServlet.doPost(DBServlet.java:205)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
         at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:419)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
         at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667)
         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
         at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
         at java.lang.Thread.run(Thread.java:595)
    I'm running this on Windows, and found if I added the classpath the the jar file where the Bar class is located, that it worked fine. But my expectation is that the jar file should have been found because it is in the /WEB-INF/lib dir. There is a line the Tomcat docs that says:
    "Last, any JAR containing servlet API classes will be ignored by the classloader. All other class loaders in Tomcat 5 follow the usual delegation pattern."
    So maybe I need to do something special to load the Bar class, or there's something strange about the way the classes and jars are being loaded that I don't fully understand. I was able to instantiate the Bar class directly from w/in my servlet class, I just can't create an instance of the Foo class that is in /WEB-INF/classes along with the servlet class. So I'm not convinced that the Bar class or associated jar file isn't being loaded.
    I don't want to have to set the classpath explicitly, so I'm looking for advice on why I'm getting this exception and how best to dynamically load the classes I need.
    Thanks.
    ab.

    Thanks for hanging in there so far. Here's the specifics if you want to try to re-create this.
    I have a webapp, which contains the class DBServlet:
    package com.hm.dhca.server;
    public class DBServlet extends HttpServlet
    // Stuff
         public void processInput()
              Foo foo = new Foo();
    The webapp also contains the class Foo:
    package com.hm.dhca.common;
    import com.general.client.common.beans.Bar;
    public class Foo extends Bar
         public Foo()
              super();
              System.out.println("Foo");
    Both of the classes are located in webapps\DHCA\WEB-INF\classes...
    The Bar class is in a separate jar called HMJCommon.jar in the webapps\DHCA\WEB-INF\lib dir.
    Class Bar looks like this:
    package com.general.client.common.beans;
    public class Bar
         public Bar()
              System.out.println("Bar");
    DBServlet creates an instance of Foo as:      
    Foo foo = new Foo();
    Which throws the Exception:
    java.lang.NoClassDefFoundError: com/general/client/common/beans/Bar
         at java.lang.ClassLoader.defineClass1(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
         at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
         at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
         at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1267)
         at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
         at com.hm.dhca.server.DBServlet.processInput(DBServlet.java:236)
         at com.hm.dhca.server.DBServlet.doGet(DBServlet.java:154)
         at com.hm.dhca.server.DBServlet.doPost(DBServlet.java:205)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
         at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:419)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
         at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667)
         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
         at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
         at java.lang.Thread.run(Thread.java:595)
    Clues:
    1. All three classes exist in the locations specified above - I have checked this manually.
    2. Within DBServlet, I can create an instance of Bar. But I cannot create an instance of Foo without the exception.
    3. If I move the Foo class from package com.hm.dhca.common to package com.hm.dhca.server (same package as DBSerlvet), everything works fine.
    4. If I modify Tomcat's classpath to include the HMJCommon.jar, it works fine (as previously discussed).
    Theory:
    I have a vague theory that what is happening is that two different webappclassloaders are loading the Foo and Bar classes, for whatever reason. As a result, they can't see each other, because neither is up the hierarchy tree from the other.
    This does not explain how I can instantiate Bar from DBServlet, but not Foo.
    Hope this helps. I think I've corrected previous mistake w/ removing too much from package naming. I'm resorting to the workaround in clue #3 for the moment. But it's not the correct solution, and it's showing that I don't really understand what's going on here.

  • Extending classes at runtime

    Hi,
    Is there a way to extend a class at runtime? What I'd like to do is the following:
    I want to have a tabbed pane component that does not stretch its tabs when there are several lines of tabs. The stretching of the tabs is implemented in the UI component of JTabbedPane - and this depends on the look & feel - it can be MetalTabbedPaneUI, WindowsTabbedPaneUI, etc.
    I want to extend the currently-used UI class (which is only known at runtime) with my own class that overrides a single method.
    I can extend all those that I currently know and use some mapping from the currently used class to the one extending it - but tomorrow someone may install a new look & feel which uses a different UI component, for which I will not have an extending class.
    Therefore, I'd like to find the currently used UI component class and extend it at runtime.
    Thanks,
    Shlomy

    Shlomy-Reinstein wrote:
    Thanks. It's a good solution, but it requires me to write wrappers for all the public methods of BasicTabbedPaneUI, doesn't it? All I'm interested in is to override a single method. If there is no easier way, that's okay, but since there are scripting languages that interface with Java (e.g. BeanShell), in which I can extend classes, I thought there should be an easy way to extend a class at runtime.You don't write code that is "easy". You write code that is correct.
    If there are several different ways to write code which are all correct then you use other criteria to determine the best one. The first criteria is how much maintenance each would require. And how complex each solution would be. Complexity also impacts maintenance.
    And nothing I have seen in this thread would suggest that anything but a wrapper is a correct solution. Certainly unless you can demonstrate that it would not work then I doubt anything would be better.
    And using beanshell just so you don't have to type is definitely not the correct solution.

  • Extending classes with private methods?

    my understanding of extending classes is that you gain all the functions and methods of that class thus You could over ride any one of them. How ever I am confused on weather or not you inherit and can over ride private methods of the class you are extending or if you have to have all methods public in an extended class.
    hope that makes sense, an example can bee seen bellow.
    package
         public class Class1
              public function apples():void
                   //some code
              private fnctuin bananas():void
                   //more code
    package
         public class Class2 extends Class 1
              override public function apples():void
                   //i changed code
              //can I over ride bananas?

    you can only override methods that would be inherited.  a private method won't be inherited:
    http://www.kirupa.com/forum/showthread.php?223798-ActionScript-3-Tip-of-the-Day/page5

  • Extending classes and overriding methods

    If I have a class which extends another, and overrides some methods, if I from a third class casts the extending class as the super class and calls one of the methods which gets overrided, is it the overrided method or the method of the superclass which get executed?
    Stig.

    Explicit cast can't enable the object to invoke super-class's method. Because dynamic binding is decided by the instance. The cast can just prevent you from using methods only defined in sub-class, but it does not let the object to use super-class's method, if the method's been overrided. Otherwise, the polymophism, which is one of the most beautiful feature of Object-Oriented thing, can't be achieved. As far as I know, the only way to use super-class's method is the super keyword in the sub-class, and seems no way for an object to do the same thing (I may wrong, since I haven't read the language spec).
    here's a small test:
    public class Test {
    public static void main(String[] args){
    A a = new B();
    a.method();
    ((A)a).method();
    class A{
    public void method(){
    System.out.println("A's method");
    class B extends A{
    public void method(){
    System.out.println("B's method");
    The output is:
    B's method
    B's method

  • Bounds are not propagated in extended class

    Have a look on this small example, 3 classes A, B and C.
    B and A are generics class,
    B herits of A and there is a lower bounds on the class T in B (T extends C)
    public class A<T> {
         public A() {}
         public T foo()
    public class B<T extends C> extends A<T> {
         public B() {}
         public static void main(String[] args) {
              B inst = new B();
              C cInst = inst.foo3();  //problem : it does'nt work !!
    public class C {
         public C() {}
    }The problem is in the main of the class B, the compiler says : "Cannot convert from Object to C".
    My reasoning :
    There is a type constraint (a lower bound) on T in the class B, so "T extends C" in the class B, so "T extends C" in the class A for an instance of the class B. The call to the method foo() does answer an object which class extends class C !!
    Someone has an explanation, it's abnormal or I should set the parameters of javac.
    thank you.

    Ok my examples were wrong !!
    Have a look on this example (smaller and better !)
    B and A are generics class,
    B herits of A and there is a lower bounds on the class T in A "T extends C"
    public class A<T extends C> {
         public A() {}
         public T foo()
         public void foo2() {
              C cinst = foo(); //no problem : it works
    public class B<T> extends A<T> {
         public B() {...}
         public void foo3() {
              C cinst = foo(); //error : "cannot convert T to C"
    }The type constraint "<T extends C>" of the class "A" is not propagated to the class "B" !!
    I have to add the constraint <T extends C> to the class B like this
    public class B<T extends C> extends A<T> {...}However, it's inevitably like this !

  • [svn:osmf:] 11139: Extending class with a 'processLoadingState' stub, invoked when load state is set to LOADING.

    Revision: 11139
    Author:   [email protected]
    Date:     2009-10-26 03:02:38 -0700 (Mon, 26 Oct 2009)
    Log Message:
    Extending class with a 'processLoadingState' stub, invoked when load state is set to LOADING.
    Modified Paths:
        osmf/trunk/framework/MediaFramework/org/osmf/media/LoadableMediaElement.as

    Strobe was used to verify that the problem was not with my OSMF implementation. Since the results were the same, I am more supsicious of OSMF itself or the underlying AIR framework than the player implementation. Either way, the information I've seen says that progressive download of h.264 video is supported on mobile devices with AIR. It would appear that this is not true in all cases.
    The issue has not been observed on not occur on the desktop. It only occurs with StageVideo enabled playback with autoplay on.
    In the actual product the videos play one at a time. Once the user has finished with a video, the player clears the references to the media. These are OSMF calls; the media assigned to the player is nulled. If this is not sufficient for garbage collection, then I am at a loss as to how to proceed. My test uses four videos that are roughly 1 MB. If there is a memory use problem, then it would appear something is broken in AIR or OSMF.
    I want to be sure I report this correctly. The code involved is more than a snippet, it's a media player designed to be embedded in an app. Do I need to include the complete implementation or will a description be sufficient?

Maybe you are looking for

  • Attributes of system message changing from warning to Erroro message

    dear experts,              I have an issue regarding to change the sytem message from warning to error message .For some materail groups are under Purchase requisition release Stratergy.For this without releasing Pur req system should not allow to ra

  • Indesign CS6 not picking up keyboard commands or any type

    I recently downloaded the CS6 creative package. I cannot seem to type anything into Indesign documents, or perform any Keyboard Commands. I'm on a Mac and have never had this problem before, it seems as if it's just not connecting to my keyboard.

  • Assign R3 users to AD groups

    Our 4.6C system assigns user roles indirectly based upon org unit or HR position ID.  When R/3 roles are assigned indirectly, we would like to assign the user ID to a Microsoft Active Directory Group.  Does anyone know how this can be accomplished? 

  • Removing the under score '_'  from the beginning of the word

    Hi Please see the below problem, with t as (      SELECT     'OS_TEST_1'     AS dt      FROM     dual union SELECT     'NET_TEST_2'     AS dt      FROM     dual select substr(dt,4) from t Current Result- TEST2 TEST_1 Expected Result - TEST_2 TEST_1 M

  • Resolving type names during compilation

    Hi, I have a question about how the default (or any other) java compiler resolves type names when compiling several files. How does the compiler efficiently organise itself so that it can resolve type names that it has not yet parsed? take a trivial