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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:19:07+00:00 2026-06-08T11:19:07+00:00

I have 2 spring contexts: webapplication context and a core context. The context core

  • 0

I have 2 spring contexts: “webapplication” context and a “core” context. The context “core” is initialized at server startup and attached to a Singleton class that holds the context. The “webapplication” context is initialized when the webapplication is started.

I want to inject bean dependencies from beans in one context to the other (bidirectional access). The webapplication beans are to be “session” scoped beans.

I’m testing this proof of concept with: webapp bean –> (that depends on) core bean –> (that depends on another) webapp bean.

At the webapplication context initialization i could inject “core” beans to the “webapplication” beans (a BeanFactory that acceses the singleton do the magic), but can’t figure out how to do the inverse; because the Spring ThreadLocal that holds the WebApplicationContext is not yet initialized.

The question is. Is it what i’m trying to do possible? If the answer is “yes”, how would you do that?

Thank’s in advance.

EDIT:

I’d realized i’m doing something wrong. The fact is that i’m trying to inject in the service layer a dependency to a session bean, at the wrong time; that is, at the web initialization time when i have no current user session.

  • 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-08T11:19:10+00:00Added an answer on June 8, 2026 at 11:19 am

    This looks to me like an architectural issue, not a technical (and certainly not Spring) one. Your separation between core context and web context is very good. The former handles business processes while the latter is responsible for representation, maybe some API.

    The dependency from web (representation, access) to core is understandable and required – after all you are building an interface over business routines. This is how spring-mvc works by default, creating separate child (web) application context of core context.

    I can hardly imagine a use case for inverted dependency. Why is your business logic depending on web layer? What if you try to migrate your application one that to a different representation technique (desktop, mobile)? Can you justify the reason for this inverted dependency? What do you mean by session bean?

    Bidirectional dependencies, as well as static singletons holding a class-loader wide reference to application context should indicate that something is wrong with the design.

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

Sidebar

Related Questions

Say, I have the following bean in Spring context: <bean class=some.class.BlabBlahBlah> <property name=location value=classpath:somefile.xml/>
I have the following test case: @ContextConfiguration(/spring/test-context.xml) @TransactionConfiguration(transactionManager=txManager) @Transactional() public class MyEntityDaoTestCase extends AbstractJUnit4SpringContextTests
I have a web application that's based on Spring and the application contexts, applicationContext.xml
I want to use two different Spring web contexts , each have own contextConfig,
I'm using Spring and struts and have the following entry in '/META-INF/context.xml' <Context cachingAllowed=false
I have two spring beans as follows: @Component(A) @Scope(prototype) public class A extends TimerTask
I have a web application that uses spring security. It uses <intercept-url ../> elements
I currently have a web application that is utilizing Spring Security hosted on a
We have a web application that uses Spring (3.0.5) and CXF (currently 2.4.2 for
The separation between application context and web context (and the class loader issues that

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.