Announcement Announcement Module
No announcement yet.
Spring, EAR, EE container, how to start spring container? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring, EAR, EE container, how to start spring container?

    Hi, I'm a bit stuck and although googled for quite a while, haven't
    found any hint on how to achieve the following.

    I have some jar which contains spring beans which so far operated as
    standalone app by simply starting spring context. Spring context config is within jar, but it could be moved out if

    Now, I'm trying to embed it into EAR and to deploy to EE container (to be more specific it is weblogic server)...and it is fine, I've embedded it as javaModule and deployed it but of course it doesn't do anything as spring context is
    not started.

    That is my question, does someone has experience with this? All I need is to on EAR start, to start spring context and on EAR stop to stop it... this does not have any gui or anything so I don't need it to be webapp. Also there are no EJBs as I don't need them, this app actually occasionally calls some system command to process some files.

    I am aware that I could convert it to web-app and use ContextListener on web-app, but before that I'd like to check, is this achievable, and what is the best approach to start spring context if I only need container to be started, nothing else?

    Any help/tip/info/suggestion is very appreciated.

  • #2
    Well if you are deploying it to an app server that this jar is being used by a webapp. So in the web.xml for the web app simply initialize the context for the jar as well.
    	<!-- Location of Java @Configuration classes that configure the components that makeup this application -->
    Or if you are using xml rather than java config then define those instead of the packages containing the @Configuration classes like this: (Note this assumes your context.xmls end in 'context.xml' you can list them out or adjust the wild card as needed)



    • #3
      Well, I've actually solved it meanwhile without webapp stuff.

      I've implemented application lifecycle listener and in post start I start spring
      with ClassPathApplicationContext.start (by giving it config location) and stop it in pre stop.

      Not sure if this is the best solution but it works quite fine.