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

  • SEARCH
  • Home
  • 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 7971009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:32:24+00:00 2026-06-04T07:32:24+00:00

I meet a problem in static field. I think the root cause must be

  • 0

I meet a problem in static field. I think the root cause must be the scope of the static field.

The project is based on Apache servicemix and consists of many sub-projects.

In sub-project ‘A’, I defined a static list field ‘reg’ in class ‘Registration’ and some static method to operate the field like ‘add’ and ‘getAll’. Once the sub-projectA is deployed, the name of the project ‘A’ will be added into the static list for registration.

The problem is when it comes to sub-project ‘B’, when the sub-project ‘B’ is deployed, I want its name would be added into the exactly same static list for registration. But when I call static method getAll or add on ‘Registration’, it seems that the ‘reg’ in sub-projectB is totally different from the one in sub-projectA. So the registration function doesn’t work.

So I want to ask one basic question, what’s the scope of a static field? Is it valid in a JVM or some other things?

Thanks for your help

  • 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-06-04T07:32:26+00:00Added an answer on June 4, 2026 at 7:32 am

    The scope of a static is global – within its owning classloader. A JVM can create multiple classloaders and load separate instances of your class in each of new classloaders.

    Statics are not global per JVM, they are global per classloader. If the class with the static field is loaded in a different classloader, its static members won’t be visible within a different classloader.

    How are project A and project B deployed? Are they in the same classloader?

    I’m not familiar with servicemix, but I imagine it deploys separate apps in separate classloaders, just like a Java EE app will deploy different versions of the same app in different classloaders, so you can run app 1.0 and app 1.1 side-by-side, and they won’t affect each other.

    This is by design.

    If this is the case, you need something independent to maintain shared state. (e.g. a database)

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

Sidebar

Related Questions

I am using gmock in my project and I meet a problem to set
i'm beginning to learn android, i meet a problem in my project, in my
I meet a headache problem. there are too many Quotation marks in my code
I meet a problem yesterday. Maybe it's because it is April 1st... but it
I want to count how many members of an iterable meet a given condition.
I am developing a WPF application that must meet Section 508 (Accessibility) requirements. In
I meet a problem about type contraint of c# now. I wrote a pair
I meet this problem when implementing my own swap() method with Python def swap(a,b):
Today I meet a similar problem and it reminds me about this thread. In
I started my first backbone.js app today and I meet a first problem. I

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.