Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6798663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:45:26+00:00 2026-05-26T18:45:26+00:00

I have a problem here that still cannot solve, the thing is I have

  • 0

I have a problem here that still cannot solve, the thing is I have this abstract class:

public abstract class AbstractBean<T> {
    private Class<T> entityClass;

    public AbstractBean(Class<T> entityClass) {
        this.entityClass = entityClass;
    }
    ...
}

Now I have another class that inherits this abstract:

@Stateless
@LocalBean
public class BasicUserBean<T extends BasicUser> extends AbstractBean<T>  {
    private Class<T> user;    

    public BasicUserBean() {  
        super(user);  // Error: cannot reference user before supertype contructor has been called.
    }
}

My question is how can I make this to work?, I am trying to make the class BasicUserBean inheritable, so if I have class PersonBean which inherits BasicUserBean then I could set in the Generic the entity Person which also inherits the entity BasicUser. And it will end up being:

@Stateless
@LocalBean
public class PersonBean extends BasicUserBean<Person>  {

    public PersonBean() {
        super(Person.class);
    }
    ...
}

I just want to inherit the basic functionality from BasicUserBean to all descendants, so I do not have to repeat the same code among all descendants. Thanks!.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:45:27+00:00Added an answer on May 26, 2026 at 6:45 pm

    You need to add the constructor to BasicUserBean taking a Class<T>

    public BasicUserBean(Class<T> entityClass) {
        super(entityClass);
    }
    

    Your no argument constructor won’t work since the class you’re extending requires a T. You can’t have a T in your constructor without taking in a T as an argument; not without a cast anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a strange problem here... I have an ASP.NET 3.5 application that has
Here's the core problem: I have a .NET application that is using COM interop
Here's my problem: I have an unmanaged dll that I made.I'm calling one of
Here's my problem: I have a virtual method defined in a .h file that
I have a strange problem with mod_rewrite, the rules that are relevant here are:
I have an interesting SQL problem that I need help with. Here is the
Here is a hum-dinger of a problem that I have not found an answer
Here's the problem: 1.) We have page here... www.blah.com/mypage.html 2.) That page requests a
I have a class that gets arranged into a hierarchy, such as this: class
He're an interesting problem that looks for the most Pythonic solution. Suppose I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.