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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:08:23+00:00 2026-05-18T05:08:23+00:00

The separation between application context and web context (and the class loader issues that

  • 0

The separation between application context and web context (and the class loader issues that ensue) are a constant source of problems for me. I’m using Spring in my first project, migrating from a badly written JSP-based webapp to Spring-based.

I just want to know if this configuration makes sense:

  • I have the controllers, form objects, and such defined using annotations and scanned in the web application context.
  • I moved the DAOs (data access objects) to the application context after initially having them in the web app context – this was because I needed to use them to get the user/password for spring security, which is an application context bean.
  • Spring security if defined (as per the docs) in the application context, necessitating DAO to go with it.

Now I’m running into classloader issues where I pass an object to JDO/DataNucleus and it’s created by the web app classloader, but the DAOs are all part of the application context, thus that component gets its own classloader and can’t match up the same objects.

Simple method from DAO:

@Override
public boolean userExists(String username) {
    Query query = pm.newQuery(User.class);
    query.setFilter( "username == :usernameParam" );
    query.setResult( "count(username)" );
    query.setResultClass(Long.class);
    System.out.println(username);
    Long result = (Long)query.execute(username);

    return (result!=null && result>0);
}

javax.jdo.JDOUserException: The Query
will return a single field but it is
not of a consistent type as the
ResultClass (java.lang.Long) : It is
java.lang.Long

I ask because this is not the first classloader issue (and I fear not the last) to pop up because of the way spring is configured right now, so I wonder if I’m doing things poorly.

Or perhaps there are some configurations that address these kinds of class loader issues that I’m not yet aware of?

  • 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-18T05:08:24+00:00Added an answer on May 18, 2026 at 5:08 am

    The classloader should have nothing to do with the Spring context. Webapplication context is a spring container which generally contains controllers and view resolvers. Application context contains dao’s. Web application context has application context as parent, so that it can access the dao and service beans and not vice versa. However both the context are part of same war and should be loaded by same class loader.

    Looking at your exception, I think, it does not seems to have anything to do with Spring.

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

Sidebar

Related Questions

In the Java world, I often see separation between web server and application server.
I plan to make an web application using XPages for the design (plus the
I'm developing a multilingual PHP web application, and I've got long(-ish) texts that I
I'm trying to figure out what are the layers that a web application needs
I have this web application that has grown to an unmanageable mess. I want
I've now completed my first web application using ASP.NET MVC and overall, I still
So, here's a quick extract of the directory structure on a web application that
So I have a layered ASP.NET MVC proof-of-concept application with good separation between presentation
Is it possible to integrate Zend Framework with already existing legacy web application? The
I am part of a development team building a new ASP.NET 3.5 web application.

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.