621862 (10) [Avatar] Offline
#1
Chapter 2, I had to add this to the root pom.xml to resolve some dependencies

<repositories>
<repository>
<id>mvnrepository</id>
<name>mvnrepository</name>
<url>https://www.mvnrepository.com/artifact/</url>
</repository>
<repository>
<id>jboss-repo</id>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
</repositories>

Still some projects run from chapter pom level some I have to go down to lower level.

Next in chapter4 I a fighting with arquillian SEVERE [org.wildfly.swarm.arquillian.runtime.DaemonService] (MSC service thread 1-3) Couldn't bind Arquillian Daemon on localhost:12345; you can change the port using system property 'swarm.arquillian.daemon.port': java.net.BindException: Address already in use.

I had a similar issue with chapter2 UI.
13 verbose stack Error: cayambe-admin-ui@1.0.0 build: `webpack --config webpack.config.production.js`

I believe running it from super level worked
621862 (10) [Avatar] Offline
#2
Code example issues
Running the test with -Dswarm.arquillian.daemon.port=22222 did work for me, but it would be nice to have e.g. arquillian.xml in the git repo for the chapter to fix it permanently

e.g. test/resources arquillian.xml

<?xml version="1.0" encoding="UTF-8"?>

<arquillian xmlnssmiliesi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://jboss.org/schema/arquillian" xsi:schemaLocation="http://jboss.org/schema/arquillian
http://jboss.org/schema/arquillian/arquillian_1_0.xsd">

<!--
- must be in a separate file because in-container tests need to use Swarm's DaemonProtocol,
- but arquillian.xml sets the default protocol to "Servlet 3.0" and there's no way to override that
- (see https://issues.jboss.org/browse/ARQ-579)
-->
<container qualifier="wildfly-swarm" default="true">
<configuration>
<property name="javaVmArguments">
-Dswarm.arquillian.daemon.port=22225
</property>
</configuration>
</container>
</arquillian>

Note: However, the above worked only when port 12345 was occupied. Once it was released it would get connection timeout

Still I get
ejm.admin.CategoryResourceTest Time elapsed: 25.714 sec <<< ERROR!
java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

when running from command line.. so for JDK11

add this to the service pom.xml
https://stackoverflow.com/questions/43574426/how-to-resolve-java-lang-noclassdeffounderror-javax-xml-bind-jaxbexception-in-j

that makes it run

but repeated tests fail, seem like a java process is left running
621862 (10) [Avatar] Offline
#3
Code example issues
Chapter 5:

mvn clean fabric8:deploy -Popenshift

ERROR] Failed to execute goal io.fabric8:fabric8-maven-plugin:3.5.33:build (default) on project chapter5-admin: Execution default of goal io.fabric8:fabric8-maven-plugin:3.5.33:build failed: S2I not yet supported for the webapp-generator. Use -Dfabric8.mode=kubernetes or -Dfabric8.build.strategy=docker for OpenShift mode. Please refer to the reference manual at https://maven.fabric8.io for details about build modes. -> [Help 1]

Seems like each chapter has an issue to face.. smilie..

I needed to update version to

<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>3.5.42</version>

The tests fail also:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.20.1:integration-test (default) on project chapter5-admin: Execution default of goal org.apache.maven.plugins:maven-failsafe-plugin:2.20.1:integration-test failed.: NullPointerException -> [Help 1]

Caused by: java.lang.NullPointerException
at org.apache.maven.surefire.shade.org.apache.commons.lang3.SystemUtils.isJavaVersionAtLeast(SystemUtils.java:1626)

Solution:
Two parts:
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.1</version>

and add JAXB
https://stackoverflow.com/questions/43574426/how-to-resolve-java-lang-noclassdeffounderror-javax-xml-bind-jaxbexception-in-j
621862 (10) [Avatar] Offline
#4
Code example issues
Just to get some break, this seems much suggesting to use Spring, while I am Java EE friendly, does not the memory stamp play a significant role for the cloud-based environment?

http://ksoong.org/wildfly-swarm-spring-boot
https://blog.akquinet.de/2017/01/12/the-lightweightness-of-microservices-comparing-spring-boot-wildly-swarm-and-haskell-snap/

Perhaps thorntail did improvements, but this would be better for Ken to respond as they must have done some internal tests for thorntail?
621862 (10) [Avatar] Offline
#5
Code example issues
Ch6 the clients would not load on the URL with the context "/"

so added @ApplicationPath("/apachehttpclient")
public class ApacheHttpClientApplication extends Application {
}

and http://localhost:8080/apachehttpclient/async works

621862 (10) [Avatar] Offline
#6
Code example issues
Chapter 7

similarly, I extended the plugin version,

the stripe fails in the minicube

2018-12-06 03:21:01,071 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC000001: Failed to start service "swarm.topology.openshift".client: org.jboss.msc.service.StartException in service "swarm.topology.openshift".client: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:197smilie
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:74smilie
Caused by: com.openshift.restclient.NotFoundException:

which then continues with

1:03,053 ERROR [org.jboss.as] (Controller Boot Thread) WFLYSRV0026: Thorntail 2.2.0.Final (WildFly Core 3.0.8.Final) started (with errors) in 2723ms - Started 122 of 133 services (3 services failed or missing dependencies, 20 services are lazy, passive or on-demand)
2018-12-06 03:21:03,078 ERROR [stderr] (main) java.lang.RuntimeException: org.jboss.msc.service.StartException in service "swarm.topology.openshift".client: Failed to start service

When I deploy the ribbon-client

the log in minishoft gives me the same:
2018-12-06 03:24:14,760 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC000001: Failed to start service "swarm.topology.openshift".client: org.jboss.msc.service.StartException in service "swarm.topology.openshift".client: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:197smilie
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:74smilie
Caused by: com.openshift.restclient.NotFoundException:

and then

2018-12-06 03:24:18,281 ERROR [org.jboss.as] (Controller Boot Thread) WFLYSRV0026: Thorntail 2.2.0.Final (WildFly Core 3.0.8.Final) started (with errors) in 4885ms - Started 100 of 109 services (3 services failed or missing dependencies, 16 services are lazy, passive or on-demand)
2018-12-06 03:24:18,289 ERROR [stderr] (main) java.lang.RuntimeException: org.jboss.msc.service.StartException in service "swarm.topology.openshift".client: Failed to start service

Well do not know what these mean smilie

Reload of ribbon gives me
Caused by: java.lang.IllegalStateException: The LogManager was not properly installed (you must set the "java.util.logging.manager" system property to "org.jboss.logmanager.LogManager")

Seems like this:
https://issues.jboss.org/browse/THORN-2166
TODO:
Change the master root pom.xml to thorntail 2.2.1.Final
621862 (10) [Avatar] Offline
#7
Code example issues
Chapter 8 again issues

1. upgrade POM.xml
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>3.5.42</version>
2. make new client root
package ejm.resteasyclient;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

@ApplicationPath("/")
public class ClientApplication extends Application {
}


The client in the minishift cannot find the stripe from browser, need to post JSON via Postman (easy to get confused) so if you see:
LOG:
2018-12-09 16:22:26,223 ERROR [org.jboss.resteasy.resteasy_jaxrs.i18n] (default task-3) RESTEASY002010: Failed to execute: javax.ws.rs.NotAllowedException: RESTEASY003650: No resource method found for GET, return 405 with Allow header
at org.jboss.resteasy.core.registry.SegmentNode.match(SegmentNode.java:426)

That is it. Second testing of the standalone stock-client works, but had to add (3.):
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>

When I deploy strip on minishift and go by postment to post json
http://chapter8-stripe-myproject.192.168.99.100.nip.io/charge
{
"amount":7843,
"cardToken":"tok_visa_debit"
}
I get an answer..

The same with

http://chapter8-resteasy-client-myproject.192.168.99.100.nip.io/sync

but perhaps posting something wrong smilie
{
"chargeId": null,
"amount": 7843,
"orderId": null,
"chargeStatus": "FAILED"
}
few more tests gave me
{
"chargeId": "ch_1DfczOAyvmYuT8zsP2aGAug0",
"amount": 7843,
"orderId": null,
"chargeStatus": "SUCCESS"
}

next to go smilie
621862 (10) [Avatar] Offline
#8
Code example issues
Chapter 9, I did not get it with the localhost URL until I run into problems...

So to find your IP use this:
https://howchoo.com/g/mte2zgrhmjf/how-to-access-a-website-running-on-localhost-from-a-mobile-phone

and then access your keycloak e.g.
http://192.168.1.105:9090/auth
621862 (10) [Avatar] Offline
#9
Chapter 10

again change most pom.xml to

<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>3.5.42</version>


Add to Cayambe and web-commonunder the pom <build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<executable>/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/bin/javac</executable>
<compilerVersion>1.6</compilerVersion>
</configuration>
</plugin>
</plugins>

Next: issue with UI

Install npm
https://stackoverflow.com/questions/31472755/sudo-npm-command-not-found/52087213


Attempts (did not work):
npm install webpack
npm install webpack-cli@3.1.2

Error: webpack.optimize.UglifyJsPlugin has been removed, please use config.optimization.minimize instead.

this below did not help ;(
npm i -D uglifyjs-webpack-plugin
or
npm i -D uglifyjs-3-webpack-plugin



This made to work [file webpack.config.production.js]



module.exports = {
  devtool: 'source-map',

  entry: './app/index.js',

  output: {
    path: path.join(__dirname, 'target/cayambe-admin-ui'),
    filename: 'bundle.js',
    publicPath: '/'
  },

  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loaders: ['babel-loader']
      }
    ]
  },
  optimization: {
    minimizer: [
      new UglifyJsPlugin({
        uglifyOptions: {
          output: {
            comments: false
          },
          compress: {
            warnings: false,
          }
        }
      }),
    ]
  },	

  plugins: [
    new webpack.optimize.OccurrenceOrderPlugin(),

    new webpack.DefinePlugin({
      'process.env': {
        'NODE_ENV': JSON.stringify('production')
      }
    })
  ]
};



npm start seems to use another config ;(

change in webpack.config.js module loader to

module: {
rules: [

you will also need to change all the IP addressed for keycloak
run ifconfig to find your 192.168.1.xxx

and replace it in all references like keycloak.json + yaml files (have 22 and 13 there)

change category-actions.js and put there URL to your service in minishift you get from minishift console

also one one hardcoded here: SubmitOrderAction.java

Add below code to payment-service

@ApplicationPath("/")
public class ClientApplication extends Application {
}
621862 (10) [Avatar] Offline
#10
Chapter 11

change URL to what you see in eth0 in
vim src/main/resources/project-defaults.yml

change URL in /cayambe-admin-ui/app/actions/category-actions.js to
[code]
const ROOT_URL = 'http://cayambe-admin-service-kafka-myproject<......>
[\code]

The book is missing one dash
./bin/kafka-console-consumer.sh --bootstrap-server 172.30.225.60:9092 –
? from-beginning --topic category_topic
meant -- from-beginning


For some reason I do not see anything smilie
sh-4.4$ ./bin/kafka-console-consumer.sh --bootstrap-server 172.30.4.193:9092 --from-beginning --topic category_topic
WARN [Consumer clientId=consumer-1, groupId=console-consumer-29215] Connection to node -1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)

..
kafka ClusterIP 172.30.4.193 <none> 9092/TCP 1h


While my delete worked
2019-01-03 21:54:43,654 INFO [org.apache.kafka.common.utils.AppInfoParser] (default task-1) Kafka version : 0.10.2.1
2019-01-03 21:54:43,654 INFO [org.apache.kafka.common.utils.AppInfoParser] (default task-1) Kafka commitId : e89bffd6b2eff799
2019-01-03 21:55:04,151 INFO [stdout] (default task-4) Ken Finnigan is deleting category with id: 1013


The consumer picked it up, but the Kafka console protests smilie

./bin/kafka-topics.sh --list --zookeeper 172.30.133.190:2181
__consumer_offsets
category_topic


This localhost would give me a 3x null
./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --from-beginning --topic category_topic
null
null
null
Processed a total of 3 messages

I guess that is it as I just posted one more and get four
oc rsh kafka-0 ./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --from-beginning --topic category_topic
null
null
null
null


I think that it should be localhost:9092 since kafka-console-producer.sh --broker-list 172.30.4.193:9092 does not work

oc rsh kafka-0 ./bin/kafka-console-producer.sh --broker-list 172.30.4.193:9092 --topic category_topic
>Ahoj
^Ccommand terminated with exit code 130


below works
oc rsh kafka-0 ./bin/kafka-console-producer.sh --broker-list localhost:9092 --topic category_topic
>Ahoj
>Hello
>^Ccommand terminated with exit code 130

It allows to print the key, but for some reason it is '?'

oc rsh kafka-0 ./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --from-beginning --topic category_topic --property print.key=true --property key.separator="-"
?-null
?-null
?-null
?-null
null-Ahoj
null-Hello
?-{"id":1020,"name":"foo","header":"foo","visible":true,"imagePath":"foo","parent":null,"created":{"year":2019,"month":"JANUARY","dayOfMonth":5,"dayOfWeek":"SATURDAY","monthValue":1,"hour":3,"minute":14,"second":8,"nano":869000000,"dayOfYear":5,"chronology":{"calendarType":"iso8601","id":"ISO"}},"updated":null,"version":0}