Reputation: 319
I've deployed a worker role with Tomcat 7 and a very simple test servlet which should simply display the ID of the serving instance (I want to test a session management solution across multiple instances).
I'm using the Azure SDK for java (github.com/WindowsAzure/azure-sdk-for-java)
Problem is that Tomcat throws an error when I call the following:
RoleEnvironment.getCurrentRoleInstance().getId()
The actual error thrown is:
com.microsoft.windowsazure.serviceruntime.RoleEnvironmentNotAvailableException
com.microsoft.windowsazure.serviceruntime.RoleEnvironment.initialize(RoleEnvironment.java:77)
com.microsoft.windowsazure.serviceruntime.RoleEnvironment.getCurrentRoleInstance(RoleEnvironment.java:331)
com.anubex.test.TestSessionServlet.doGet(TestSessionServlet.java:35)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
java.lang.RuntimeException: java.io.FileNotFoundException: \\.\pipe\WindowsAzureRuntime (The system cannot find the file specified)
com.microsoft.windowsazure.serviceruntime.FileInputChannel.getInputStream(FileInputChannel.java:33)
com.microsoft.windowsazure.serviceruntime.RuntimeVersionProtocolClient.getVersionMap(RuntimeVersionProtocolClient.java:41)
com.microsoft.windowsazure.serviceruntime.RuntimeVersionManager.getRuntimeClient(RuntimeVersionManager.java:48)
com.microsoft.windowsazure.serviceruntime.RoleEnvironment.initialize(RoleEnvironment.java:74)
com.microsoft.windowsazure.serviceruntime.RoleEnvironment.getCurrentRoleInstance(RoleEnvironment.java:331)
com.anubex.test.TestSessionServlet.doGet(TestSessionServlet.java:35)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
java.io.FileNotFoundException: \\.\pipe\WindowsAzureRuntime (The system cannot find the file specified)
java.io.FileInputStream.open(Native Method)
java.io.FileInputStream.<init>(FileInputStream.java:120)
java.io.FileInputStream.<init>(FileInputStream.java:79)
com.microsoft.windowsazure.serviceruntime.FileInputChannel.getInputStream(FileInputChannel.java:30)
com.microsoft.windowsazure.serviceruntime.RuntimeVersionProtocolClient.getVersionMap(RuntimeVersionProtocolClient.java:41)
com.microsoft.windowsazure.serviceruntime.RuntimeVersionManager.getRuntimeClient(RuntimeVersionManager.java:48)
com.microsoft.windowsazure.serviceruntime.RoleEnvironment.initialize(RoleEnvironment.java:74)
com.microsoft.windowsazure.serviceruntime.RoleEnvironment.getCurrentRoleInstance(RoleEnvironment.java:331)
com.anubex.test.TestSessionServlet.doGet(TestSessionServlet.java:35)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
Problem seems to be that the following named pipe cannot be found:
\\.\pipe\WindowsAzureRuntime
Not sure how/where this gets created. Any ideas?
Upvotes: 0
Views: 1291
Reputation: 657
I guess you are using AzureRunMe to run your Java Project. In Windows Azure Service Runtime, there are two mechanism to supply RoleEnviroment information. The first one is via .NET assembly, the second one is via Windows named pipe. The first method is meant to be used by .NET applications, the second method is meant to be used by applications written by non-.NET languages. However, the second method would not be available unless the program is started via ProgramEntryPoint in ServiceDefinition file.
The scenario that you are facing is that AzureRunMe is started via the first method, but Java SDK is trying to access RoleEnviroment via the second method. It failed at that time.
There are two mitigation strategies that are worthy exploring. A. update AzureRunMe to expose RoleEnviroment information to Java. B. Run AzureRunMe via ProgramEntryPoint. I would be curious about how it goes.
Upvotes: 1
Reputation: 106
I stumbled upon the same problem and this description of help: http://msdn.microsoft.com/en-us/library/hh690948(VS.103).aspx
Hope this helps,
Patriek
Upvotes: 1
Reputation: 3202
RoleEnvironmentNotAvailableException tells you that the code is not running in the context of an Azure Role. When developing an application for Azure, there are two ways that your application can be in the context of an Azure Role: it's either running in the cloud on Azure's servers, or it's running in the Compute Emulator that is part of the Azure SDK.
In your case, it looks like you are neither running in the cloud nor running in the emulator, thus the exception is thrown. To resolve this, you will need to setup your project to use the emulator. Here is a walkthrough on how to do it: http://msdn.microsoft.com/en-us/library/windowsazure/hh690944(v=vs.103).aspx
As a side note, you can check to see if you are running in the context of an Azure role by checking RoleEnvironment.isAvailable(), and you can check to see if it is emulated (i.e., running in development vs. running in the cloud) by checking RoleEnvironment.isEmulated().
Upvotes: 1