0

このチュートリアル http://blogs.msdn.com/b/dachou/archive/2010/03/21/run-java-with-jetty-in-windows-azure.aspxに従いまし たが、「ファイルが見つかりません」という例外が発生しますプログラムを実行すると、何度も試してみましたが、うまくいきません.今、\app\java だけを workerrole に追加し、このコードを使用しました

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Threading;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.Diagnostics;
using Microsoft.WindowsAzure.ServiceRuntime;
using Microsoft.WindowsAzure.Storage;

namespace JettyWorkerRole
{
    public class WorkerRole : RoleEntryPoint
    {
        public override void Run()
        {
            string response = "";

            System.IO.StreamReader sr; 

            // This is a sample worker implementation. Replace with your logic.
            Trace.TraceInformation("JettyWorkerRole entry point called", "Information");

            string roleRoot = Environment.GetEnvironmentVariable("RoleRoot");
            string port = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["HttpIn"].IPEndpoint.Port.ToString();
            string address = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["HttpIn"].IPEndpoint.Address.ToString();
            Trace.TraceInformation("RADICE " + roleRoot, "Information");
            Trace.TraceInformation("PORTA " + port, "Information");
            Trace.TraceInformation("INDIRIZZO " + address, "Information");
            string jreHome = roleRoot + @"\approot\app\jre7";
            Trace.TraceInformation("JAVA 7 " + jreHome, "Information");


            Process proc = new Process();
            proc.StartInfo.UseShellExecute = false;
            proc.StartInfo.RedirectStandardOutput = true;
            proc.StartInfo.FileName = String.Format("\"{0}\\bin\\java.exe\"", jreHome);
            //proc.StartInfo.Arguments = String.Format("-Djetty.port={0} -Djetty.home=\"{1}\" -jar \"{1}\\start.jar\"", port, jettyHome);
            proc.StartInfo.Arguments = String.Format("-version");
            proc.EnableRaisingEvents = false;
            proc.Start();

            sr = proc.StandardOutput;
            response = sr.ReadToEnd(); 

            while (true)
            {
                Thread.Sleep(10000);
                Trace.TraceInformation("Working", "Information");
            }
        }

        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections 
            ServicePointManager.DefaultConnectionLimit = 12;

            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

            return base.OnStart();
        }
    }
}

しかし、proc.Start() で常に Win32 例外ファイルが見つかりません。これを修正して Java (および jetty) を使用するにはどうすればよいですか?

4

1 に答える 1

0

これは、ホスティング OSにデフォルトでJVM/JRE がインストールされてjava.exeおらず、見つからないためです。

ホストされている Azure マシンに JVM をインストールするには、いくつかの方法があります。jre6参照するブログ エントリで説明されているのは、Azure プロジェクトにフォルダーを追加して "コピー" インストールを実行することだけです。ただし、実際の JRE バイナリはサンプル プロジェクトに含まれていないため、展開用の正しい設定と共に手動で追加する必要があることに注意してください。

この MSDN ブログで提案されている別のオプションは、JVM バイナリを BLOB ストレージに配置し、ロールの起動時にダウンロードすることです。

于 2013-05-22T21:33:11.863 に答える