Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Marius Bogoevici
JBoss Web Framework Kit 1.1 Snowdrop Sportsclub Example Integrating Spring with the JBoss Enterprise Platforms Edition 1.0
Author Editor Editor Copyright 2010 Red Hat, Inc. The text of and illustrations in this document are licensed by Red Hat under a Creative Commons AttributionShare Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version. Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law. Red Hat, Red Hat Enterprise Linux, the Shadowman logo, JBoss, MetaMatrix, Fedora, the Infinity Logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries. Linux is the registered trademark of Linus Torvalds in the United States and other countries. Java is a registered trademark of Oracle and/or its affiliates. XFS is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries. MySQL is a registered trademark of MySQL AB in the United States, the European Union and other countries. All other trademarks are the property of their respective owners. Marius Bogoevici Laura Bailey Rebecca Newton mariusb@redhat.com lbailey@redhat.com rnewton@redhat.com
This book provides a walkthrough of the JBoss Snowdrop Sportsclub example. It illustrates several use cases for integrating the JBoss Enterprise Platforms with the Spring Framework.
Preface v 1. Document Conventions ................................................................................................... v 1.1. Typographic Conventions ...................................................................................... v 1.2. Pull-quote Conventions ........................................................................................ vi 1.3. Notes and Warnings ............................................................................................ vii 2. We Need Feedback! ...................................................................................................... vii 1. Introduction 1.1. Prerequisites ................................................................................................................ 1.1.1. Download the Example ...................................................................................... 1.1.2. Setting up Maven repositories ............................................................................ 1.2. How to build and run the examples ............................................................................... 1.2.1. Building the application ...................................................................................... 1.2.2. Initializing the database ..................................................................................... 1.2.3. Preparing your JBoss Enterprise Platform ........................................................... 1.2.4. Deploying the application ................................................................................... 1.2.5. Starting the database ........................................................................................ 1.2.6. Special configuration for distinct profiles .............................................................. 1.3. Sportsclub and JBoss Developer Studio ........................................................................ 1 1 1 1 2 2 2 3 3 3 4 4
2. Understanding the application structure 5 2.1. The application structure and its use cases ................................................................... 5 2.2. A comparative look of the project modules .................................................................... 6 3. Using JBoss and Spring together 7 3.1. A look at the JBoss/Spring integration use cases ........................................................... 7 3.2. The domain model ....................................................................................................... 9 3.3. Persistence implementation: JPA and Hibernate ........................................................... 10 3.3.1. The Hibernate implementation .......................................................................... 10 3.3.2. The JPA implementation .................................................................................. 11 3.3.3. Unit testing the repositories .............................................................................. 12 3.4. Service Layer ............................................................................................................. 12 3.4.1. The Spring-based service layer ........................................................................ 13 3.4.2. The EJB service layer ...................................................................................... 13 3.5. Presentation Layer ..................................................................................................... 14 3.5.1. Subscriptions: JSF and Spring ......................................................................... 14 3.5.2. Reservations: JSF/Spring integration ................................................................ 14 3.5.3. Invoicing: Spring MVC and EJB ........................................................................ 16 3.5.4. A problem of reusing content ........................................................................... 18 3.6. Enterprise Integration Features ................................................................................... 18 3.6.1. Payment processing: JMS integration through JCA ............................................ 18 3.6.2. Aspects and auditing ....................................................................................... 20 3.6.3. Configuring Spring beans through JMX ............................................................. 20 3.6.4. Payment processing: exposing a JAX-WS web service ....................................... 21 A. Revision History 23
iii
iv
Preface
1. Document Conventions
This manual uses several conventions to highlight certain words and phrases and draw attention to specific pieces of information. In PDF and paper editions, this manual uses typefaces drawn from the Liberation Fonts set. The Liberation Fonts set is also used in HTML editions if the set is installed on your system. If not, alternative but equivalent typefaces are displayed. Note: Red Hat Enterprise Linux 5 and later includes the Liberation Fonts set by default.
1
https://fedorahosted.org/liberation-fonts/
Preface Close to switch the primary mouse button from the left to the right (making the mouse suitable for use in the left hand). To insert a special character into a gedit file, choose Applications Accessories Character Map from the main menu bar. Next, choose Search Find from the Character Map menu bar, type the name of the character in the Search field and click Next. The character you sought will be highlighted in the Character Table. Doubleclick this highlighted character to place it in the Text to copy field and then click the Copy button. Now switch back to your document and choose Edit Paste from the gedit menu bar. The above text includes application names; system-wide menu names and items; application-specific menu names; and buttons and text found within a GUI interface, all presented in proportional bold and all distinguishable by context. Mono-spaced Bold Italic or Proportional Bold Italic Whether mono-spaced bold or proportional bold, the addition of italics indicates replaceable or variable text. Italics denotes text you do not input literally or displayed text that changes depending on circumstance. For example: To connect to a remote machine using ssh, type ssh username@domain.name at a shell prompt. If the remote machine is example.com and your username on that machine is john, type ssh john@example.com. The mount -o remount file-system command remounts the named file system. For example, to remount the /home file system, the command is mount -o remount /home. To see the version of a currently installed package, use the rpm -q package command. It will return a result as follows: package-version-release. Note the words in bold italics above username, domain.name, file-system, package, version and release. Each word is a placeholder, either for text you enter when issuing a command or for text displayed by the system. Aside from standard usage for presenting the title of a work, italics denotes the first use of a new and important term. For example: Publican is a DocBook publishing system.
Source-code listings are also set in mono-spaced roman but add syntax highlighting as follows:
package org.jboss.book.jca.ex1; import javax.naming.InitialContext;
vi
Note
Notes are tips, shortcuts or alternative approaches to the task at hand. Ignoring a note should have no negative consequences, but you might miss out on a trick that makes your life easier.
Important
Important boxes detail things that are easily missed: configuration changes that only apply to the current session, or services that need restarting before an update will apply. Ignoring a box labeled 'Important' will not cause data loss but may cause irritation and frustration.
Warning
Warnings should not be ignored. Ignoring warnings will most likely cause data loss.
2. We Need Feedback!
If you find a typographical error in this manual, or if you have thought of a way to make this manual better, we would love to hear from you! Please submit a report in JIRA: http://jira.jboss.org/ against the product JBoss Enterprise Application Platform and component Documentation. When submitting a bug report, be sure to mention the manual's identifier: JBoss Web Framework Kit Snowdrop Sportsclub Example. If you have a suggestion for improving the documentation, try to be as specific as possible when describing it. If you have found an error, please include the section number and some of the surrounding text so we can find it easily.
vii
viii
Chapter 1.
Introduction
The Sportsclub application provides a real world-inspired example of integrating Spring with the JBoss Entprise Platforms. It consists of three web applications, which illustrate several use cases through various combinations of components and technologies. It also illustrates how to use the Snowdrop libraries to provide JBoss-specific features, such as creating a standalone deployment of an ApplicationContext and injecting beans from that application context into non-Spring components like Enterprise Java Beans (EJB). This book aims to illustrate the mechanics of using Spring with different Java EE 5 components in the specific context of the JBoss Enterprise Platforms, and to recommend methods of achieving certain integration goals. The Sportsclub example is not intended as a guide to creating a domain model. Detailing the various layers of application and UI design is outside the scope of this document. As such, the example application has been designed to illustrate integration use cases, rather than to demonstrate a domain model that strictly follows principles of object-oriented and domain-driven design. The Sportsclub example uses RichFaces as a component library for JavaServer Faces (JSF). Consult the RichFaces documentation for RichFaces-specific information.
1.1. Prerequisites
You will need to install the following before you can run the Sportsclub example: Java 6 JDK A JBoss Enterprise Platform (JBoss Enterprise Application Platform 5.0 or later, or JBoss Enterprise Web Platform 5.0 or later) Maven 2.0.9 or later, with properly set up repositories the Snowdrop Spring deployer (see the Snowdrop User Guides for assistance)
Chapter 1. Introduction
Important
The built application can use one of two main profiles: spring-2.5 The default. A Spring 2.5 variant of the application. spring-3 A Spring 3.0 variant of the application. To build the Spring 3.0 variant of the application, use the following command:
mvn clean package -Pspring-3
Preparing your JBoss Enterprise Platform Once this step has been completed, it does not need to be repeated again before running the application, but it can be repeated if the database needs to be reset.
Modify the jbossconf/jbossas.properties file to indicate the correct location of the JBoss AS installation. A commented example is provided.
mvn -Pinstall
This will copy the DataSource and JMS destination definitions into the JBoss server. Like the previous one, this step needs to be executed only once.
Execute one of the two startup scripts: On Linux and other Unix-like systems:
./startdb.sh
On Windows: 3
Chapter 1. Introduction
startdb.bat
The database must be always started before the application server is started and the application is deployed. The application can also be deployed in a running application server (for example after making changes to it), but this should always happen while the database is started.
Alternately, you can install the m2eclipse Maven Eclipse plugin, and use it to import the application.
Chapter 2.
Figure 2.1. Structure of the Sportsclub application All three applications share a common domain model and a common DAO/repository layer, implemented using Spring. The application includes both Hibernate and JPA implementations for the repository layer (using the Hibernate and JPA support provided by JBoss AS, respectively). The application is built in two different variants, each using one of the two DAO implementation alternatives. Apart from that, each web application uses a different combination of technologies, illustrating one or more integration use cases. The Subscriptions application uses an EJB-based service layer and a JSF-based front-end, using Richfaces components. The Reservations application uses a Spring-based business layer and a JSF-based front-end, also using Richfaces components. 5
Chapter 2. Understanding the application structure The Invoicing application uses an EJB service layer and a Spring MVC-based front-end (using JSP and Spring form tags). It also demonstrates the creation of JAX-WS based web services injected with Spring beans, JCA-based Spring JMS integration, auditing by using the Spring AOP configuration and Spring JMX integration.
Sportsclub-jpa-dao
jar
Sportsclub-jpa-ear Sportsclub-staticwebcontent
ear war
Sportsclub-test-infrastructure
jar
Chapter 3.
Spring/JPA integration
Testing
Business Logic
Chapter 3. Using JBoss and Spring together Category Use case How does this involve JBoss Enterprise Platforms TransactionManager in use is the JTATransactionManager using JBoss Transactions provided in JBoss Enterprise Platforms. EJBs injected with Spring Beans The application uses JBossdeployed EJBs which are injected with Spring beans acquired from an application context bootstrapped by the Spring Deployer. Transactions are managed by EJBs. The application uses the JBoss Enterprise Platforms-provided JSF support, and RichFaces components. The business services and UI-backing instances are Spring beans. The application uses Spring MVC and the business logic is implemented using JBossdeployed EJBs, which are injected into the Spring controllers. Spring-configured message listeners are used for processing JMS messages from JBoss Enterprise Platforms-managed destinations. The application uses the Spring /JCA integration for receiving messages.
User Interface
JMS/JCA integration
Aspect-oriented programming
Spring-based weaving of POJO This use case does not aspects have any JBoss Enterprise Platforms-specific functionality. Spring beans are exposed as JMX beans The JBoss Enterprise Platforms MBean Server is used for registering the Spring-exported JMX beans. Consequently, the Spring beans can be managed from the JBoss Enterprise Platforms Administration Console. The application uses JBoss Enterprise Platforms' support for JAX-WS through JBoss WS, but also Spring to define the underlying business logic,
JMX
Web Services
The domain model Category Use case How does this involve JBoss Enterprise Platforms which is injected into the JBoss WS-deployed services.
Figure 3.1. Domain entities of the application and their connections Figure 3.1, Domain entities of the application and their connections shows the domain entities of the application. A few non-entity domain objects have been ommitted from the diagram. Figure 3.2, The Account and Person entities shows a more detailed overview of the entities involved in the Account/ Person relationship, including the non-entity domain objects.
10
public long countAll() { return (Integer)getCurrentSession().createCriteria(clazz).setProjection(Projections.count("id")).uniqueResult() } public Criteria applyRange(Criteria criteria, Range range) { return criteria.setFirstResult(range.getMinIndex()).setMaxResults(range.length()); } }
It is important to notice that this implementation and its subclasses are not Spring-based. The only Spring-related component of this module is the configuration which consists of two files: spring-hibernate-dao/src/main/resources/dao-context.xml Contains the Spring bean definitions for the repository implementations, the Spring-based SessionFactory definition (a LocalSessionFactoryBean) and the wiring of session factories into Spring beans. spring-hibernate-dao/src/main/resources/infrastructure.xml Contains the definitions for infrastructure-related Spring beans, namely the data source to be used for the Hibernate SessionFactory and the transaction manager. Separating the infrastructure context definition file from the rest of the bean definitions allows to swap the infrastructure definition for unit testing. For example, the Hibernate SessionFactory is configured to use JTA transactions, and allows the Session to shared with a layer of EJBs that delegate to it.
Chapter 3. Using JBoss and Spring together if any reference to Spring needs to be removed). Besides the fact that it is using the JPA API - for example an EntityManager instead of the SessionFactory, the JPA Persistence Unit (and subsequent EntityManager) are created by the application server and not created by Spring (the EntityManager is injected by Spring, but acquired from JNDI). The persistence unit is deployed from within the JPA repository jar, in order to allow the spring-domain jar to be deployed in non-JPA scenarios (e.g. Hibernate) without triggering a persistence unit deployment. The Spring application context configuration fragments are very similar to the ones encountered in the Hibernate module: spring-jpa-dao/src/main/resources/dao-context.xml Contains the Spring bean definitions for the repository implementations, assuming an EntityManager bean is defined in the global application context definition. spring-jpa-dao/src/main/resources/infrastructure.xml Contains the definitions for infrastructure-related Spring beans, namely the data source to be used for the Hibernate SessionFactory and the transaction manager.
This configuration reuses the 'application-specific' context configuration fragment, as well as two testspecific (or otherwise said local) context configuration fragments in order to create a Spring context in isolation. Thus, the functionality provided by the repositories can be tested outside the running application.
The Spring-based service layer is also the layer which provides transaction demarcation. One consideration for which transaction demarcation should be done at service level is to ensure that the changes made by service operations are atomic. Otherwise, concurrent operations may leave the application data in an inconsistent state. Demarcating transactions at the repository/DAO level should be done carefully, taking into consideration that multiple repository/DAO invocations that are not surrounded by a wrapping transactions will execute in separate transactional contexts. In the Sportsclub application, there are two variants of implementing the service layer: using Spring (Reservations, parts of Invoicing) using EJB (Subscriptions, Invoicing)
Note
It is possible to define transactions at the repository level, thus avoiding another indirection to the persistence layer for simple persistence operations (finding an object, persisting an object).
13
</beans>
The injection task is undertaken by the SpringLifecycleInterceptor. Once it encounters a field or setter annotated with @Spring, it will look for the JNDI-bound application context and inject the corresponding Spring bean.
Reservations: JSF/Spring integration defines a number of Spring beans that are used directly in the web tier by the JSF pages or by the RichFaces components; The Spring configuration file imports the Spring business beans and infrastructure definitions as follows:
<import resource="classpath*:reservations-service.xml"/> <import resource="classpath*:infrastructure.xml"/>
The following bean is used for backing JSF pages. Please note that Spring beans defined in the web layer may use scopes, and a significant number of the Spring beans used in Reservations application are session-scoped (like the one in the following example). Spring provides a request scope as well, but it is not used in this example.
<bean id="reservationCreate" class="org.jboss.snowdrop.samples.Sportsclub.jsf.beans.ReservationCreate" scope="session" init-method="init"> <property name="reservationService" ref="reservationService"/> <property name="accountService" ref="accountService"/> <property name="accountFilter" ref="accountFilterCreate"/> <property name="equipmentFilter" ref="equipmentFilterCreate"/> </bean>
In order to make the Spring beans visible to JSF pages, a special VariableResolver has to be defined in /WEB-INF/faces-config.xml.
<application> <!-- other definitions --> <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver> </application>
Now, we can use the Spring bean defined above directly in a JSF page, as in the following excerpt from createReservation.xhtml:
<rich:panel> <f:facet name="header">Select Account</f:facet> <h:form id="AccountSelectForm"> <rich:extendedDataTable id="accountsTable" value="#{accountFilterCreate}" var="account" selectionMode="single" selection="#{accountFilterCreate.selection}" enableContextMenu="true" height="250px" rows="5"> <a4j:support event="onselectionchange" action="#{reservationCreate.updateSelectedAccount}" reRender="reservationDetails"/> <rich:column label="Id" width="7%"> <f:facet name="header"> <h:outputText value="Id"/> </f:facet> <h:outputText value="#{account.id}"/> </rich:column> <rich:column label="First Name"> <f:facet name="header"> <h:outputText value="First Name"/> </f:facet> <h:outputText value="#{account.subscriber.name.firstName}"/> </rich:column>
15
<rich:column label="Last Name"> <f:facet name="header"> <h:outputText value="Last Name"/> </f:facet> <h:outputText value="#{account.subscriber.name.lastName}"/> </rich:column> <rich:column label="City"> <f:facet name="header"> <h:outputText value="City"/> </f:facet> <h:outputText value="#{account.subscriber.address.city}"/> </rich:column> <rich:column label="Country"> <f:facet name="header"> <h:outputText value="Country"/> </f:facet> <h:outputText value="#{account.subscriber.address.country}"/> </rich:column> <f:facet name="footer"> <rich:datascroller id="scrollerAccount" for="accountsTable" maxPages="5" page="#{accountFilterCreate.currentPage}"/> </f:facet> </rich:extendedDataTable> </h:form> </rich:panel>
All the EL variables that are used in the previous example, including the ones referenced in the RichFaces elements are, in fact, Spring beans. They can be used either as backing beans for retrieving and setting values, as well as for invoking methods corresponding to JSF events.
16
@RequestMapping(value = "/generateInvoice.do", method = RequestMethod.POST) ModelMap generateInvoice(@RequestParam("id") String id) { Account account = subscriptionService.findAccountById(Long.parseLong(id)); Invoice invoice = billingService.generateInvoice(account); ModelMap model = new ModelMap(); model.addAttribute("id",id); model.addAttribute(invoice); return model; } }
The @Controller annotation will be detected by Spring, as it does a scanning of the classpath which is prompted by including the following line into /WEB-INF/spring-servlet-context.xml.
<context:component-scan base-package="org.jboss.snowdrop.samples.Sportsclub.springmvc"/>
As a Spring-managed object, the bean is injected with the EJBs BillingService and SubscriptionService, as required by annotated the respective fields with the @EJB annotation. The @RequestMapping-annotated methods will be executed when the user is accessing the specified URL and HTTP method. The request parameters will be bound to method arguments. In the example above, invoking the URL http://localhost:8080/sportsclub/invoicing/accountDetail.do?id=1 will cause the invocation accountController.getAccountDetail(1). The method will invoke the appropriate business services (in this case, exposed as EJBs) and will return a map of business object collections, indexed by their names. Spring MVC will take care of setting them on the request, so that they can be used for rendering the response. By default, Spring MVC will try to find a view whose name is 'accountDetail', and based on the view resolver definition from /WEB-INF/spring-servlet-context.xml, it will use the JSP file at /WEB-INF/jsp/ accountDetail.jsp. This JSP uses the Spring tag libraries for form processing, so that the collections previously returned will be accessible using JSTL expressions, and furthermore, we will find the following declaration:
<form:form action="generateInvoice.do">
17
Clicking the 'Create Invoice' button will result in a POST submission to http://localhost:8080/sportsclub/ invoicing/generateInvoice.do?id=1 and the subsequent invocation of the generateInvoice method. A small note here: in order to be able to demonstrate a few Spring/JBoss integration features, the Invoicing application also contains a number of business services that are using Spring. They do not play any role in the Spring MVC/EJB integration, and we will discuss more about them in section 6.
Note
When working in an IDE this might produce an undesirable side-effect. If the IDE does not know how to apply Maven overlays correctly, the static content may not be available when building and deploying the application through the IDE, without Maven. This does not affect the general functionality of the application but may affect the look and feel in that particular situation. However, if the application is build using Maven, this will not be a problem.
Payment processing: JMS integration through JCA asynchronously, through a JMS queue. Once such a payment has been received, it can be processed by a message-driven component, which in our case is a Spring bean. In order to take full advantage of the managed environment provided by the application server, the Spring bean will be invoked in a JCA context. The component that processes JMS messages is a POJO:
public class PaymentNotificationProcessor { private static final Log LOG = LogFactory.getLog(PaymentNotificationProcessor.class); @Autowired private PaymentProcessor paymentProcessor; public void processPaymentNotification(PaymentNotification paymentNotification) { LOG.info(paymentNotification + " received"); paymentProcessor.processPayment(paymentNotification.getAccountNumber(), paymentNotification.getAmount()); LOG.info(paymentNotification + " processed"); } }
It delegates the actual processing of a PaymentNotification to a different component, the PaymentProcessor, which is injected in the PaymentNotificationProcessor. This is done in order to maintain a degree of separation between the way data may be represented when exchanged over the messaging system (i.e. encapsulated in a PaymentNotification object), and the contract of the internal component which actually does the processing. The PaymentProcessor instance injected into the PaymentNotificationProcessor is, in fact, reused by the PaymentNotificationService web service implementation (whose contract does not depend on the PaymentNotification entity). The arrival of messages and their processing can be traced by examining the application log. Spring will instantiate a bean named "paymentNotificationProcessor" which will be registered as a processor for JMS message as follows:
<jms:jca-listener-container resource-adapter="resourceAdapter" acknowledge="auto" activation-spec-factory="activationSpecFactory"> <jms:listener destination="/queue/Sportsclub" ref="paymentNotificationProcessor" method="processPaymentNotification"/> </jms:jca-listener-container>
This type of configuration uses the JCA infrastructure to deliver messages to the listener, as opposed to the DefaultMessageListenerContainer which is effectively polling the destination for incoming messages. Using JCA will ensure better performance, as well as the ability to integrate with the JTA transaction manager out of the box. In order to be able to test this feature, messages have to be sent to the message queue. This can be done by using a special MBean defined by the application, accessible from the JBoss Enterprise Platforms JMX console. The name of the bean is "Sportsclub:name=paymentNotificationTrigger" and has an operation called 'sendPaymentNotification' with two arguments: a long value, which is the accountId for making the payment; a double value, which represents the amount to be paid; Once the JMX operation is invoked, a message is sent to the queue and a confirmation message will be displayed in the JBoss log. 19
As you can see, the aspect is defined as a bean and applied as an aspect through the Spring aop namespace. The pointcut definition is an AspectJ expression.
20
The annotations ManagedResource and ManagedAttribute are using to indicate what classes and properties are JMX-managed. In order to expose the bean through JMX, it must be exported using Spring's MBean Exporter.
<bean id="attributeSource" class="org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource"/> <bean class="org.springframework.jmx.export.MBeanExporter"> <property name="autodetectModeName" value="AUTODETECT_ASSEMBLER"/> <property name="ensureUniqueRuntimeObjectNames" value="true"/> <property name="namingStrategy"> <bean class="org.springframework.jmx.export.naming.MetadataNamingStrategy"> <property name="attributeSource" ref="attributeSource"/> </bean> </property> <property name="assembler"> <bean class="org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler"> <property name="attributeSource" ref="attributeSource"/> </bean> </property> </bean>
As a result, you can turn this functionality on and off directly from the JBoss Enterprise Platforms JMX administration console, using the "sportsclub:name=paymentAuditor" bean to interact with the payment auditor. As explained in the JMS section, a separate MBean is set up for setting messages to the payment notifications message queue.
Chapter 3. Using JBoss and Spring together To that end, a JAX-WS annotated class is provided by the application:
@WebService public class PaymentNotificationService extends SpringBeanAutowiringSupport { @Autowired private PaymentProcessor paymentProcessor; @WebMethod public Long notifyPayment(Long accountNumber, BigDecimal amount) { return paymentProcessor.processPayment(accountNumber, amount); } }
By extending SpringBeanAutowiringSupport, the class PaymentNotificationService will be injected automatically with the same PaymentProcessor instance that is used by the JMS notification processor, and defined in the application context created from WEB-INF/spring-business-context.xml. This is necessary, because no bean of the type PaymentNotificationService is defined in the application context. Instead, the web service is defined and mapped as a servlet in /WEB-INF/ web.xml:
<servlet> <servlet-name>PaymentNotificationService</servlet-name> <servlet-class>org.jboss.snowdrop.samples.sportsclub.ws.PaymentNotificationService</ servlet-class> </servlet> <servlet-mapping> <servlet-name>PaymentNotificationService</servlet-name> <url-pattern>/ws/payment</url-pattern> </servlet-mapping>
As a result, the a JAX-WS web service can be accessed at http://localhost:8080/ws/payment. The service can be tested using a free SOAP testing tool such as SOAP UI.
22
23
24