4 Replies Latest reply on Aug 30, 2011 5:03 AM by samwun9988

    How to change jetty binding port number in maven.

    samwun9988

      Hi,

       

      I have created a webservice based on CXF2, spring 3.0.5 in a WAR file.

      When I deploy the WAR file to JBoss AS7, it thrown the following exception:

       

       

      Caused by: javax.xml.ws.WebServiceException: org.apache.cxf.interceptor.Fault: Could not start Jetty server on port 80: Address already in use

              at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:350) [cxf-rt-frontend-jaxws-2.4.1.jar:]

              at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:239) [cxf-rt-frontend-jaxws-2.4.1.jar:]

              at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:509) [cxf-rt-frontend-jaxws-2.4.1.jar:]

              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_03-p4]

              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_03-p4]

              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_03-p4]

              at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_03-p4]

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1544) [spring-beans-3.0.5.RELEASE.jar:]

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1485) [spring-beans-3.0.5.RELEASE.jar:]

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417) [spring-beans-3.0.5.RELEASE.jar:]

              ... 20 more

       

       

      here is the pom.xml file of the WAR file:

       

       

      <plugin>

                      <groupId>org.apache.cxf</groupId>

                      <artifactId>cxf-java2ws-plugin</artifactId>

                      <version>${cxf.version}</version>

                      <dependencies>

                          <dependency>

                              <groupId>org.apache.cxf</groupId>

                              <artifactId>cxf-rt-frontend-jaxws</artifactId>

                              <version>${cxf.version}</version>

                          </dependency>

                          <dependency>

                              <groupId>org.apache.cxf</groupId>

                              <artifactId>cxf-rt-frontend-simple</artifactId>

                              <version>${cxf.version}</version>

                          </dependency>

                      </dependencies>

                      <executions>

                          <execution>

                                                                                                                 

                              <id>generate-test-sources</id>

                              <phase>generate-test-sources</phase>

                              <configuration>

                                  <sourceRoot>generated/wsdl</sourceRoot>

                                  <wsdlOptions>

                                      <wsdlOption>

                                          <wsdl>Order-Process.wsdl</wsdl>

                                      </wsdlOption>

                                  </wsdlOptions>

       

       

                                  <className>ix.service.order.service.OrderProcess</className>

                                  <genWsdl>true</genWsdl>

                                  <keep>true</keep>

                                  <verbose>true</verbose>

                                         <!-- <tasks>

                                              <copy file="${basedir}/generated/wsdl/OrderProcess.wsdl"

                                                    tofile="${basedir}/src/main/resources/wsdl/OrderProcess.wsdl"/>

                                          </tasks> -->

                              </configuration>

                              <goals>

                                  <goal>java2ws</goal>

                              </goals> 

                          </execution>

                      </executions>

                  </plugin>

                  <plugin>

                      <groupId>org.mortbay.jetty</groupId>

                      <artifactId>maven-jetty-plugin</artifactId>

                      <version>6.1.15</version>

                      <configuration>

                          <scanIntervalSeconds>10</scanIntervalSeconds>

                          <connectors>

                              <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">

                                  <port>8080</port>

                              </connector>

                          </connectors>

                          <webXml>${project.build.directory}/web.xml</webXml>

                          <webAppConfig>

                              <contextPath>/</contextPath>

                          </webAppConfig>

                      </configuration>

                  </plugin>

       

       

      web.xml file:

       

       

      <servlet>

              <description>Order Apache CXF Endpoint</description>

              <display-name>cxf</display-name>

              <servlet-name>cxf</servlet-name>

              <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>

              <load-on-startup>1</load-on-startup>

          </servlet>

          <servlet-mapping>

              <servlet-name>cxf</servlet-name>

              <url-pattern>/services/*</url-pattern>

          </servlet-mapping>

          <session-config>

              <session-timeout>60</session-timeout>

          </session-config>

          <context-param>

              <param-name>contextConfigLocation</param-name>

              <param-value>WEB-INF/beans.xml</param-value>

          </context-param>

          <listener>

              <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

          </listener>

       

       

      beans.xml file:

       

       

      <beans xmlns="http://www.springframework.org/schema/beans"

                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"

                xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">

                <import resource="classpath:META-INF/cxf/cxf.xml" />

                <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />

                <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

                <jaxws:endpoint id="orderProcess"

                          implementor="ix.service.order.service.OrderProcessImpl"

       

                                          address="http://www.ixsystems.com.au/orderprocess">

                          <jaxws:features>

                                    <bean class="org.apache.cxf.feature.LoggingFeature" />

                          </jaxws:features>

                </jaxws:endpoint>

      </beans>

       

       

      I think it is either I miss the jetty listener configuration in JBOSS AS7 or incorrection/missing the jetty configuration in the pom.xml, web.xml or beans.xml file. But I could not find any workable answers .

       

      Your suggestion is very appreciated.

       

      Thanks

      SW