Building your Service Fabric Environment on your Mac with Eclipse

I create a development environment for Service Fabric (Java) with my Mac and Eclipse. However, I notice a lot of pit holes on the get started page.
I'll send pull request for this. Before it is accepted, I'd like to share how to create your development environment on your Mac.

[caption id="attachment_1225" align="alignnone" width="1024"]Service Fabric UI Service Fabric UI[/caption]

Create a Service Fabric Local Cluster for Java.

I try to the following instruction. You can see my reference development environment on my GitHub.

Set up your development environment on Mac OS X

after the

 vagrant up

I've got an error.

 DEBUG ssh: == Net-SSH connection debug-level log END ==

 INFO ssh: SSH not ready: #<Vagrant::Errors::NetSSHException: An error occurred in the underlying SSH library that Vagrant uses.

The error message is shown below. In many cases, errors from this

library are caused by ssh-agent issues. Try disabling your SSH

agent or removing some keys and try again.

 

If the problem persists, please report a bug to the net-ssh project.

I could't ssh the VM.  This is known issue.

Failing "underlying SSH library" #509

It might be my environment specific problem. However, I'd like to share my solution.

I add a vagrant plugin.

 vagrant plugin install vagrant-vbguest

Then I edit the Vagrantfile.

like this.

     :
config.vm.provider "virtualbox" do |vb|
vb.memory = "3072"
vb.customize ['modifyvm', :id, '--cableconnected1', 'on']
end
     :

Then I can create a Cluster VM by vagrant.

Download Service Fabric SDK

Sorry! You don't need this step. Vagrant File does this. If you find the error, you need to place Vagrant file on your eclipse workspace directory and execute "vagrant up".

If you try Eclipse setup and build your project, you'll get an error like this.

 /Users/ushio/Codes/sflinux/workspace/StatelessApp/StatelessApp/src/statelessservice/StatelessAppService.java:8: error: package microsoft.servicefabric.services.communication.runtime does not exist

import microsoft.servicefabric.services.communication.runtime.ServiceInstanceListener;

                                                             ^

/Users/ushio/Codes/sflinux/workspace/StatelessApp/StatelessApp/src/statelessservice/StatelessAppService.java:9: error: package microsoft.servicefabric.services.runtime does not exist

import microsoft.servicefabric.services.runtime.StatelessService;

The reason is, lack of the service fabric SDK library. However, if you are using Mac, you can't get the SDK library.  Service Fabric SDK is only for Windows and Linux.
But you can get it from the Local Service Fabric Cluster VM which you created by vagrant. You can get these like this.

 $ vagrant ssh-config > ssh.config

$ scp -F ./ssh.config vagrant@default:/opt/microsoft/sdk/servicefabric/java/packages/lib/* .

You'll get jar files and a so library.  Please store it on your {eclipse workspace}/tmp/lib

Directory Structure of Eclipse

You need to follow the directory structure. This is my Eclipse directory structure. In this example, I create Stateless service called SfTest.

You can see the whole file in my GitHub.

 .

├── RemoteSystemsTempFiles

├── SfTest

│   ├── PublishProfiles

│   │   ├── Cloud.json

│   │   └── Local.json

│   ├── Scripts

│   │   ├── VagrantSSHCaller.sh

│   │   ├── connect.sh

│   │   ├── deploy.sh

│   │   ├── install.sh

│   │   ├── uninstall.sh

│   │   └── upgrade.sh

│   ├── SfTest

│   │   ├── build

│   │   │   └── tmp

│   │   │       └── jar

│   │   │           └── MANIFEST.MF

│   │   ├── build.gradle

│   │   ├── out

│   │   │   └── classes

│   │   │       └── statelessservice

│   │   │           ├── SfTestService.class

│   │   │           └── SfTestServiceHost.class

│   │   └── src

│   │       └── statelessservice

│   │           ├── SfTestService.java

│   │           └── SfTestServiceHost.java

│   ├── SfTestApplication

│   │   ├── ApplicationManifest.xml

│   │   └── SfTestPkg

│   │       ├── Code

│   │       │   ├── SfTest.jar

│   │       │   ├── entryPoint.sh

│   │       │   └── lib

│   │       │       ├── asm-5.0.4.jar

│   │       │       ├── asm-analysis-5.0.4.jar

│   │       │       ├── asm-commons-5.0.4.jar

│   │       │       ├── asm-tree-5.0.4.jar

│   │       │       ├── asm-util-5.0.4.jar

│   │       │       ├── asm-xml-5.0.4.jar

│   │       │       ├── libjFabricRuntime.so

│   │       │       ├── microsoft.servicefabric.actors-preview.jar

│   │       │       ├── microsoft.servicefabric.services-preview.jar

│   │       │       └── system.fabric-preview.jar

│   │       ├── Config

│   │       │   └── Settings.xml

│   │       ├── Data

│   │       │   └── _readme.txt

│   │       └── ServiceManifest.xml

│   ├── SfTestTestClient

│   │   └── VagrantSSHCallerForTestClient.sh

│   ├── build

│   │   ├── libs

│   │   │   └── SfTest.jar

│   │   └── tmp

│   │       └── jar

│   │           └── MANIFEST.MF

│   ├── build.gradle

│   ├── gradle

│   │   └── wrapper

│   │       ├── gradle-wrapper.jar

│   │       └── gradle-wrapper.properties

│   ├── gradlew

│   ├── gradlew.bat

│   └── settings.gradle

├── Vagrantfile

└── tmp

    └── lib

        ├── asm-5.0.4.jar

        ├── asm-analysis-5.0.4.jar

        ├── asm-commons-5.0.4.jar

        ├── asm-tree-5.0.4.jar

        ├── asm-util-5.0.4.jar

        ├── asm-xml-5.0.4.jar

        ├── libjFabricRuntime.so

        ├── microsoft.servicefabric.actors-preview.jar

        ├── microsoft.servicefabric.services-preview.jar

        └── system.fabric-preview.jar

 

The point is

  1. Vagrantfile is on the workspace directory of eclipse.
  2. Service Fabric SDK should be placed on workspace directory/tmp/lib

Vagrantfile is on the workspace directory of eclipse

On this Vagrantfile mounts the root directory. which means this project it's self. the deployment script expect the root directory is the same as eclipse workspace.
You need to execute "vagrant up" on the workspace directory.

Service Fabric SDK should be placed on workspace root directory/tmp/lib

The gradle file expects the SDK is workspace root directory/temp/lib

Edit Local.json file

 ├── SfTest

│   ├── PublishProfiles

│   │   ├── Cloud.json

│   │   └── Local.json <--

like this

 {
 "ClusterConnectParameters": 
 {
 "ConnectionIPOrURL": "192.168.50.50",
 "ConnectionPort": "19080",
 "ClientKey": "",
 "ClientCert": ""
 }
}

Now you can build and deploy your local cluster! Enjoy coding.

[caption id="attachment_1235" align="alignnone" width="1024"]Eclipse with ServiceFabric Plugin Eclipse with ServiceFabric Plugin[/caption]