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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:48:38+00:00 2026-06-02T08:48:38+00:00

I’m about to write a MMO, using HTTP-requests that are responsed with JSON. I

  • 0

I’m about to write a MMO, using HTTP-requests that are responsed with JSON.

I was writing it all in Java EE-style, hoping it won’t be hard to port to Java EE than. But then I’ve found out that my static instance variables for a couple of sinletons weren’t created properly – classloader made a bunch of them when calling SingletonClass.getInstance() from servlets.

I was totally desperate and thought adding @Singleton descriptions would help. But things weren’t so easy. My classes simply not working while adding them with @EJB ClassName var. Context lookup doesn’t work either.

I was trying developing in Eclipse, NetBeans, used Glassfish, tried to set it up, but nothing really helped. I do not know what to do and really desperate now.

All I need is just few classes, that work all the time application is loaded to handle game events and hold logged users data (which is distributed in non-EJB objects that hold user data, monsters and so on), some timed events for each logged user and ability to respond to HTTP POST requests with JSON. I even do not need the ORM, I wrote all queries by myself, but still… Something that had to work simply doesn’t work out.

I’m aware that all that sounds messy and non-informative, but I do not know what to do – where is my problem? Maybe, I should fill web.xml, or use different port, or fly to the moon? Or just change programming language? Sorry for your time spent reading this.

UPD. Some application scheme parts. First two from package “server”.

    @Startup
    @Singleton 
    public class DbWrapper

handles all database connections, DbConnectionPool is non-singleton class, which handles pool of java.sql.Conneciton.

    @Startup
    @Singleton
    @DependsOn("DbWrapper")
    public class World

is yet another class to handle all the in-game events, that holds HashMap of logged users. User and Monster classes are from package “entities” (User holds a list of monsters).

Package “servlets” hold HttpServlet descendants, annotated @WebServlet(“/pathname”), that try to use

    @EJB World world

for example. But such things as world.getUser(id_user) simply won’t work.

As for JDBC – postgres jar is included in GlassFish domain’s /lib.

As for JSON – I use org.json found here: https://github.com/douglascrockford/JSON-java

  • 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-02T08:48:40+00:00Added an answer on June 2, 2026 at 8:48 am

    I’ve found out that my static instance variables for a couple of singletons weren’t created properly – classloader made a bunch of them when calling SingletonClass.getInstance() from servlets.

    First, you should show us the code for one of these singleton classes. You may have made a mistake in the implementation that causes this problem.

    It is true that you can get what appear to be multiple instances of a (properly implemented) singleton class in a servlet framework. But in fact they are not what they appear to be. What is actually going on is that you have loaded the class from multiple classloaders, either because you have multiple webapps each loading the class, or because you are redeploying your webapp and the previous deployment is not clearing up properly.

    So what can / could you do about this?

    • You could use a dependency injection framework to configure your webapp, and hence avoid the need for singleton classes.

    • You could continue using singletons, but track down why you are getting multiple instances, and fix that problem.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have thousands of HTML files to process using Groovy/Java and I need to
I am writing an app with both english and french support. The app requests
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.