1 2 Previous Next 18 Replies Latest reply on Oct 23, 2008 5:50 PM by kr8m3r_78

    If I deploy more than one webservice I get "Multiple context

    rickcr

      I can deploy a simple webservice and everything works fine. If II create another webservice in a similar manner and deploy it, I end up with a "Multiple context root not supported" error.

      This is very frustrating since I see nothing about this issue in the users guide.

      Here was an example of an initial web service I was trying to deploy (which works fine, until I try to deploy another webservice using the same approach):

      @Local
      @WebService
      @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
      public interface Echo {
      @WebMethod String testEcho(String s);
      }

      @Stateless
      @WebService(endpointInterface="com.foobar.edsf.example.ejb.webservices.Echo")
      public class EchoBean {
      public String testEcho(String s) {
      return s;
      }
      }

      If I deploy a similar webservice like the above, I'll get the Multiple context root not supported error. Am I doing something unorthodox or is this a bug? My EJB3 book and the examples that come with the jboss patch here: http://docs.jboss.org/ejb3/app-server/tutorial/installing.html show examples like I'm doing above.

      There is something related to this in jira http://jira.jboss.com/jira/browse/JBWS-1622 but I can't seem to get the concept of @WebContext working correctly (I also don't see why I should even need to use a non-standard JBoss annotation to do something that should be standard.)

      WITHOUT adding a @WebContext I'll end up with a wsdl location like:

      http://machine-name:8080/EchoBeanService/EchoBean?wsdl

      If I try to declare a @WebContext I won't get the multiple context root error, but it changes the wsdl path to a path that it can't find. For example if I give it a path:

      @WebContext(contextRoot="/EDSF-tests", secureWSDLAccess=false)

      I end up with a wsdl URL:

      http://machine-name:8080/EDSF-tests/EchoBean?wsdl

      Which doesn't point to the wsdl anymore.

      Can someone give me some pointers about what I'm doing wrong? There must be a reason others have not run into this as well since I don't think I'm creating my webservices in a unique way.



        • 1. Re: If I deploy more than one webservice I get
          rickcr

          I guess this is a bug since if I use jbossws-1.2.0.SP1 I do not get this error. The jira bug on this is still open so I guess I'll just use 1.2.0 until it is resolved.

          If this isn't a bug, though, someone please let me know:)

          Thanks.

          • 2. Re: If I deploy more than one webservice I get
            peterj

            If I remember correctly, the context root comes from the jar file name. Are both of your jar files named the same?

            It would appear that the standards define how the default context root is defined, but always leave it up to the implementation to specify alternate context root (hence the context-root entry in the jboss-web.xml file used in war files).

            Of course, I could always be wrong.

            • 3. Re: If I deploy more than one webservice I get
              rickcr

              The two webservices are in the same package and packaged in the same jar. It seems odd that things work fine in 1.2.0.SP1 but not 1.2.1.GA.

              • 4. Re: If I deploy more than one webservice I get
                genady_yadata

                Our jar is named "beans.jar" and adding

                @WebContext(contextRoot="/beans")

                to all of the classes seems to work.

                I also can't understand what caused them to change the behavior in 1.2.1GA.

                Does anybody know how to specify the context root in an XML file?

                • 5. Re: If I deploy more than one webservice I get
                  rickcr

                  Also, my webservices jar is locate din an ear file if that matters at all.

                  Secondly, I'm not sure why I would need to use @WebContext in order to get this to work in 1.2.1.GA. All the standard examples I see do not mentioning using @WebContext - which if I understand correctly is not even part of the EJB3 Spec but is a JBoss specific annotation.

                  If you check out the webservice example for jboss provided after downloading the examples here
                  http://sourceforge.net/project/showfiles.php?group_id=22866&package_id=132063
                  (unzip and then in the docs/tutorials there is a webservice example),

                  You'll see there example does not use the @WebContext notation.

                  • 6. Re: If I deploy more than one webservice I get
                    heiko.braun

                    Thanks for the valuable discussion. I will try to explain what changes between 1.2.0 and 1.2.1 are causing the problems you encounter.


                    1.) For EJB3 deployments we need to create a web app for HTTP invocations (obviously)

                    2.) EJB's don't contain web context information, so we derive it automagically.

                    3.) Until 1.2.0 the context name was derived from the ear/jar name.

                    4.) This changed with 1.2.1 to an algorithm that derives it from the bean class name


                    So what's happening when you deploy a EJB3 jar that contains multiple beans?
                    The default algorithm derives different context names for each bean in this deployment, which in turn we cannot use to setup the HTTP endpoint and thus throw an exception.

                    This also explains why the following did work:


                    @WebContext(contextRoot="/beans")


                    Unfortunately this is left out in the specs and thus has been changed many times.
                    Until we a have a definite solution i suggest you refer to the @WebContext annotation, even though it's not the most elegant solution.

                    --
                    Heiko

                    • 7. Re: If I deploy more than one webservice I get
                      rickcr

                      Thanks Heiko for the information. My only question now (and pardon if this is a very 'newbie' question) but what would I set the web context to? In other words, do I need to make sure the various webapp wars that might be in the ear all have web.xml definitions that point to the ejbs so that I can create a context for the ejbs through the web.xml? If so, this seems like a lot of extra work.

                      I guess I'm just confused how I know what @WebContext to use for the ejbs? I could have several wars that all have their own web context. I would think the ejb context would be independent of those contexts, but just giving it an arbitrary context doesn't help in regard to having the wsdl being located.

                      If someone could provide a simple example of what to set this @WebContext to I'd appreciate. I'm sure I'm missing something simple.

                      • 8. Re: If I deploy more than one webservice I get
                        heiko.braun

                        Regular war's are not touched by this probelm. Just make sure all EJB's within a jar point to the same web context thriugh something like:


                        @WebContext(contextRoot="/myEJBServices")


                        • 9. Re: If I deploy more than one webservice I get
                          rickcr

                          Thanks Heiko. That worked great. Not sure what I was doing wrong earlier when I had tried that (using @WebContext) and wasn't able to find the wsdl. It's working fine now, so I'll chalk my mistakes up to typical stupid human error:)

                          • 10. Re: If I deploy more than one webservice I get
                            genady_yadata

                            Heiko,
                            Is there an XML syntax that can override the WebContext or we must use the annotation?

                            Thanks,
                            Genady

                            • 11. Re: If I deploy more than one webservice I get

                              Rick, can you confirm that your question in JIRA JBWS-1622 is solved (for you, but maybe not for the reporter of that issue) by Heiko's replies?

                              And for the archives: @WebContext is org.jboss.ws.annotation.WebContext as found in jbossws-core.jar

                              Arjan.

                              • 12. Re: If I deploy more than one webservice I get

                                Even when deploying only a single web service, this error may also be caused by some left-overs after refactoring without properly cleaning up.

                                I changed the name of my service using Eclipse, which left the old compiled classes in various exploded archive folders. Those were then still copied to, and loaded by, JBoss. This resulted in multiple services (same implementation with different class names) within the same application, and thus yielding the "org.jboss.ws.WSException: Multiple context root not supported" error.

                                My stupid mistake, of course...

                                • 13. Re: If I deploy more than one webservice I get
                                  wpfeiffe

                                  Can anyone provide the EJB 2.1 equivalent to:

                                  @WebContext(contextRoot="/beans")


                                  I've seen in the FAQ this bit of text:

                                  Use the explicit context root from webservices/context-root

                                  Can be set in jboss.xml and is only relevant for EJB endpoints.


                                  Can anyone clarify which file the webservices/context-root is referring to and the exact syntax?


                                  Any help would be appreciated.

                                  Thanks,

                                  Bill Pfeiffer

                                  • 14. Re: If I deploy more than one webservice I get
                                    rroles1209

                                    Sorry I am so dense, but where IS WebContext, I would like to try and
                                    use it to solve an issue I am having with multiple Context in deploying multiple Web Services, and cannot find it in any Web Services JBOSS jar

                                    1 2 Previous Next