The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

lollisoft (4) [Avatar] Offline
#1
Hi,

I struggled to get the sample code working. While this I found issues that may not have been reported yet. I will do...

1.) The Chapter2Launcher was not found (ClassNotFoundException).
Add a package declaration has helped me out (package soa.governance.chapter2.trafficsmilie. Moving the class to the path corresponding to package was not enough.
2.) Change version of spring context from 2.1 to 2.5 to get rid of component scan errors.
This change is in applicationcontext.xml in traffic-service-container/src/main/resources.
This is probably because the 2.1 version is no longer present at the original location when
loading int in browser.
3.) Starting the services from console didn't work.
Start it by this from the root directory chapter2 (-e is optional): mvn exec:java -pl traffic-service-container -Dexec.maClass=Chapter2Launcher -e
4.) Main class in pom.xml was reported earlyer, but I put it here for completeness.
See patch...
5.) WSServiceTest service helloClient becomes accountClient.
See patch...

I hope this will be patched so that other readers don't struggle any more smilie
There may be missing bits, but that's for now and how far I came today.

Regards, Lothar

Here is a patch I have made to verify what I have made:

### Eclipse Workspace Patch 1.0
#P chapter2
Index: traffic-service-container/src/main/java/Chapter2Launcher.java
===================================================================
--- traffic-service-container/src/main/java/Chapter2Launcher.java (revision 185)
+++ traffic-service-container/src/main/java/Chapter2Launcher.java (working copy)
@@ -1,27 +0,0 @@
-
-
-import java.io.IOException;
-
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-/**
- * This launcher launches a server which hosts our REST and WS based services. The configuration
- * of these services can be found in the applicationcontext.xml file.
- *
- * @author Jos Dirksen
- */
-public class Chapter2Launcher {
-
- /**
- * Launch the application by loading the spring applicationcontext.
- * @param args not used
- * @throws IOException if something goes wrong readin from stdin
- */
- public static void main(String[] args) throws IOException {
- ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationcontext.xml");
- System.out.println("

--Press enter to terminate this service--");
- System.in.read();
- context.close();
- System.exit(0);
- }
-}
No newline at end of file
Index: traffic-service-container/src/main/java/soa/governance/chapter2/traffic/Chapter2Launcher.java
===================================================================
--- traffic-service-container/src/main/java/soa/governance/chapter2/traffic/Chapter2Launcher.java (revision 0)
+++ traffic-service-container/src/main/java/soa/governance/chapter2/traffic/Chapter2Launcher.java (working copy)
@@ -1,4 +1,4 @@
-
+package soa.governance.chapter2.traffic;

import java.io.IOException;

Index: traffic-service-container/src/test/java/soa/governance/chapter2/traffic/services/ws/WSServiceTest.java
===================================================================
--- traffic-service-container/src/test/java/soa/governance/chapter2/traffic/services/ws/WSServiceTest.java (revision 185)
+++ traffic-service-container/src/test/java/soa/governance/chapter2/traffic/services/ws/WSServiceTest.java (working copy)
@@ -31,7 +31,7 @@
@BeforeClass
public static void setup() throws Exception {
appContext = new ClassPathXmlApplicationContext("applicationcontext-test-ws.xml");
- client = (AccountServicePortType) appContext.getBean("helloClient");
+ client = (AccountServicePortType) appContext.getBean("accountClient");
accountServiceMock = (AccountService) appContext.getBean("accountServiceImpl");
}

Index: traffic-service-container/src/main/resources/applicationcontext.xml
===================================================================
--- traffic-service-container/src/main/resources/applicationcontext.xml (revision 185)
+++ traffic-service-container/src/main/resources/applicationcontext.xml (working copy)
@@ -20,7 +20,7 @@
http://cxf.apache.org/transports/http-jetty/configuration
http://cxf.apache.org/schemas/configuration/http-jetty.xsd
http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context-2.1.xsd">
+ http://www.springframework.org/schema/context/spring-context-2.5.xsd">

<!-- Import the various CXF related configuration which are needed for WS and REST -->
<import resource="classpath:META-INF/cxf/cxf.xml" />
Index: traffic-service-container/pom.xml
===================================================================
--- traffic-service-container/pom.xml (revision 185)
+++ traffic-service-container/pom.xml (working copy)
@@ -21,7 +21,7 @@
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
<configuration>
- <mainClass>soa.governance.chapter2.traffic.CXFBasedJettyLauncher</mainClass>
+ <mainClass>soa.governance.chapter2.traffic.Chapter2Launcher</mainClass>
</configuration>
</plugin>
</plugins>
Index: environment.sh
===================================================================
--- environment.sh (revision 0)
+++ environment.sh (revision 0)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+export CLASSPATH="/Users/lothar/develop/Projects/ReferenzProjekte/WSO2SOAArchitecture/workspace/chapter2/traffic-service-general/target/traffic-service-general-0.0.1-SNAPSHOT.jar:/Users/lothar/develop/Projects/ReferenzProjekte/WSO2SOAArchitecture/workspace/chapter2/traffic-service-remoting-REST/target/traffic-service-remoting-REST-0.0.1-SNAPSHOT.jar:/Users/lothar/develop/Projects/ReferenzProjekte/WSO2SOAArchitecture/workspace/chapter2/traffic-service-remoting-WS/target/traffic-service-remoting-WS-0.0.1-SNAPSHOT.jar:/Users/lothar/develop/Projects/ReferenzProjekte/WSO2SOAArchitecture/workspace/chapter2/traffic-service-container/target/classes/Chapter2Launcher.class"

Property changes on: environment.sh
___________________________________________________________________
Added: svn:executable
+ *