Satheesh Satheesh - 1 year ago 236
Java Question

Java Webapp Deployment in Azure Service fabric explorer

We have a stateless Java Application which I want to be deployed in Azure fabric. I have installed the Fabric SDK and Visual studio tools as per the documentation.

After that I have created the Service Fabric application "Guest Executable" template and my project structure is like below:

enter image description here

I have followed steps similar to the documentation as in

My ServiceManifest.xml is below:

<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="Guest1Pkg"
<StatelessServiceType ServiceTypeName="Guest1Type" UseImplicitHost="true" />
<CodePackage Name="Code" Version="1.0.0">
<ConfigPackage Name="Config" Version="1.0.0" />
<Endpoint Name="JavaAppTypeEndpoint" Protocol="http" Port="8080" Type="Input" />

My ApplicationManifest.xml snippet is below:

<?xml version="1.0" encoding="utf-8"?>
<ApplicationManifest ApplicationTypeName="Application1Type"
<Parameter Name="Guest1_InstanceCount" DefaultValue="-1" />
<ServiceManifestRef ServiceManifestName="Guest1Pkg" ServiceManifestVersion="1.0.0" />
<ConfigOverrides />
<Service Name="Guest1">
<StatelessService ServiceTypeName="Guest1Type" InstanceCount="[Guest1_InstanceCount]">
<SingletonPartition />

I deployed to Service Fabric Explorer in my local, and the build and publish steps are good without any errors:

-------- Package: Project: Application1 succeeded, Time elapsed: 00:00:00.3530634 --------
2>Started executing script 'Deploy-FabricApplication.ps1'.
2>. 'C:\Users\samanoha\Documents\Visual Studio 2015\Projects\Application1\Application1\Scripts\Deploy-FabricApplication.ps1' -ApplicationPackagePath 'C:\Users\samanoha\Documents\Visual Studio 2015\Projects\Application1\Application1\pkg\Debug' -PublishProfileFile 'C:\Users\samanoha\Documents\Visual Studio 2015\Projects\Application1\Application1\PublishProfiles\Local.5Node.xml' -DeployOnly:$true -UnregisterUnusedApplicationVersionsAfterUpgrade $false -OverrideUpgradeBehavior 'None' -OverwriteBehavior 'Always' -SkipPackageValidation:$true -ErrorAction Stop
2>Copying application to image store...
2>Copy application package succeeded
2>Registering application type...
2>Register application type succeeded
2>Removing application package from image store...
2>Remove application package succeeded
2>Finished executing script 'Deploy-FabricApplication.ps1'.
2>Time elapsed: 00:00:01.9327912
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
========== Deploy: 1 succeeded, 0 failed, 0 skipped ==========

Started executing script 'Publish-NewServiceFabricApplication'.
[void](Connect-ServiceFabricCluster); Import-Module 'C:\Program Files\Microsoft SDKs\Service Fabric\Tools\PSModule\ServiceFabricSDK\ServiceFabricSDK.psm1'; Publish-NewServiceFabricApplication -ApplicationPackagePath 'C:\Users\samanoha\Documents\Visual Studio 2015\Projects\Application1\Application1\pkg\Debug' -ApplicationParameterFilePath 'C:\Users\samanoha\Documents\Visual Studio 2015\Projects\Application1\Application1\PublishProfiles\..\ApplicationParameters\Local.5Node.xml' -ApplicationParameter @{_WFDebugParams_='[]'} -Action Create -SkipPackageValidation:$true -ErrorAction Stop
Creating application...

ApplicationName : fabric:/Application1
ApplicationTypeName : Application1Type
ApplicationTypeVersion : 1.0.0
ApplicationParameters : { "_WFDebugParams_" = "[]" }

Create application succeeded.

Finished executing script 'Publish-NewServiceFabricApplication'.
Time elapsed: 00:00:01.8691591
Started executing script 'Get-ServiceFabricApplicationStatus'.
[void](Connect-ServiceFabricCluster); Import-Module 'C:\Program Files\Microsoft SDKs\Service Fabric\Tools\PSModule\ServiceFabricSDK\ServiceFabricSDK.psm1'; Get-ServiceFabricApplicationStatus -ApplicationName 'fabric:/Application1' -ErrorAction Stop
The application has started.
Service Status:
fabric:/Application1/Guest1 is ready.

The application is ready.
Finished executing script 'Get-ServiceFabricApplicationStatus'.
Time elapsed: 00:00:01.0230548

But the application health state shows error and the event is

"Error event: SourceId='System.Hosting', Property='CodePackageActivation:Code:EntryPoint'.
There was an error during CodePackage activation."

enter image description here

I don't have any idea what might be the issue here in deployment, whether anything needs to be included in Application service Entry point in addition to mentioned above.

Also, The Java webapplication when deployed on Standalone tomcat has the following context http://localhost:8080/HelloWorld/hello . If the Application is deployed in Service fabric cluster, will the URL context for this remains same or should it be something like http://localhost:8080/Application1/Guest1/HelloWorld/hello due to the Azure fabric wrapper around it?

Answer Source

Finally it turned out that we need to separately install Java in the Host virtual machine (Azure VM or local Desktop) and then we have to reference the java path.

So my service manifest is

        <ConsoleRedirection FileRetentionCount="5" FileMaxSizeInKb="2048"/>

I have created a folder called scripts under Code folder and the script file "launchConfig.cmd" has just single line as below:

"C:\Program Files (x86)\Java\jre1.8.0_101\bin\java.exe" -jar HelloWorld.war

We might need to remove the path hardcodings, but this is how it referred finally.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download