Dubbo & Zookeeper & SPRINGMVC

Source: Internet
Author: User
Tags zookeeper

I. Installation Preparation 1. Introduction to the Environment
name version
OS Mac OS X 10.11.5
Jdk 1.8.0_51
Dubbo 2.5.4
Tomcat 8.0.35
Zookeeper 3.4.8
Maven 3.3.9
2. Episode

To download with wget, you find that the MAC is not installed by default. Accustomed to other Linux environments, use an automated installation tool to install wget. After that, we found the homebrew. The following first installs the homebrew, this centos-like Yum and Ubuntu Apt-get, the installation method is very simple, the following can be done:
Ruby-e "$ (curl-fssl https://raw.githubusercontent.com/Homebrew/install/master/install)"
After performing the above and installing successfully, let's test the installation wget below:
The Brew install wget is perfect and ready for installation.

3. Compiling the Dubbo sample

According to the official website tutorial:
Http://dubbo.io/Administrator+Guide-zh.htm#AdministratorGuide-zh-%E7%A4%BA%E4%BE%8B%E6%8F%90%E4%BE%9B%E8%80%85 %e5%ae%89%e8%a3%85

found that the direct download assembly address is invalid, to other addresses. Find the demo code on GitHub and fork it into your account and clone it locally. This is managed with Maven, so also prepare MAVEN environment, the construction of MAVEN environment is omitted here.
CD Dubbo
MVN install-dmaven.test.skip=true
Once the compilation is complete, go to the demo directory to find a place to make the components. The compressed package name is:
Directory Dubbo/dubbo-demo/dubbo-demo-provider/target below:
Dubbo-demo-provider-2.5.4-snapshot-assembly.tar.gz

Directory Dubbo/dubbo-demo/dubbo-demo-consumer/target below:
Dubbo-demo-consumer-2.5.4-snapshot-assembly.tar.gz

Directory Dubbo/dubbo-simple/dubbo-monitor-simple/target below:
Dubbo-monitor-simple-2.5.4-snapshot-assembly.tar.gz

Directory Dubbo/dubbo-admin/target below:
Dubbo-admin-2.5.4-snapshot.war

Two. Zookeeper Registration Center Installation

There are a number of options for the registry, and I choose Zookeeper as the registration center.
wget http://apache.fayea.com/zookeeper/zookeeper-3.4.8/zookeeper-3.4.8.tar.gz
TAR-ZXVF zookeeper-3.4.8.tar.gz
CD zookeeper-3.4.8
CP Conf/zoo_sample.cfg Conf/zoo.cfg

Do not configure the cluster to start directly
./bin/zkserver.sh Start

Three. Installing Dubbo Example 1. Example Provider installation

TAR-ZXVF dubbo-demo-provider-2.5.4-snapshot-assembly.tar.gz
CD Dubbo-demo-provider-2.5.4-snapshot

Configuration
VI conf/dubbo.properties
Place them
dubbo.registry.address=zookeeper://127.0.0.1:2181
Remove comments, comment multicast that

Start
./bin/start.sh
Connect to Provider
Telnet 127.0.0.1 20880
Enter Help to view the actions provided

2. Sample Consumer Installation

TAR-ZXVF dubbo-demo-consumer-2.5.4-snapshot-assembly.tar.gz
CD Dubbo-demo-consumer-2.5.4-snapshot

Configuration
VI conf/dubbo.properties
Place them
dubbo.registry.address=zookeeper://127.0.0.1:2181
Remove comments, comment multicast that

./bin/start.sh

3. Monitoring Center Installation

TAR-ZXVF dubbo-monitor-simple-2.5.4-snapshot-assembly.tar.gz
CD Dubbo-monitor-simple-2.5.4-snapshot Configuration
VI conf/dubbo.properties
Place them
dubbo.registry.address=zookeeper://127.0.0.1:2181
Remove comments, comment multicast that

./bin/start.sh

http://127.0.0.1:8080

4. Management Console Installation

Copy the compiled Dubbo-admin-2.5.4-snapshot.war to Tomcat. Configure the Server.xml to avoid conflicts with the ports in the front monitoring center. Start Tomcat.
Error found:
The Bean property ' Uritype ' was not writable or had an invalid setter method.

Specific errors and solution references here:
https://github.com/alibaba/dubbo/issues/50
Follow the 4 steps below and the error disappears.

1, the dependence of WEBX changed to 3.1.6 version;

<dependency>    <groupId>com.alibaba.citrus</groupId>    <artifactId>citrus-webx-all</artifactId>    <version>3.1.6</version></dependency>   

2, add the velocity of dependence, I used 1.7;

<dependency>    <groupId>org.apache.velocity</groupId>    <artifactId>velocity</artifactId>    <version>1.7</version></dependency>   

3. Add exclusion to dependency Dubbo to avoid introducing old spring

<dependency>    <groupId>com.alibaba</groupId>    <artifactId>dubbo</artifactId>    <version>${project.parent.version}</version>    <exclusions>        <exclusion>            <groupId>org.springframework</groupId>            <artifactId>spring</artifactId>        </exclusion>    </exclusions></dependency>   

4, WEBX has more than 3 of spring dependency, so comment out the spring dubbo-admin inside

<!--<dependency>-->    <!--<groupId>org.springframework</groupId>-->    <!--<artifactId>spring</artifactId>--><!--</dependency>-->   

Make sure that the Lib directory does not have dependencies below Spring 3 after the war package is decompressed. And then it runs fine.

No additional configuration is required here, and the default is zookeeper configuration in Dubbo.properties.

My access address is:
http://127.0.0.1:8888

Four. Joining service providers and consumers via SPRINGMVC

The integration of Dubbo and Springmvc, I refer to this paragraph:
Http://dubbo.io/User+Guide-zh.htm#UserGuide-zh-%E6%B3%A8%E8%A7%A3%E9%85%8D%E7%BD%AE

New two projects:

Dubbo Application
Test-consumer
Test-provider

On the two sheets added to the management console, the following consumer why there are three do not understand, need to continue to study:

Two questions were encountered during the construction process:

Problem one: The dubbo.xsd file cannot be found

After downloading the dubbo.xsd to local, join by following these steps, I am using eclipse:
Windows->preferrence->xml->xmlcatalog
Add->catalog Entry->file System Select the file path you just downloaded
Modifying the key value is the same as the http://code.alibabatech.com/schema/dubbo/dubbo.xsd of the configuration file

The solution of the problem comes from here, thanks to the author ~
http://blog.csdn.net/lxb15959168136/article/details/50225057

Issue two: In the process of Dubbo startup error reported: Java.lang.ClassNotFoundException:javassist. ClassPath

My approach:
Since I am building with maven, I add the following directly to the project Pom.xml:

 <Dependency><GroupId>org. Javassist</groupid>< Artifactid>javassist</artifactId ><version>3.18 2-ga</version ><scope>runtime </scope> </dependency< Span class= "O" >>               
The last is the code of the service provider and the consumer who wrote

Https://github.com/mingbozhang/leandubbo

Dubbo & Zookeeper & SPRINGMVC

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.