This workspace will show how to query a Couchbase bucket using simple Java EE application deployed on WildFly. Alternative configuration is also provided to deploy on Payara/GlassFish.
docker swarm init
docker-compose up -d
Creating network "couchbasejavaee_default" with the default driver
Pulling web (arungupta/wildfly-admin:latest)...
latest: Pulling from arungupta/wildfly-admin
a3ed95caeb02: Pull complete
fa32110542d8: Pull complete
15db7fa11ba9: Pull complete
a701e6df8ee7: Pull complete
6e1e0efdee86: Pull complete
191bf863124f: Pull complete
16ade257aae0: Pull complete
df6d4a72b040: Pull complete
Digest: sha256:a86d9e3807dd002ef070eea16bb90ae55d966da0a53fdc8ab121dcb505db1a20
Status: Downloaded newer image for arungupta/wildfly-admin:latest
Pulling db (couchbase:latest)...
latest: Pulling from library/couchbase
56eb14001ceb: Pull complete
7ff49c327d83: Pull complete
6e532f87f96d: Pull complete
3ce63537e70c: Pull complete
b8145bb24a3f: Pull complete
e6e203bac6d0: Pull complete
566dfc7d9e85: Pull complete
a2c938a8a28b: Pull complete
c6f4b64cd81f: Pull complete
9471cd6d0816: Pull complete
b5dbff584fd2: Pull complete
cb803d8435bd: Pull complete
Digest: sha256:c28ef137a77914333cd65e5cdf187e38507627d83caa06f4748ca0f596e49bea
Status: Downloaded newer image for couchbase:latest
Creating couchbasejavaee_db_1
Creating couchbasejavaee_web_1
mvn install -Pcouchbase -Ddocker.host=localhost
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building couchbase-javaee 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ couchbase-javaee ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ couchbase-javaee ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ couchbase-javaee ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/arungupta/workspaces/couchbase-javaee/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ couchbase-javaee ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ couchbase-javaee ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ couchbase-javaee ---
[INFO] Packaging webapp
[INFO] Assembling webapp [couchbase-javaee] in [/Users/arungupta/workspaces/couchbase-javaee/target/couchbase-javaee]
[INFO] Processing war project
[INFO] Copying webapp resources [/Users/arungupta/workspaces/couchbase-javaee/src/main/webapp]
[INFO] Webapp assembled in [62 msecs]
[INFO] Building war: /Users/arungupta/workspaces/couchbase-javaee/target/couchbase-javaee.war
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ couchbase-javaee ---
[INFO] Installing /Users/arungupta/workspaces/couchbase-javaee/target/couchbase-javaee.war to /Users/arungupta/.m2/repository/org/couchbase/sample/couchbase-javaee/1.0-SNAPSHOT/couchbase-javaee-1.0-SNAPSHOT.war
[INFO] Installing /Users/arungupta/workspaces/couchbase-javaee/pom.xml to /Users/arungupta/.m2/repository/org/couchbase/sample/couchbase-javaee/1.0-SNAPSHOT/couchbase-javaee-1.0-SNAPSHOT.pom
[INFO]
[INFO] --- exec-maven-plugin:1.4.0:exec (Configure memory) @ couchbase-javaee ---
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying ::1...
* Connected to localhost (::1) port 8091 (#0)
> POST /pools/default HTTP/1.1
> Host: localhost:8091
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Length: 36
> Content-Type: application/x-www-form-urlencoded
>
} [36 bytes data]
* upload completely sent off: 36 out of 36 bytes
< HTTP/1.1 200 OK
< Server: Couchbase Server
< Pragma: no-cache
< Date: Sat, 16 Jul 2016 05:31:23 GMT
< Content-Length: 0
< Cache-Control: no-cache
<
100 36 0 0 100 36 0 4338 --:--:-- --:--:-- --:--:-- 4500
* Connection #0 to host localhost left intact
[INFO]
[INFO] --- exec-maven-plugin:1.4.0:exec (Configure services) @ couchbase-javaee ---
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying ::1...
* Connected to localhost (::1) port 8091 (#0)
> POST /node/controller/setupServices HTTP/1.1
> Host: localhost:8091
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Length: 26
> Content-Type: application/x-www-form-urlencoded
>
} [26 bytes data]
* upload completely sent off: 26 out of 26 bytes
< HTTP/1.1 200 OK
< Server: Couchbase Server
< Pragma: no-cache
< Date: Sat, 16 Jul 2016 05:31:23 GMT
< Content-Length: 0
< Cache-Control: no-cache
<
100 26 0 0 100 26 0 3447 --:--:-- --:--:-- --:--:-- 3714
* Connection #0 to host localhost left intact
[INFO]
[INFO] --- exec-maven-plugin:1.4.0:exec (Setup credentials) @ couchbase-javaee ---
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying ::1...
* Connected to localhost (::1) port 8091 (#0)
> POST /settings/web HTTP/1.1
> Host: localhost:8091
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Length: 50
> Content-Type: application/x-www-form-urlencoded
>
} [50 bytes data]
* upload completely sent off: 50 out of 50 bytes
< HTTP/1.1 200 OK
< Server: Couchbase Server
< Pragma: no-cache
< Date: Sat, 16 Jul 2016 05:31:24 GMT
< Content-Type: application/json
< Content-Length: 39
< Cache-Control: no-cache
<
{ [39 bytes data]
100 89 100 39 100 50 3716 4764 --:--:-- --:--:-- --:--:-- 5000
* Connection #0 to host localhost left intact
{"newBaseUri":"http://localhost:8091/"}[INFO]
[INFO] --- exec-maven-plugin:1.4.0:exec (Set storage mode) @ couchbase-javaee ---
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying ::1...
* Connected to localhost (::1) port 8091 (#0)
* Server auth using Basic with user 'Administrator'
> POST /settings/indexes HTTP/1.1
> Host: localhost:8091
> Authorization: Basic QWRtaW5pc3RyYXRvcjpwYXNzd29yZA==
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Length: 28
> Content-Type: application/x-www-form-urlencoded
>
} [28 bytes data]
* upload completely sent off: 28 out of 28 bytes
< HTTP/1.1 200 OK
< Server: Couchbase Server
< Pragma: no-cache
< Date: Sat, 16 Jul 2016 05:31:24 GMT
< Content-Type: application/json
< Content-Length: 152
< Cache-Control: no-cache
<
{ [152 bytes data]
100 180 100 152 100 28 9831 1811 --:--:-- --:--:-- --:--:-- 10133
* Connection #0 to host localhost left intact
{"storageMode":"memory_optimized","indexerThreads":0,"memorySnapshotInterval":200,"stableSnapshotInterval":5000,"maxRollbackPoints":5,"logLevel":"info"}[INFO]
[INFO] --- exec-maven-plugin:1.4.0:exec (Install travel-sample bucket) @ couchbase-javaee ---
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying ::1...
* Connected to localhost (::1) port 8091 (#0)
* Server auth using Basic with user 'Administrator'
> POST /sampleBuckets/install HTTP/1.1
> Host: localhost:8091
> Authorization: Basic QWRtaW5pc3RyYXRvcjpwYXNzd29yZA==
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Length: 17
> Content-Type: application/x-www-form-urlencoded
>
} [17 bytes data]
* upload completely sent off: 17 out of 17 bytes
< HTTP/1.1 202 Accepted
< Server: Couchbase Server
< Pragma: no-cache
< Date: Sat, 16 Jul 2016 05:31:24 GMT
< Content-Type: application/json
< Content-Length: 2
< Cache-Control: no-cache
<
{ [2 bytes data]
100 19 100 2 100 17 16 140 --:--:-- --:--:-- --:--:-- 141
* Connection #0 to host localhost left intact
[][INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.048 s
[INFO] Finished at: 2016-07-15T22:31:24-07:00
[INFO] Final Memory: 13M/309M
[INFO] ------------------------------------------------------------------------
mvn install -Pwildfly -Dwildfly.hostname=localhost -Dwildfly.username=admin -Dwildfly.password=Admin#007
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building couchbase-javaee 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ couchbase-javaee ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ couchbase-javaee ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ couchbase-javaee ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/arungupta/workspaces/couchbase-javaee/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ couchbase-javaee ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ couchbase-javaee ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ couchbase-javaee ---
[INFO] Packaging webapp
[INFO] Assembling webapp [couchbase-javaee] in [/Users/arungupta/workspaces/couchbase-javaee/target/couchbase-javaee]
[INFO] Processing war project
[INFO] Copying webapp resources [/Users/arungupta/workspaces/couchbase-javaee/src/main/webapp]
[INFO] Webapp assembled in [62 msecs]
[INFO] Building war: /Users/arungupta/workspaces/couchbase-javaee/target/couchbase-javaee.war
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ couchbase-javaee ---
[INFO] Installing /Users/arungupta/workspaces/couchbase-javaee/target/couchbase-javaee.war to /Users/arungupta/.m2/repository/org/couchbase/sample/couchbase-javaee/1.0-SNAPSHOT/couchbase-javaee-1.0-SNAPSHOT.war
[INFO] Installing /Users/arungupta/workspaces/couchbase-javaee/pom.xml to /Users/arungupta/.m2/repository/org/couchbase/sample/couchbase-javaee/1.0-SNAPSHOT/couchbase-javaee-1.0-SNAPSHOT.pom
[INFO]
[INFO] >>> wildfly-maven-plugin:1.1.0.Alpha4:deploy (default) > package @ couchbase-javaee >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ couchbase-javaee ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ couchbase-javaee ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ couchbase-javaee ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/arungupta/workspaces/couchbase-javaee/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ couchbase-javaee ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ couchbase-javaee ---
[INFO] No tests to run.
[INFO] Skipping execution of surefire because it has already been run for this configuration
[INFO]
[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ couchbase-javaee ---
[INFO] Packaging webapp
[INFO] Assembling webapp [couchbase-javaee] in [/Users/arungupta/workspaces/couchbase-javaee/target/couchbase-javaee]
[INFO] Processing war project
[INFO] Copying webapp resources [/Users/arungupta/workspaces/couchbase-javaee/src/main/webapp]
[INFO] Webapp assembled in [18 msecs]
[INFO] Building war: /Users/arungupta/workspaces/couchbase-javaee/target/couchbase-javaee.war
[INFO]
[INFO] <<< wildfly-maven-plugin:1.1.0.Alpha4:deploy (default) < package @ couchbase-javaee <<<
[INFO]
[INFO] --- wildfly-maven-plugin:1.1.0.Alpha4:deploy (default) @ couchbase-javaee ---
Jul 15, 2016 10:33:23 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.1.Final
Jul 15, 2016 10:33:23 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.1.Final
Jul 15, 2016 10:33:23 PM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 4.0.9.Final
[INFO] Authenticating against security realm: ManagementRealm
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.478 s
[INFO] Finished at: 2016-07-15T22:33:28-07:00
[INFO] Final Memory: 20M/370M
[INFO] ------------------------------------------------------------------------
curl -v http://localhost:8080/couchbase-javaee/resources/airline
* Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> GET /couchbase-javaee/resources/airline HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Connection: keep-alive
< X-Powered-By: Undertow/1
< Server: WildFly/8
< Content-Type: application/octet-stream
< Content-Length: 1402
< Date: Sat, 16 Jul 2016 05:34:56 GMT
<
* Connection #0 to host localhost left intact
[{"travel-sample":{"id":10,"iata":"Q5","icao":"MLA","name":"40-Mile Air","callsign":"MILE-AIR","type":"airline","country":"United States"}}, {"travel-sample":{"id":10123,"iata":"TQ","icao":"TXW","name":"Texas Wings","callsign":"TXW","type":"airline","country":"United States"}}, {"travel-sample":{"id":10226,"iata":"A1","icao":"A1F","name":"Atifly","callsign":"atifly","type":"airline","country":"United States"}}, {"travel-sample":{"id":10642,"iata":null,"icao":"JRB","name":"Jc royal.britannica","callsign":null,"type":"airline","country":"United Kingdom"}}, {"travel-sample":{"id":10748,"iata":"ZQ","icao":"LOC","name":"Locair","callsign":"LOCAIR","type":"airline","country":"United States"}}, {"travel-sample":{"id":10765,"iata":"K5","icao":"SQH","name":"SeaPort Airlines","callsign":"SASQUATCH","type":"airline","country":"United States"}}, {"travel-sample":{"id":109,"iata":"KO","icao":"AER","name":"Alaska Central Express","callsign":"ACE AIR","type":"airline","country":"United States"}}, {"travel-sample":{"id":112,"iata":"5W","icao":"AEU","name":"Astraeus","callsign":"FLYSTAR","type":"airline","country":"United Kingdom"}}, {"travel-sample":{"id":1191,"iata":"UU","icao":"REU","name":"Air Austral","callsign":"REUNION","type":"airline","country":"France"}}, {"travel-sample":{"id":1203,"iata":"A5","icao":"RLA","name":"Airlinair","callsign":"AIRLINAIR","type":"airline","country":"France"}}]
curl -v http://localhost:8080/couchbase-javaee/resources/airline/137
curl -v http://localhost:8080/couchbase-javaee/resources/airline/137
* Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> GET /couchbase-javaee/resources/airline/137 HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Connection: keep-alive
< X-Powered-By: Undertow/1
< Server: WildFly/8
< Content-Type: application/octet-stream
< Content-Length: 131
< Date: Sat, 16 Jul 2016 05:35:57 GMT
<
* Connection #0 to host localhost left intact
{"travel-sample":{"id":137,"iata":"AF","icao":"AFR","name":"Air France","callsign":"AIRFRANS","type":"airline","country":"France"}}
curl -v -H "Content-Type: application/json" -X POST -d '{"country":"France","iata":"A5","callsign":"AIRLINAIR","name":"Airlinair","icao":"RLA","type":"airline"}' http://localhost:8080/couchbase-javaee/resources/airline
* Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> POST /couchbase-javaee/resources/airline HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 104
>
* upload completely sent off: 104 out of 104 bytes
< HTTP/1.1 200 OK
< Connection: keep-alive
< X-Powered-By: Undertow/1
< Server: WildFly/8
< Content-Type: application/octet-stream
< Content-Length: 117
< Date: Sat, 16 Jul 2016 05:36:42 GMT
<
* Connection #0 to host localhost left intact
{"id":"19810","iata":"A5","icao":"RLA","name":"Airlinair","callsign":"AIRLINAIR","type":"airline","country":"France"}
curl -v -H "Content-Type: application/json" -X PUT -d '{"country":"France","iata":"A5","callsign":"AIRLINAIR","name":"Airlin Air","icao":"RLA","type":"airline","id": "19810"}' http://localhost:8080/couchbase-javaee/resources/airline/19810
* Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> PUT /couchbase-javaee/resources/airline/19810 HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 119
>
* upload completely sent off: 119 out of 119 bytes
< HTTP/1.1 200 OK
< Connection: keep-alive
< X-Powered-By: Undertow/1
< Server: WildFly/8
< Content-Type: application/octet-stream
< Content-Length: 118
< Date: Sat, 16 Jul 2016 05:37:29 GMT
<
* Connection #0 to host localhost left intact
{"id":"19810","iata":"A5","icao":"RLA","name":"Airlin Air","callsign":"AIRLINAIR","type":"airline","country":"France"}
curl -v -X DELETE http://localhost:8080/couchbase-javaee/resources/airline/19810
* Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> DELETE /couchbase-javaee/resources/airline/19810 HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Connection: keep-alive
< X-Powered-By: Undertow/1
< Server: WildFly/8
< Content-Type: application/octet-stream
< Content-Length: 136
< Date: Sat, 16 Jul 2016 05:38:14 GMT
<
* Connection #0 to host localhost left intact
{"travel-sample":{"id":"19810","iata":"A5","icao":"RLA","name":"Airlin Air","callsign":"AIRLINAIR","type":"airline","country":"France"}}