configuring a cxf web service in jboss as 7 - web-services

I am developing a new web service. But I cannot seem to figure out the best way to set up the web service to deploy in jboss as 7.
As per the jboss documentation, here is the web.xml.
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<servlet>
<servlet-name>testService</servlet-name>
<servlet-class>com.sgb.testService.ws.web.TestService</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>testService</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
As per the jboss docs, it also needs a jboss-cxf.xml for all the configurations for cxf and spring.
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cxf="http://cxf.apache.org/core"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:wsa="http://cxf.apache.org/ws/addressing"
xmlns:http="http://cxf.apache.org/transports/http/configuration"
xmlns:sec="http://cxf.apache.org/configuration/security"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd ">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<!-- import spring application context configurations -->
<import resource="classpath:META-INF/spring/applicationContext-ws.xml" />
<jaxws:endpoint id="testService"
implementor="com.sgb.testService.ws.web.TestService"
address="/testService" >
<!--
address="http://localhost:8080/testService">
-->
<jaxws:properties>
<entry key="schema-validation-enabled" value="true" />
</jaxws:properties>
<jaxws:invoker>
<bean class="org.jboss.wsf.stack.cxf.InvokerJSE" />
</jaxws:invoker>
</jaxws:endpoint>
And the spring configurations are defined in the ApplicationContext-ws.xml here.
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<context:property-placeholder location="classpath*:META-INF/spring/*.properties" />
<!--
import the common configurations from core sub-module
which contains the declarations for Datasource, EntityManagerFactory & PersistanceUnit
-->
<import resource="applicationContext-core.xml" />
<import resource="applicationContext-jpa.xml" />
<!-- setting up multiple packages to scan for components -->
<context:component-scan base-package="com.sgb.testService.ws.service" />
<!-- Declare the Transaction Manager -->
<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<!-- declare transactions as annotation driven -->
<tx:annotation-driven
transaction-manager="transactionManager" />
Does the above look right?
Am I missing anything?
Specific Question:
For deploying a cxf based web service in jboss AS 7, where does the spring beans configuration (ApplicationContext-ws.xml above) need to be defined?
Can someone point me to a recent (2012) example or tutorial. Most of the examples I find online seem to be old and I cannot seem to find a proper tutorial in the jboss or spring websites...
Thank you.
-SGB
EDIT TO ADD:
The error message seems to indicate that while deploying the war file, jboss is attempting to publish the wsdl to JBOSS_HOME/standalone/data/wsdl/TestService.war, but is failing as it cannot find the schema (xsd file). This is a bit strange as bot the schema and wsdl is inside WEB-INF/wsdl/ directory.
where
JBOSS_HOME = C:\Program Files (x86)\Apache Software Foundation\jboss-as-7.1.1.Final\
ERROR MESSAGE:
15:56:09,146 INFO [org.apache.cxf.service.factory.ReflectionServiceFactoryBean] (MSC service thread 1-4) Creating Service {http://www.sgb.com/Slm/ES
/TestServiceIdentifier}TestServiceIdentifier from WSDL: WEB-INF/wsdl/TestService.wsdl
15:56:09,238 INFO [org.apache.cxf.endpoint.ServerImpl] (MSC service thread 1-4) Setting the server's publish address to be http://localhost:8080/eucl
id-ws
15:56:09,266 INFO [org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher] (MSC service thread 1-4) WSDL published to: JBOSS_HOME/standalone/data/wsdl/testService-ws.war /TestService.wsdl
15:56:09,270 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC00001: Failed to start service jboss.deployment.unit."testService-ws.war".INSTA
LL: org.jboss.msc.service.StartException in service jboss.deployment.unit."testService-ws.war".INSTALL: Failed to process phase INSTALL of deployment "eucl
id-ws.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_33]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_33]
at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_33]
Caused by: java.lang.RuntimeException: Cannot publish wsdl to: JBOSS_HOME\standalone\data\
wsdl\testService-ws.war\TestService.wsdl
at org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher.publishWsdlFiles(WSDLFilePublisher.java:107)
at org.jboss.wsf.stack.cxf.deployment.EndpointImpl.publishContractToFilesystem(EndpointImpl.java:222)
at org.jboss.wsf.stack.cxf.deployment.EndpointImpl.doPublish(EndpointImpl.java:93)
at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:239)
at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:509)
at org.jboss.wsf.stack.cxf.configuration.NonSpringBusHolder.configure(NonSpringBusHolder.java:117)
at org.jboss.wsf.stack.cxf.deployment.aspect.BusDeploymentAspect.startDeploymentBus(BusDeploymentAspect.java:113)
at org.jboss.wsf.stack.cxf.deployment.aspect.BusDeploymentAspect.start(BusDeploymentAspect.java:66)
at org.jboss.as.webservices.deployers.AspectDeploymentProcessor.deploy(AspectDeploymentProcessor.java:74)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1
.Final]
... 5 more
Caused by: java.io.FileNotFoundException: JBOSS_HOME\standalone\data\wsdl\testService-ws.war\TestServiceIdentifier.xsd (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method) [rt.jar:1.6.0_33]
at java.io.FileInputStream.<init>(FileInputStream.java:120) [rt.jar:1.6.0_33]
at java.io.FileInputStream.<init>(FileInputStream.java:79) [rt.jar:1.6.0_33]
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:70) [rt.jar:1.6.0_33]
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:161) [rt.jar:1.6.0_33]
at java.net.URL.openStream(URL.java:1010) [rt.jar:1.6.0_33]
at org.jboss.ws.common.utils.AbstractWSDLFilePublisher.publishSchemaImports(AbstractWSDLFilePublisher.java:243)
at org.jboss.ws.common.utils.AbstractWSDLFilePublisher.publishSchemaImports(AbstractWSDLFilePublisher.java:250)
at org.jboss.ws.common.utils.AbstractWSDLFilePublisher.publishSchemaImports(AbstractWSDLFilePublisher.java:250)
at org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher.publishWsdlFiles(WSDLFilePublisher.java:94)
... 14 more
15:56:09,343 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "testService-ws.war" was rolled back with failure
message {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"testService-ws.war\".INSTALL" => "org.jboss.msc.service.StartException in service jbos
s.deployment.unit.\"testService-ws.war\".INSTALL: Failed to process phase INSTALL of deployment \"testService-ws.war\""}}
15:56:09,413 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015877: Stopped deployment testService-ws.war in 70ms
15:56:09,414 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014777: Services which failed to start: service jboss.deployment.unit."testService-ws.war".INSTALL: org.jboss.msc.service.StartException in serv
ice jboss.deployment.unit."testService-ws.war".INSTALL: Failed to process phase INSTALL of deployment "testService-ws.war"
15:56:09,421 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled ba
ck. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"testService-ws.war\".INSTALL" => "org.jboss.m
sc.service.StartException in service jboss.deployment.unit.\"testService-ws.war\".INSTALL: Failed to process phase INSTALL of deployment \"testService-ws.war\""
}}}}
From the above, the root cause seem to be this:
Caused by: java.io.FileNotFoundException: JBOSS_HOME\standalone\data\wsdl\testService-ws.war\TestServiceIdentifier.xsd (The system cannot find the file specified)
It seems like it is able to find the WSDL, but not the corresponding xsd which it uses which is available in the same directory as WSDL file.

As per this https://issues.jboss.org/browse/JBWS-3532, it might be due to the space in the path of JBOSS_HOME directory. As per a comment by a Richard Opalka in the link above, it looks like it was fixed in a newer build too.
I downloaded the latest nightly of jboss and installed in c:\jboss\ and the problem dis-appeared.

Related

Spring MVC REST Controller test won't autowire WebApplicationContext

Spring 3.2.3.Release and Junit4 4.11
I created a web-application Spring MVC REST project. This is the project which has the controllers which wrap around the Service and the Domain entities. The DAO and Services from the other project are all unit tested and working fine, so that is not the problem. The DAO's and Services have come in from a compiled jar file.
I am using maven, so I do have Spring-web, Spring-webmvc, Spring Core, Spring-Beans, Spring-test ... Spring-test is the 3.2.3.Release version, not the separate GitHub version.
I have spent 2 days looking at the Internet, Google, and StackOverflow, and the Spring Forums for a definitive answer, and yet I can't get the exact answer that I need, so I need another set of eyes to look at my files to see if something is basically wrong.
The problem is my unit test does not work, it's very minimal, but comes up with a huge error, and I can't even execute any tests at all. So, let me start my listing my code and xml files.
If anyone can look at the error and look at the code, if something is off, can you please let me know. And in the meantime I will continue to do more research on my own.
I'll start with the error from the console:
(main)2013-07-30 13:33:56,336 INFO [org.hibernate.impl.SessionFactoryImpl] - <closing>
(main)2013-07-30 13:33:56,336 ERROR [org.springframework.test.context.TestContextManager] - <Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener#6c07588c] to prepare test instance [com.tom.rest.controller.invoice.InvoiceControllerTests#564686bc]>
(main)java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:157)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:211)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:288)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:290)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'invoiceControllerTests': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.web.context.WebApplicationContext com.tom.rest.controller.invoice.InvoiceControllerTests.wac; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [org.springframework.web.context.WebApplicationContext] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1120)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:103)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)
at org.springframework.test.context.support.DelegatingSmartContextLoader.loadContext(DelegatingSmartContextLoader.java:228)
at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:124)
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:148)
... 24 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.web.context.WebApplicationContext com.tom.rest.controller.invoice.InvoiceControllerTests.wac; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [org.springframework.web.context.WebApplicationContext] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:514)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
... 39 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [org.springframework.web.context.WebApplicationContext] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:949)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:818)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:730)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:486)
... 41 more
applicationContext.xml because of the dependency on the dao and service jar, these imports come from that project.
<import resource="classpath:project-dao.xml"/>
<import resource="classpath:project-engines.xml"/>
<import resource="classpath:project-infrastructure.xml"/>
<import resource="classpath:project-interface.xml"/>
<import resource="classpath:project-service.xml"/>
<import resource="classpath:project-transactions.xml"/>
<import resource="classpath:project-ui.xml"/>
<import resource="classpath:project-webservices.xml" />
<context:component-scan base-package="com.tom.viper" />
<context:annotation-config />
<bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor"/>
<bean id="invoiceControllerTests" class="com.tom.rest.controller.invoice.InvoiceControllerTests" />
springmvc-servlet.xml
<beans>
<context:component-scan base-package="com.tom.viper, com.tom.cobra" />
<mvc:annotation-driven>
<mvc:message-converters register-defaults="true">
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="objectMapper">
<bean class="com.fasterxml.jackson.databind.ObjectMapper">
<property name="dateFormat">
<bean class="java.text.SimpleDateFormat">
<constructor-arg type="java.lang.String" value="yyyy-MM-dd"></constructor-arg>
</bean>
</property>
</bean>
</property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<bean id="jsonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes" value="application/json"/>
</bean>
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="jsonHttpMessageConverter" />
</list>
</property>
</bean>
<bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
<property name="messageConverters">
<list>
<ref bean="jsonHttpMessageConverter" />
</list>
</property>
</bean>
</beans>
web.xml
<web-app>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:/log4j.properties</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/classes/applicationContext.xml
/WEB-INF/classes/springmvc-servlet.xml
classpath:project-dao.xml
classpath:project-engines.xml
classpath:project-infrastructure.xml
classpath:project-interface.xml
classpath:project-service.xml
classpath:project-transactions.xml
classpath:project-ui.xml
classpath:project-webservices.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Servlets -->
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>jUnitHostImpl</servlet-name>
<servlet-class>com.google.gwt.junit.server.JUnitHostImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>jUnitHostImpl</servlet-name>
<url-pattern>/RevenueManager/junithost/*</url-pattern>
</servlet-mapping>
<!-- Servlets -->
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
And now the controller tests:
#RunWith(SpringJUnit4ClassRunner.class)
#WebAppConfiguration
#ContextConfiguration(locations =
{
"/applicationContext.xml",
"/springmvc-servlet.xml",
"classpath:project-infrastructure.xml",
"classpath:project-dao.xml",
"classpath:project-service.xml" })
public class InvoiceControllerTests
{
#Autowired
private WebApplicationContext wac;
private MockMvc mockMvc;
#Before
public void setup()
{
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
}
#Test
public void getInvoices()
{
assertEquals(true, true);
}
}
Remove
<bean id="invoiceControllerTests" class="com.tom.rest.controller.invoice.InvoiceControllerTests" />
in your applicationContext.xml.
you can make the InvoiceControllerTest implement ApplicationContextAware and grab the instance of applicationContext from the implementation of the lifecycle method.
Alternatively, you can Autowire specific controller instance that u want to test in ur test class and do a standalone setup like so,
this.mockMvc = MockMvcBuilders.standaloneSetup(this.invoiceController).build();
I came to a new company that had an existing Spring DAO and Services layer created and full unit tested. They use Ivy to handle dependencies and Ant build.xml files to handle the builds. I presumed that when the JAR was created, that this would be a self-contained file (encapsulated) with all the config files and necessary jar files. When I cracked open the JAR file, I was horrified that there was no config files or jars, it was simply the Java code from the project itself. That is why there was no Spring config files.
In my new maven project, it was asking me for all the jars that were missing from the previous project, so I just decided to create a new Maven Spring DAO/Service project and bring all the code over.
So to update:
In this new Maven project for DAO's and Services, I have the Spring config files under; src/main/resources/spring
and when this new JAR compiles, the new spring config files are at:
WEB-INF/classes/spring
So, in my Spring Web MVC project, here is my applicationContext.xml now:
<import resource="classpath*:projct-dao.xml"/>
<import resource="classpath*:projct-engines.xml"/>
<import resource="classpath*:project-infrastructure.xml"/>
<import resource="classpath*:project-interface.xml"/>
<import resource="classpath*:projct-service.xml"/>
<import resource="classpath*:projct-transactions.xml"/>
<import resource="classpath*:project-ui.xml"/>
<import resource="classpath*project-webservices.xml" />
and here is part of the web.xml that handles the spring context files:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/classes/applicationContext.xml
/WEB-INF/viper-servlet.xml
classpath*:project-dao.xml
classpath*:project-engines.xml
classpath*:project-infrastructure.xml
classpath*:poject-interface.xml
classpath*:project-service.xml
classpath*:project-transactions.xml
classpath*:projct-ui.xml
classpath*:project-webservices.xml
</param-value>
</context-param>
Adding the wildcard (*) to the end of the classpath made it find the missing spring context files. This solves the problem with my web-app starting ... I hope this helps someone else.

Server Side Logging with Spring-WS

I have implemented a web services using JaxWS-Spring. I would like to log the XML being received. I have tried various attempts, among which to add the proper categories to my log4j.properties file and using interceptors. However I have always failed for one reason or another (logging seems to be ignored - adding interceptors to my application context gives other issues).
The following snippets from my project :
PS: I am using Spring 2.5.6
web.xml
<servlet>
<servlet-name>jaxws-servlet</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSSpringServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Mapping to redirect all requests from 'FaxWebService' to jaxws-servlet. -->
<servlet-mapping>
<servlet-name>jaxws-servlet</servlet-name>
<url-pattern>/FaxWebService</url-pattern>
</servlet-mapping>
applicationContext.xml
<!-- Bind the URL FaxWebService to our bean FaxWebService. -->
<wss:binding url="/FaxWebService">
<wss:service>
<ws:service bean="#faxWebService"/>
</wss:service>
</wss:binding>
<!-- Bean responsible of taking care of the webservice. -->
<bean id="faxWebService" class="com.connexo.icubeplus3.dispatcher.webservices.FaxWebService"
scope="singleton">
<property name="dummyMode" value="${fax.dummy.mode}"/>
</bean>
I doubt this has anything to do with Spring WS to be honest.
If you want to log the incoming messages in Spring WS, you want to raise the logging level for org.springframework.ws.client.MessageTracing.sent and org.springframework.ws.client.MessageTracing.received to TRACE. For example, in log4j config:
<logger name="org.springframework.ws.client.MessageTracing.sent">
<level value="TRACE" />
<appender-ref ref="stdout" />
</logger>
<logger name="org.springframework.ws.client.MessageTracing.received">
<level value="TRACE" />
<appender-ref ref="stdout" />
</logger>
You will have to write a handler to log it. There are various examples in the web, like http://docs.oracle.com/cd/E13222_01/wls/docs103/webserv_adv_rpc/handlers.html

javaee 5 bookstore sample to run with jboss 4.0 and hibernate

when i am trying to deploy bookstore1 web application from Netbeans ( JavaEE5 sample ) , i have changed the persistence.xml file to use hibernate :
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="book" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/jdbc/BookDB</jta-data-source>
<class>com.sun.bookstore.database.Book</class>
</persistence-unit>
</persistence>
and my mysql-ds.xml file is :
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>jdbc/BookDB</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/bookdb</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<password>1234</password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
I am getting below error:
[STDOUT] Couldn't create bookstore database bean: null
19:16:53,846 INFO [[/bookstore1]] Marking servlet ShowCartServlet as unavailable
19:16:53,846 ERROR [[ShowCartServlet]] Allocate exception for servlet ShowCartServlet
javax.servlet.UnavailableException: Couldn't get database.
at com.sun.bookstore1.servlets.ShowCartServlet.init(ShowCartServlet.java:39)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:806)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
19:17:17,534 INFO [[ShowCartServlet]] Servlet ShowCartServlet is currently unavailable
Can you please let me know where i am making wrong...
JBoss 4.0.x is not a JavaEE5 appserver, it's much too old - it only supports J2EE 1.4
This may not be the problem (it's impossible to tell from the info you've given us), but there's no point continuing with the JavaEE5 sample and JBoss 4.0.x, it just won't work.
You either need to use the J2EE 1.4 sample app, or upgrade your JBoss (to version 5 or 6).

Build a WS with Spring

I need to create a WS with Spring 3.0.4.RELEASE to run in a Tomcat with Axis2. I'm following this doc: http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/remoting.html#remoting-web-services-jaxws-export-ri (if that paragraph can be called "doc")
Ok, here are the details:
The java class:
package foo;
#WebService(serviceName="MyService")
public class MyService{
#WebMethod
public String getString(){
return "Hello StackOverflow";
}
}
The WEB-INF/spring-ws.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ws="http://jax-ws.dev.java.net/spring/core"
xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://jax-ws.dev.java.net/spring/core https://jax-ws.dev.java.net/spring/core.xsd
http://jax-ws.dev.java.net/spring/servlet https://jax-ws.dev.java.net/spring/servlet.xsd">
<wss:binding url="/myService" service="#myService" />
<ws:service id="myService"
impl="foo.MyService" />
</beans>
The WEB-INF/web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="myService" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>my Service</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-ws.xml</param-value>
</context-param>
<!-- this is for Spring -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- these are for JAX-WS -->
<servlet>
<servlet-name>jaxws-servlet</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSSpringServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>jaxws-servlet</servlet-name>
<url-pattern>/myService</url-pattern>
</servlet-mapping>
And last, but not less important, the error when I start tomcat 6.0.29:
Context initialization failed
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://jax-ws.dev.java.net/spring/servlet]
Offending resource: ServletContext resource [/WEB-INF/spring-ws.xml]
Someone has any clue of what is happening? Is all the configuration correct? Does anyone have a simple (working) WS to show how to deploy a WS using Spring?
Thanks in advance
I also experience this issue a while back and figured out the problem is with the "https://". Change it back to http:// and you should be good to go. But when you use http:// you get a schema validation error in eclipse because eclipse can't automatically redirect schema url from http:// to https://. And apparently netbeans is capable of it.
One more thing. You'll have to have the xbeans-spring as well. I honestly think that's a pretty stupid dependency.

Problem with cometd and jetty 6 / 7

I'm trying to get started with cometd (http://cometd.org/) and jetty 6 or 7, but I seem to be having problems. I've got an ant script that packages my code up into a war with the cometd 1.1.1 binaries and jetty binaries that are appropriate to the version of jetty I deploy the war to (so 7.1.2.v20100523 binaries when I deploy to jetty 7.1.2.v20100523 and 6.1.24 when I deploy to 6.1.24). I first tried getting a setup with version 7.1.2.v20100523, but when I tried to deploy I got a very long stack trace sample of which is:
2010-05-26 15:32:12.906:WARN::Problem processing jar entry org/eclipse/jetty/util/MultiPartOutputStream.class
java.io.IOException: Invalid resource
at org.eclipse.jetty.util.resource.URLResource.getInputStream(URLResource.java:204)
at org.eclipse.jetty.util.resource.JarResource.getInputStream(JarResource.java:113)
at org.eclipse.jetty.annotations.AnnotationParser$2.processEntry(AnnotationParser.java:575)
at org.eclipse.jetty.webapp.JarScanner.matched(JarScanner.java:152)
at org.eclipse.jetty.util.PatternMatcher.matchPatterns(PatternMatcher.java:82)
at org.eclipse.jetty.util.PatternMatcher.match(PatternMatcher.java:64)
at org.eclipse.jetty.webapp.JarScanner.scan(JarScanner.java:75)
at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:587)
at org.eclipse.jetty.annotations.AbstractConfiguration.parseWebInfLib(AbstractConfiguration.java:107)
at org.eclipse.jetty.annotations.AnnotationConfiguration.configure(AnnotationConfiguration.java:68)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:992)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:579)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:381)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:36)
at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:182)
at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:497)
at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:135)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileChanged(ScanningAppProvider.java:77)
at org.eclipse.jetty.util.Scanner.reportChange(Scanner.java:490)
at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:355)
at org.eclipse.jetty.util.Scanner.scan(Scanner.java:306)
at org.eclipse.jetty.util.Scanner$1.run(Scanner.java:258)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
2010-05-26 15:32:12.907:WARN::Problem processing jar entry org/eclipse/jetty/util/MultiPartWriter.class
java.io.IOException: Invalid resource
at org.eclipse.jetty.util.resource.URLResource.getInputStream(URLResource.java:204)
at org.eclipse.jetty.util.resource.JarResource.getInputStream(JarResource.java:113)
at org.eclipse.jetty.annotations.AnnotationParser$2.processEntry(AnnotationParser.java:575)
at org.eclipse.jetty.webapp.JarScanner.matched(JarScanner.java:152)
at org.eclipse.jetty.util.PatternMatcher.matchPatterns(PatternMatcher.java:82)
at org.eclipse.jetty.util.PatternMatcher.match(PatternMatcher.java:64)
at org.eclipse.jetty.webapp.JarScanner.scan(JarScanner.java:75)
at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:587)
at org.eclipse.jetty.annotations.AbstractConfiguration.parseWebInfLib(AbstractConfiguration.java:107)
at org.eclipse.jetty.annotations.AnnotationConfiguration.configure(AnnotationConfiguration.java:68)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:992)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:579)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:381)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:36)
at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:182)
at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:497)
at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:135)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileChanged(ScanningAppProvider.java:77)
at org.eclipse.jetty.util.Scanner.reportChange(Scanner.java:490)
at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:355)
at org.eclipse.jetty.util.Scanner.scan(Scanner.java:306)
at org.eclipse.jetty.util.Scanner$1.run(Scanner.java:258)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
2010-05-26 15:32:12.907:WARN::Problem processing jar entry org/eclipse/jetty/util/Attributes.class
java.io.IOException: Invalid resource
at org.eclipse.jetty.util.resource.URLResource.getInputStream(URLResource.java:204)
at org.eclipse.jetty.util.resource.JarResource.getInputStream(JarResource.java:113)
at org.eclipse.jetty.annotations.AnnotationParser$2.processEntry(AnnotationParser.java:575)
at org.eclipse.jetty.webapp.JarScanner.matched(JarScanner.java:152)
at org.eclipse.jetty.util.PatternMatcher.matchPatterns(PatternMatcher.java:82)
at org.eclipse.jetty.util.PatternMatcher.match(PatternMatcher.java:64)
at org.eclipse.jetty.webapp.JarScanner.scan(JarScanner.java:75)
at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:587)
at org.eclipse.jetty.annotations.AbstractConfiguration.parseWebInfLib(AbstractConfiguration.java:107)
at org.eclipse.jetty.annotations.AnnotationConfiguration.configure(AnnotationConfiguration.java:68)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:992)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:579)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:381)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:36)
at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:182)
at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:497)
at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:135)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileChanged(ScanningAppProvider.java:77)
at org.eclipse.jetty.util.Scanner.reportChange(Scanner.java:490)
at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:355)
at org.eclipse.jetty.util.Scanner.scan(Scanner.java:306)
at org.eclipse.jetty.util.Scanner$1.run(Scanner.java:258)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
Seemed to go through all the jetty binaries and complain about each class file.
When I tried to deploy to 6.1.24 I got
org.mortbay.util.MultiException[java.lang.NoClassDefFoundError: org/eclipse/jetty/util/ajax/JSON$Source, java.lang.NoClassDefFoundError: org/eclipse/jetty/util/thread/ThreadPool]
at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:656)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.Server.doStart(Server.java:224)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.xml.XmlConfiguration.main(XmlConfiguration.java:985)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.mortbay.start.Main.invokeMain(Main.java:194)
at org.mortbay.start.Main.start(Main.java:534)
at org.mortbay.start.Main.start(Main.java:441)
at org.mortbay.start.Main.main(Main.java:119)
My web.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<servlet>
<servlet-name>cometd</servlet-name>
<servlet-class>org.cometd.server.continuation.ContinuationCometdServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>cometd</servlet-name>
<url-pattern>/cometd/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>initializer</servlet-name>
<servlet-class>uk.co.dubit.nexus.comet.BayeuxInitializer</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<!-- <filter>
<filter-name>cross-origin</filter-name>
<filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>cross-origin</filter-name>
<url-pattern>/cometd/*</url-pattern>
</filter-mapping> -->
</web-app>
note cross origin filter is commented out. The class didn't seem to exist when I tried to run on 6.1.24 (which as far as I understand is the correct behaviour, yes?).
Sorry for the noob question but does anyone know what I'm doing wrong here?
Regards,
Tom
ok seems there were a couple of problems to work out here. Firstly the version of jetty I was bundling in my war needed to change. I switched to 7.0.2.v20100331. Secondly I had to change the deployment descriptor
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<servlet>
<servlet-name>cometd</servlet-name>
<servlet-class>org.cometd.server.continuation.ContinuationCometdServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>cometd</servlet-name>
<url-pattern>/cometd/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>initializer</servlet-name>
<servlet-class>uk.co.dubit.nexus.comet.BayeuxInitializer</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<filter>
<filter-name>continuation</filter-name>
<filter-class>org.eclipse.jetty.continuation.ContinuationFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>continuation</filter-name>
<url-pattern>/cometd/*</url-pattern>
</filter-mapping>
</web-app>
And finally there's an extra step in deploying a war to jetty 6.1.24 (which is the version I got the code running on in the end), you have to place an XML descriptor for the war in the contexts/ directory. My descriptor looked like
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<configure class="org.mortbay.jetty.webapp.WebAppContext">
<Set name="contextPath">/cometd</Set>
<Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/nexus.war</Set>
</configure>
After that my servlet was accessible from the /cometd path listed in this descriptor.