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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:54:00+00:00 2026-06-13T22:54:00+00:00

I have a Spring application and I want to run in it an embedded

  • 0

I have a Spring application and I want to run in it an embedded Jetty instance where I want to deploy a Grails application.

I need the Grails application to have access to the application context of the Spring application.

I am deploying the Grails application as following:

    Server webServer = new Server(8080);
    WebAppContext webapp = new WebAppContext();
    webapp.setContextPath("/");
    webapp.setWar("MyGrailsApp.war");
    webServer.setHandler(webapp);
    webServer.start();

To get the Grails application access to Spring application context I further added these lines before calling webServer.start():

    ParentAwareContextLoaderListener contextLoaderListener = new ParentAwareContextLoaderListener();
    //appContext is context of my Spring application
    contextLoaderListener.setApplicationContext(appContext);
    webapp.addEventListener(contextLoaderListener);

ParentAwareContextLoaderListener is a simple class like this:

public class ParentAwareContextLoaderListener extends ContextLoaderListener implements ApplicationContextAware {
private ApplicationContext applicationContext;


@Override
protected ApplicationContext loadParentContext(final ServletContext servletContext) {
    return applicationContext;
}

@Override
public void setApplicationContext(final ApplicationContext applicationContext) throws BeansException {
    this.applicationContext = applicationContext;
}
}

I further removed the original ContextLoaderListener from the Grails application web.xml. While this approach worked for one other non grails application, it is for some reason not working with Grails. I get this exception:

20138 [main] ERROR org.springframework.web.context.ContextLoader ContextLoader - Context initialization failed 
java.lang.IllegalArgumentException: ConfigurableWebApplicationContext environment must be of type ConfigurableWebEnvironmentObject of class [org.springframework.core.env.StandardEnvironment] must be an instance of interface org.springframework.web.context.ConfigurableWebEnvironment
    at org.springframework.util.Assert.isInstanceOf(Assert.java:337)
    at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.getEnvironment(AbstractRefreshableWebApplicationContext.java:147)
    at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.getEnvironment(AbstractRefreshableWebApplicationContext.java:1)
    at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.resolvePath(AbstractRefreshableConfigApplicationContext.java:122)
    at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.setConfigLocations(AbstractRefreshableConfigApplicationContext.java:81)
    at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.setConfigLocation(AbstractRefreshableConfigApplicationContext.java:69)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:380)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)

Any idea how can this problem be solved? Thank you for any 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-13T22:54:01+00:00Added an answer on June 13, 2026 at 10:54 pm

    I finally used a completely different approach. See for example this link http://techo-ecco.com/blog/spring-application-context-hierarchy-and-contextsingletonbeanfactorylocator/ for solution which uses ContextSingletonBeanFactoryLocator.

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

Sidebar

Related Questions

I have a spring application that uses an embedded Jetty instance. Since I am
I have a following application I want to run from a flash drive, say
I have developed a spring application, I want to configure it with apache log4j,
I have a j2ee web application running on Spring framework. I want to implement
I have a Spring application deployed in JBoss EAP server, using the following settings:
i want to run my view based window application with ticker.i have code for
I have my application running on Tomcat server successfully. I want to run some
I have application i want to run as LaunchDaemon on OSX. My plist looks
I have 3 application contexts: A global context which is responsible for launching Jetty
I have a Spring web application and I want to make unittests for my

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.