Announcement Announcement Module
No announcement yet.
spring standalone app Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring standalone app

    hi all,
    sorry this might look like a silly question but i have been so used to run apps in application servers that now i am little in trouble.
    I have to write a standalone Spring application that listen to an MQ, picks messages and insert content of the message in a database.
    Currently on our system we don't have an application server, so i was wondering how am i going to implement this....
    as a running thread?
    any other alternatives?

    thanks in advance and regards

  • #2
    You might be able to use mdp. Take a look at You should be able to bring the app up by instantiating the appcontext from a class with a main method and let spring handle the threading.


    • #3
      This is a loaded question. Is it going to be a Swing/SWT app or Main program of some type?

      Here is some pointers that might help
      No you don't need J2EE container to run Spring.
      You would obviously need a Java program with main() method in it ( I assume you know that ) and there are various ways to instantiate Spring Bean Factory and/or Application Context (see a quick example below).
      public static void main(String[] args) {
            ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
            ITest test = (ITest) context.getBean("testTarget");
      If you are running it in Swing/SWT app then you would include this code in the appropriate place within your GUI container.

      If you are planing to implement your own container you can look at implementation of Main class of Tomcat, Servicemix, JBoss and other containers (Servicemix would be preferable since it is Spring based)
      small example would be:
      public static void main(String args[]) {
              try {
                 ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
                  . . . . .
                  Object lock = new Object();
                  synchronized (lock) {
              } catch (Exception e) {
      Hope it helps

      Oleg Zhurakousky


      • #4
        Hi all,
        thanks for all replies.... well it's going to be a standalone app (with Main())...
        i m going to check out servicemix as it looks exactly what i need



        • #5
          In order to simplify main management, I have created If you like the proposed approach, please vote for it.