DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Navigating NoSQL: A Pragmatic Approach for Java Developers
  • Java EE 6 Pet Catalog with GlassFish and MySQL
  • Architecture and Code Design, Pt. 2: Polyglot Persistence Insights To Use Today and in the Upcoming Years
  • Architecture and Code Design, Pt. 1: Relational Persistence Insights to Use Today and On the Upcoming Years

Trending

  • DZone's Article Submission Guidelines
  • Docker Base Images Demystified: A Practical Guide
  • How Large Tech Companies Architect Resilient Systems for Millions of Users
  • Medallion Architecture: Why You Need It and How To Implement It With ClickHouse
  1. DZone
  2. Data Engineering
  3. Databases
  4. JBoss EAP 7 and NoSQL Using Java EE and Docker

JBoss EAP 7 and NoSQL Using Java EE and Docker

Developers can write applications to Couchbase using many different languages and multiple SDKs. This post explains how to deploy and access a NoSQL database from JBoss EAP 7.

By 
Arun Gupta user avatar
Arun Gupta
·
Dec. 28, 15 · Tutorial
Likes (5)
Comment
Save
Tweet
Share
10.4K Views

Join the DZone community and get the full member experience.

Join For Free

JBoss EAP 7 Beta is now released, many congratulations to Red Hat and particularly to the WildFly team!

There are plenty of improvements coming in this release as documented in Release Notes. One of the major themes is Java EE 7 compliance.

JBoss EAP 7 and Java EE 7

IBM and Oracle already provide commercially-supported Java EE 7-compliant Application Servers. And now Red Hat will be joining this party soon as well. Already WildFly has supported Java EE 7 for over two years, but commercial support is critical for open source to be adopted enterprise-wide. So this is good news!

You can learn all about different Java EE 7 APIs in the DZone Refcardz that I authored along with @alrubinger.

Java EE 7 Refcardz

There are plenty of “hello world” Java EE 7 Samples that should all run with JBoss EAP. Hopefully, somebody will update the pom.xml and add a new profile.

Why NoSQL?

If you are building a traditional enterprise application then you might be fine using an RDBMS. There are plenty of advantages to using RDBMS, but using a NoSQL database instead has a few advantages:

  • There is no need to have a pre-defined schema and that makes them a schema-less database. The addition of new properties to existing objects is easy and does not require ALTER TABLE. The unstructured data gives flexibility to change the format of data any time without downtime or reduced service levels. Also there are no joins happening on the server because there is no structure and thus no relation between them.
  • Scalability, agility, and performance are more important than the entire set of functionality typically provided by an RDBMS. This set of databases provide eventual consistency and/or transactions restricted to single items, but more focus on CRUD.
  • NoSQL is designed to scale-out (horizontal) instead of scale-up (vertical). This is important knowing that databases, and everything else as well, is moving into the cloud. RDBMS can scale-out using sharding but requires complex management, not for the faint of heart. Queries requiring JOINs across shards is extremely inefficient.
  • RDBMS have impedance mismatch between the database structure and the domain classes. An Object Relational Mapping, such as one provided by Java Persistence API or Hibernate, is needed in such a case.
  • NoSQL databases are designed for less management and simpler data models lead to lower administration cost as well.

So, now you are all excited about NoSQL and want to learn more, right? Check out these links:

  • Why NoSQL?
  • Why do successful enterprises rely on NoSQL?
  • Top 10 Enterprise NoSQL Usecases

In short, there are four different types of NoSQL databases:

  • Document: Couchbase, Mongo, and others
  • Key/Value: Couchbase, Redis, and others
  • Graph: Neo4J, OrientDB, and others
  • Column: Cassandra and others

Java EE 7 provides a Java Persistence API that does not provide any support for NoSQL. So, how do you get started with NoSQL with JBoss EAP 7?

This blog will show how to query a Couchbase database using simple Java EE application deployed on JBoss EAP 7 Beta.

What is Couchbase?

Couchbase is an open-source, NoSQL, document database. It allows us to access, index, and query JSON documents while taking advantage of integrated distributed caching for high performance data access.

Developers can write applications to Couchbase using many different languages (Java, Go, .NET, Node, PHP, Python, C) and multiple SDKs. This blog will show how you can easily create a CRUD application using Java SDK for Couchbase.

Run JBoss EAP 7

There are two ways to start JBoss EAP 7.

Download and Run

./jboss-eap-7.0/bin/standalone.sh 
=========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /Users/arungupta/tools/jboss-eap-7.0

  JAVA: java

  JAVA_OPTS:  -server -verbose:gc -Xloggc:"/Users/arungupta/tools/jboss-eap-7.0/standalone/log/gc.log" -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=3M -XX:-TraceClassUnloading -Xms1303m -Xmx1303m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true

=========================================================================

21:22:58,773 INFO  [org.jboss.modules] (main) JBoss Modules version 1.4.4.Final-redhat-1

. . .

21:23:21,441 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
21:23:21,442 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
21:23:21,442 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: EAP 7.0.0.Beta1 (WildFly Core 2.0.3.Final-redhat-1) started in 22950ms - Started 261 of 509 services (332 services are lazy, passive or on-demand)

Docker Run

In a containerized world, you just docker run to run your JBoss EAP. However, JBoss EAP image does not exist on Docker Hub and so the image needs to be explicitly built. You still need to explicitly download JBoss EAP and then use the following Dockerfile to build the image:

# Use latest jboss/base-jdk:8 image as the base
FROM jboss/base-jdk:8

# Set the JBOSS_VERSION env variable
ENV JBOSS_VERSION 7.0.0.Beta
ENV JBOSS_HOME /opt/jboss/jboss-eap-7.0/

COPY jboss-eap-$JBOSS_VERSION.zip $HOME

# Add the JBoss distribution to /opt, and make jboss the owner of the extracted zip content
# Make sure the distribution is available from a well-known place
RUN cd $HOME \
    && unzip jboss-eap-$JBOSS_VERSION.zip \
    && rm jboss-eap-$JBOSS_VERSION.zip

# Ensure signals are forwarded to the JVM process correctly for graceful shutdown
ENV LAUNCH_JBOSS_IN_BACKGROUND true

# Expose the ports we're interested in
EXPOSE 8080 9990

# Set the default command to run on boot
# This will boot JBoss EAP in the standalone mode and bind to all interface
CMD ["/opt/jboss/jboss-eap-7.0/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]

The image is built as:

docker build -t arungupta/jboss-eap:7-beta .

And then you can run the JBoss EAP 7 container as:

docker run -it -p 8080:8080 arungupta/jboss-eap:7-beta
=========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /opt/jboss/jboss-eap-7.0/

  JAVA: /usr/lib/jvm/java/bin/java

  JAVA_OPTS:  -server -verbose:gc -Xloggc:"/opt/jboss/jboss-eap-7.0//standalone/log/gc.log" -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=3M -XX:-TraceClassUnloading -Xms1303m -Xmx1303m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true

=========================================================================

20:51:12,551 INFO  [org.jboss.modules] (main) JBoss Modules version 1.4.4.Final-redhat-1
20:51:12,824 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final-redhat-1

. . .

20:51:16,750 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://0.0.0.0:9990/management
20:51:16,758 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://0.0.0.0:9990
20:51:16,759 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: EAP 7.0.0.Beta1 (WildFly Core 2.0.3.Final-redhat-1) started in 4529ms - Started 261 of 509 services (332 services are lazy, passive or on-demand)

Notice how application and management ports are bound to all network interfaces. This will simplify to deploy the application to this JBoss EAP instance later.

Stop the server—we will show an easier way to start it later.

Start Application Server and Database

The Java EE application will provide an HTTP CRUD interface over JSON documents stored in Couchbase. The application itself will be deployed on JBoss EAP 7 Beta. So, it would require to start Couchbase and JBoss EAP.

Use the Docker Compose file from github.com/arun-gupta/docker-images/blob/master/jboss-eap7-nosql/docker-compose.yml to start Couchbase and JBoss EAP 7 container:

mycouchbase:
  container_name: "db"
  image: couchbase/server
  ports:
    - 8091:8091
    - 8092:8092 
    - 8093:8093 
    - 11210:11210
jboss:
  image: arungupta/jboss-eap:7-beta
  environment:
    - COUCHBASE_URI=db
  ports:
    - 8080:8080
    - 9990:9990

The application is started as:

docker-compose --x-networking up -d
Creating network "jbosseap7nosql" with driver "None"
Starting jbosseap7nosql_jboss_1
Creating db

The started containers can be seen as:

docker ps
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                                                                                               NAMES
154436dfbfb1        couchbase/server             "/entrypoint.sh couch"   10 seconds ago      Up 8 seconds        0.0.0.0:8091-8093->8091-8093/tcp, 11207/tcp, 11211/tcp, 18091-18092/tcp, 0.0.0.0:11210->11210/tcp   db
cb76d4e38df3        arungupta/jboss-eap:7-beta   "/opt/jboss/jboss-eap"   10 seconds ago      Up 9 seconds        0.0.0.0:8080->8080/tcp, 0.0.0.0:9990->9990/tcp                                                      jbosseap7nosql_jboss_1

Configure Couchbase Server

Clone couchbase-javaee application. This Java EE application uses Couchbase Java SDK APIs to connect to the Couchbase server. The bootstrap code is:

CouchbaseCluster.create(System.getenv("COUCHBASE_URI"));

and is invoked from Database abstraction.

Couchbase Server can be configured using REST API. These REST APIs are defined in a Maven profile in pom.xml of this application. And so, they configure the Couchbase server as:

mvn install -Pcouchbase -Ddocker.host=$(docker-machine ip couchbase)
[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] 
[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 [82 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 ---
* Hostname was NOT found in DNS cache
*   Trying 192.168.99.102...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Connected to 192.168.99.102 (192.168.99.102) port 8091 (#0)
> POST /pools/default HTTP/1.1
> User-Agent: curl/7.37.1
> Host: 192.168.99.102:8091
> Accept: */*
> Content-Length: 36
> Content-Type: application/x-www-form-urlencoded
> 
} [data not shown]
* upload completely sent off: 36 out of 36 bytes
< HTTP/1.1 200 OK
* Server Couchbase Server is not blacklisted
< Server: Couchbase Server
< Pragma: no-cache
< Date: Mon, 21 Dec 2015 21:35:10 GMT
< Content-Length: 0
< Cache-Control: no-cache
< 
100    36    0     0  100    36      0  15510 --:--:-- --:--:-- --:--:-- 18000
* Connection #0 to host 192.168.99.102 left intact
[INFO] 
[INFO] --- exec-maven-plugin:1.4.0:exec (Configure services) @ couchbase-javaee ---
* Hostname was NOT found in DNS cache
*   Trying 192.168.99.102...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Connected to 192.168.99.102 (192.168.99.102) port 8091 (#0)
> POST /node/controller/setupServices HTTP/1.1
> User-Agent: curl/7.37.1
> Host: 192.168.99.102:8091
> Accept: */*
> Content-Length: 26
> Content-Type: application/x-www-form-urlencoded
> 
} [data not shown]
* upload completely sent off: 26 out of 26 bytes
< HTTP/1.1 200 OK
* Server Couchbase Server is not blacklisted
< Server: Couchbase Server
< Pragma: no-cache
< Date: Mon, 21 Dec 2015 21:35:10 GMT
< Content-Length: 0
< Cache-Control: no-cache
< 
100    26    0     0  100    26      0   9976 --:--:-- --:--:-- --:--:-- 13000
* Connection #0 to host 192.168.99.102 left intact
[INFO] 
[INFO] --- exec-maven-plugin:1.4.0:exec (Setup credentials) @ couchbase-javaee ---
* Hostname was NOT found in DNS cache
*   Trying 192.168.99.102...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Connected to 192.168.99.102 (192.168.99.102) port 8091 (#0)
> POST /settings/web HTTP/1.1
> User-Agent: curl/7.37.1
> Host: 192.168.99.102:8091
> Accept: */*
> Content-Length: 50
> Content-Type: application/x-www-form-urlencoded
> 
} [data not shown]
* upload completely sent off: 50 out of 50 bytes
< HTTP/1.1 200 OK
* Server Couchbase Server is not blacklisted
< Server: Couchbase Server
< Pragma: no-cache
< Date: Mon, 21 Dec 2015 21:35:10 GMT
< Content-Type: application/json
< Content-Length: 44
< Cache-Control: no-cache
< 
{ [data not shown]
100    94  100    44  100    50   6880   7818 --:--:-- --:--:-- --:--:--  8333
* Connection #0 to host 192.168.99.102 left intact
{"newBaseUri":"http://192.168.99.102:8091/"}[INFO] 
[INFO] --- exec-maven-plugin:1.4.0:exec (Install travel-sample bucket) @ couchbase-javaee ---
* Hostname was NOT found in DNS cache
*   Trying 192.168.99.102...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Connected to 192.168.99.102 (192.168.99.102) port 8091 (#0)
* Server auth using Basic with user 'Administrator'
> POST /sampleBuckets/install HTTP/1.1
> Authorization: Basic QWRtaW5pc3RyYXRvcjpwYXNzd29yZA==
> User-Agent: curl/7.37.1
> Host: 192.168.99.102:8091
> Accept: */*
> Content-Length: 17
> Content-Type: application/x-www-form-urlencoded
> 
} [data not shown]
* upload completely sent off: 17 out of 17 bytes
< HTTP/1.1 202 Accepted
* Server Couchbase Server is not blacklisted
< Server: Couchbase Server
< Pragma: no-cache
< Date: Mon, 21 Dec 2015 21:35:11 GMT
< Content-Type: application/json
< Content-Length: 2
< Cache-Control: no-cache
< 
{ [data not shown]
100    19  100     2  100    17     41    355 --:--:-- --:--:-- --:--:--   361
* Connection #0 to host 192.168.99.102 left intact
[][INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.094 s
[INFO] Finished at: 2015-12-21T13:35:11-08:00
[INFO] Final Memory: 13M/309M
[INFO] ------------------------------------------------------------------------

Deploy Java EE Application to JBoss

Java EE Application can easily be deployed to JBoss EAP 7 Beta using the WildFly Maven Plugin. This is also defined as a Maven profile in pom.xml as well.

Deploy the application as:

mvn install -Pwildfly -Dwildfly.hostname=$(docker-machine ip couchbase) -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] 
[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] 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 [20 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 ---
Dec 21, 2015 1:43:34 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.1.Final
Dec 21, 2015 1:43:34 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.1.Final
Dec 21, 2015 1:43:34 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: 17.010 s
[INFO] Finished at: 2015-12-21T13:43:48-08:00
[INFO] Final Memory: 17M/217M
[INFO] ------------------------------------------------------------------------

Access the Application

As mentioned earlier, the application provides HTTP CRUD API over JSON documents stored in Couchbase.

Access the application as:

curl -v http://$(docker-machine ip couchbase):8080/couchbase-javaee/resources/airline
* Hostname was NOT found in DNS cache
*   Trying 192.168.99.102...
* Connected to 192.168.99.102 (192.168.99.102) port 8080 (#0)
> GET /couchbase-javaee/resources/airline HTTP/1.1
> User-Agent: curl/7.37.1
> Host: 192.168.99.102:8080
> Accept: */*
> 
< HTTP/1.1 200 OK
< Connection: keep-alive
< X-Powered-By: Undertow/1
* Server JBoss-EAP/7 is not blacklisted
< Server: JBoss-EAP/7
< Content-Type: application/octet-stream
< Content-Length: 1402
< Date: Mon, 21 Dec 2015 21:45:40 GMT
< 
* Connection #0 to host 192.168.99.102 left intact
[{"travel-sample":{"country":"United States","iata":"Q5","callsign":"MILE-AIR","name":"40-Mile Air","icao":"MLA","id":10,"type":"airline"}}, {"travel-sample":{"country":"United States","iata":"TQ","callsign":"TXW","name":"Texas Wings","icao":"TXW","id":10123,"type":"airline"}}, {"travel-sample":{"country":"United States","iata":"A1","callsign":"atifly","name":"Atifly","icao":"A1F","id":10226,"type":"airline"}}, {"travel-sample":{"country":"United Kingdom","iata":null,"callsign":null,"name":"Jc royal.britannica","icao":"JRB","id":10642,"type":"airline"}}, {"travel-sample":{"country":"United States","iata":"ZQ","callsign":"LOCAIR","name":"Locair","icao":"LOC","id":10748,"type":"airline"}}, {"travel-sample":{"country":"United States","iata":"K5","callsign":"SASQUATCH","name":"SeaPort Airlines","icao":"SQH","id":10765,"type":"airline"}}, {"travel-sample":{"country":"United States","iata":"KO","callsign":"ACE AIR","name":"Alaska Central Express","icao":"AER","id":109,"type":"airline"}}, {"travel-sample":{"country":"United Kingdom","iata":"5W","callsign":"FLYSTAR","name":"Astraeus","icao":"AEU","id":112,"type":"airline"}}, {"travel-sample":{"country":"France","iata":"UU","callsign":"REUNION","name":"Air Austral","icao":"REU","id":1191,"type":"airline"}}, {"travel-sample":{"country":"France","iata":"A5","callsign":"AIRLINAIR","name":"Airlinair","icao":"RLA","id":1203,"type":"airline"}}]

CRUD operations (GET, POST, PUT, DELETE) can be performed on Airline resource in the application. Complete CRUD API is documented at github.com/arun-gupta/couchbase-javaee.

This blog explained how to access a NoSQL database from JBoss EAP 7.

Read more about Couchbase 4:

  • What’s New in Couchbase Server 4.1
  • Couchbase Server documentation
  • Talk to us on Couchbase Forums
  • Follow @couchbasedev or @couchbase

Learn more about Couchbase in this recent developer-focused webinar:


Enterprise architecture planning Java EE Database JBoss Java (programming language) NoSQL Docker (software) Relational database application

Published at DZone with permission of Arun Gupta, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Navigating NoSQL: A Pragmatic Approach for Java Developers
  • Java EE 6 Pet Catalog with GlassFish and MySQL
  • Architecture and Code Design, Pt. 2: Polyglot Persistence Insights To Use Today and in the Upcoming Years
  • Architecture and Code Design, Pt. 1: Relational Persistence Insights to Use Today and On the Upcoming Years

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: