12 Replies Latest reply on Jul 24, 2008 4:10 PM by jagdeep

    multiple web apps in the SAME JBoss instance

      Hi, I think this should be possible and am trying to test it. I have 2 ears, 2 database with sperate DB connections inside two custom security folders. e.g: server/app1/deploy, server/app2/deploy.
      1) How do I start JBoss to pick both deployments? Is it even possible?
      2) I came across the topic to start Multiple Instances of JBoss in the same machine, in the JBoss wiki, but as you see, I want to start 2 security modules with seperate EAR / DB connections, in the same JBoss instance.

      Please point me to the appropriate documentation / forum / post if this has been discussed before.

      Thanks,

        • 1. Re: multiple web apps in the SAME JBoss instance
          peterj

          If you want one app server instance to deploy both data sources and both apps, place all the files (both *-ds.xml files and both *.ear files) into a single deploy directory (such as server/app/deploy).

          If you use two different service configurations (such as server/app1 and server/app2) you will have to run two app server instances.

          • 2. Re: multiple web apps in the SAME JBoss instance

            Thanks PeterJ,
            That was basically what I observed while trying this, and you confirmed it. What is the difference in terms of security? I have my custom classes on top of authentication mechanism provided by JBoss. I am thinking, apart from not being able to config a few things seperately, security wise things should be the same in both styles. Would you agree?

            • 3. Re: multiple web apps in the SAME JBoss instance
              peterj

              You should be able to configure the security of both apps independent of each other. Or make use of some common security functionality (for example, use the same database login module). What are the issues you are seeing that caused you to write "not being able to config a few things seperately"?

              • 4. Re: multiple web apps in the SAME JBoss instance

                Peter, my bad...guess what I meant to say was ' *I assume* in the scenario we would not be able to config some things', I haven't come across any, but are there things to keep in mind if I wanted two apps to work completely independently connecting to seperate DBs etc....Right now both my application policies(for both apps) are defined in the same login-config xml, but I have seperate classes extending the DatabaseLoginModule in JBoss in my seperate apps, so I think security should be independent enough, but what other (if any) thing would I want seperate if I wanted completely independent applications running in the same instance of JBoss...is it possible to have custom directories by which to seperate these apps /ds.xml?
                Thanks for you help.

                • 5. Re: multiple web apps in the SAME JBoss instance

                  in continuation to my above post: My basic objective was to be able to deploy multiple independent apps / db conn, and have the ability to start /stop one without affecting the other. That was the reason I was thinking about using multiple custom configs, and hoping to start them using something like: ./run.sh -c app1 -c app2 etc....I understand that other app servers like jRun allow that...is there no way / workaround in jBoss for this (except using multiple instances of JBoss)?
                  Thanks.

                  • 6. Re: multiple web apps in the SAME JBoss instance
                    peterj

                    For all intents and purposes, the two apps are independent (unless you code the apps to interact). They can each use their own login domains, their own databases, etc.

                    You can start and stop the apps independently. For each app JBossAS creates MBeans that can be used to stop, start and even undeploy the app. Of course all of this happens while JBossAS is running - you never stop it.

                    • 7. Re: multiple web apps in the SAME JBoss instance

                      I see...though I am familiar with what MBeans are, starting / stopping is something I am not familiar with.
                      1) I went to the JMX console and under MBean>jboss.j2ee>my deployment ear and tried stopping it. It throws a security policy exception (operation not allowed).
                      2) Would I need to custom write an MBean, specially if I wanted to have one more level of directory inside deploy folder where I keep my app?
                      Is there a some good reading source you could point me to? anything online or a book?
                      Thanks

                      • 8. Re: multiple web apps in the SAME JBoss instance
                        peterj

                        If you just want to keep the files of the apps separate, you could create a directory for each under the deploy directory. For example, server/xxx/deploy/app1 and server/xxx/deploy/app2.

                        I think you were using the web console, not jmx console (the URL should be http://localhost:8080/jmx-console). I would not use the web console, it has not been updated for years and rarely works correctly.

                        Have you read the JBossAS documentation? Also see http://www.manning.com/jamae, which is based on JBossAS 5.0.

                        • 9. Re: multiple web apps in the SAME JBoss instance

                          Thanks Peter, this was helpful. I went through the JMX console, but still get another exception when trying to stop my EARDeployment service.
                          Though, when I try stopping the WAR, it undeploys the WAR file!!.

                          I see from the exception that JBoss doesnt find my EAR registered??

                          javax.servlet.ServletException: Failed to invoke operation
                          org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.invokeOp(HtmlAdaptorServlet.java:269)
                          org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.processRequest(HtmlAdaptorServlet.java:100)
                          org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.doPost(HtmlAdaptorServlet.java:82)
                          javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
                          javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
                          org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


                          root cause

                          javax.management.InstanceNotFoundException: jboss.j2ee:service=EARDeployment,url='example2.ear' is not registered.
                          org.jboss.mx.server.registry.BasicMBeanRegistry.get(BasicMBeanRegistry.java:523)
                          org.jboss.mx.server.MBeanServerImpl.getMBeanInfo(MBeanServerImpl.java:666)
                          org.jboss.jmx.adaptor.control.Server.invokeOp(Server.java:216)
                          org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.invokeOp(HtmlAdaptorServlet.java:262)
                          org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.processRequest(HtmlAdaptorServlet.java:100)
                          org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.doPost(HtmlAdaptorServlet.java:82)
                          javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
                          javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
                          org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

                          • 10. Re: multiple web apps in the SAME JBoss instance
                            peterj

                            That is weird. I clicked on the corresponding link for one of my EARs and did not get an error. All you did was click on the "service=EARDeployment.url='example2.ear'" link under the "jboss.jca" section on the JMX Agent View within jmx-console, right?

                            That the war is undeployed when you stop it is not surprising. There is no concept of "don't allow any more requests for this app". Though if you set up virtual hosts, one for each app, you might be able to stop each host. That might not undeploy the app, and since the app can be reached only through the virtual host, it is as good as stopped.

                            By the way, even if you went with two app server instances, one for each app, stopping one of the app servers to stop an app would also undeploy the app.

                            • 11. Re: multiple web apps in the SAME JBoss instance

                              Hi Peter, yes the link you mention below, but for me it is under jboss.j2ee, not jca (I am guessing it might be the same for you). Btw, I am on JBoss 4.2.2 GA.
                              I think as a first step, if the app gets undeployed (just like the WAR), it would work for me. Only that it is not doing so :-)

                              • 12. Re: multiple web apps in the SAME JBoss instance

                                Hi Peter, I also noticed that starting the WAr doesn't work either, so basically only stopping the WAR works for me. Stopping the WAR, starting /stoppping the EAR does not. Are you on version 4.2.2GA too? Are there any alternate means of achieving this functionality?