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 6154037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:11:38+00:00 2026-05-23T20:11:38+00:00

How many number of Instance can be there when same singleton class is packaged

  • 0

How many number of Instance can be there when same singleton class is packaged in two war file(and both war files are packaged in
one ear file)

Cas1

MyUnderstanding
As per my understanding for singleton class there will be a single instance per JVM. So as per this answer for above should be one instance
as there will be one instance of jvm for the ear file.

Case2

But on differnt sites(one at http://www.coderanch.com/t/520891/java/java/Singleton-Diff-WAR-files-same) , folks have also mentioned singleton produces
the single instance for a class loader. they said for two war files there will be two class loader . So ther will be two instance of singleton.

What is the right answer?

If second case is right can we say below statements

1)For singleton class there will be a single instance per classloader(here i mean classloader hirerchy in a jvm instance that includes bootstrap loader,
application class loader) not for jvm.

2)For two war files packaged in same ear file there will be two classloader hirerchies under same jvm instance

posted at http://forums.oracle.com/forums/thread.jspa?threadID=2253940&tstart=0 but not concrete answer

  • 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-23T20:11:38+00:00Added an answer on May 23, 2026 at 8:11 pm

    1) If your class is in each WAR, then there will be an instance per webapp (classloader herarchy).

    2) Yes.

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

Sidebar

Related Questions

I'm setting up a number sites right now and many of them have multiple
I've heard many people say that if the number of expected elements in the
What is a magic number? Why do many programmers advise that they be avoided?
Many people string together find and sed, or perl, or any number of other
I have to maintain a large number of classic ASP pages, many of which
We have a SQL query that pulls a large number of fields from many
Is there any way to get numbers on how many people are reading an
How can I, in a MySQL query, have the same behaviour as the Regex.Replace
I have an application with many different parts, it runs on OSGi, so there's
Our Swing application doesn't limit the number of application instance user opens that is

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.