WARNING - 原因が見つからないファイルではありません - すべてのスレッドがのApache CommonsのExecの - 時々スレッドは、Linux
同じスクリプトファイルを呼び出している私は、5-を始めていますRed Hatボックスでローカルスクリプトを呼び出す6つのスレッド。
は、私はに関連する何かのようですので、時々、私は、すべてのプロセスが、スクリプトを実行している、
明らかに次のエラーメッセージを取得することに気付きました[1] OSは、同時にいくつかの制限がありますスクリプトを実行したり、読み込みのためにファイルにアクセスできるプロセス、または[2] Javaは準備が整っていないストリームで何らかの操作を実行しようとしています(私はcommons-execがこれを世話すると仮定していました)。
コードは次のとおりです
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
CommandLine commandline = CommandLine.parse("/home/leo/myScript.exp");
DefaultExecutor exec = new DefaultExecutor();
PumpStreamHandler streamHandler = new PumpStreamHandler(outputStream);
exec.setStreamHandler(streamHandler);
try {
exec.execute(commandline); <<< error happens here
}catch(IOException io) {
throw new Exception("");
}
エラーがある場合は、エラーが[1]、その後、私はLinuxのOS
でこの制限を緩和する方法を知りたいのですがされている場合は、[2]、その後、私は私が言うのですか知りたいですcommons-execがリソースの準備ができるまで待ちます(最悪の場合、再試行を追加しますが、これはあまりエレガントではないと思います)。
エラーが他の場合は、いくつかの解決策を見つけるのに十分なほど良いと思う。
更新日 - 3月15日
さて、ここが問題です。
スクリプトは、ライブラリを使用してJavaクラスを呼び出すexpectスクリプトです。
私が気づいたことの1つは、データベース接続を作成するJavaメソッドを呼び出すまで、スクリプトはうまくいくということです。
スレッド数が少ない(3〜5)ため、データベースに問題はないと思います。代わりに、Javaコードが呼び出されている間、および/またはJavaコードがデータベース接続を作成している間に、何かが呼び出されるスクリプトをブロックしているように見えます。
私はまだ正確な例外を取得しようとしていますが、スクリプトは次のようになります期待して(の一種)pullNextInputDataが
public static LegacyDriverTaskInputData pullNextInputData(String token) throws Exception {
try {
return pullNextInputDataImpl(token);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
private static LegacyDriverTaskInputData pullNextInputDataImpl(String token) throws Exception {
Connection conn = null;
try{
conn = new TCLDriverWrapper().getConnection();
QueryRunner run = new QueryRunner();
ResultSetHandler<LegacyDriverTaskInputData> rsh = new BeanHandler<LegacyDriverTaskInputData>(LegacyDriverTaskInputData.class);
LegacyDriverTaskInputData inputData = run.query(conn,"select * from LegacyDriverTask where id = ?",rsh,Long.valueOf(token));
return inputData;
} catch (ClassNotFoundException e) {
e.printStackTrace();
throw e;
} catch (SQLException e) {
e.printStackTrace();
throw e;
} finally {
DbUtils.close(conn);
}
}
とのgetConnection(ように見える
#!/opt/tclblend/bin/expect -f
set edfDir "/usr/local/nssa/bin/edf";
set env(LD_LIBRARY_PATH) "/opt/tclblend/lib/tcljava1.4.1"; # for tclBlend
## always use absolute paths
set env(TCL_CLASSPATH) "/home/leoks/EclipseIndigo/workspace2/xyzJavaWrapper/bin";
set env(CLASSPATH) {/home/leoks/EclipseIndigo/workspace2/xyzTomEE/lib/commons-logging-1.1.1.jar:/home/leoks/EclipseIndigo/workspace2/xyzConfiguration/lib/commons-configuration-1.9.jar:/home/leoks/EclipseIndigo/workspace2/xyzConfiguration/lib/commons-lang-2.4.jar:/home/leoks/EclipseIndigo/workspace2/xyz/3rdPartyJDBCJars/ojdbc6.jar:/home/leoks/EclipseIndigo/workspace2/xyzJavaWrapper/lib/commons-dbutils-1.5.jar:/home/leoks/EclipseIndigo/workspace2/xyzJavaWrapper/tcl/tcllib/xyzConfiguration.jar};
source $edfDir/lib/statics.tcl;
source $edfDir/lib/acclib.tcl;
package require java
java::import com.abc.xyz.legacydriver.TCLDriverWrapper
java::import com.abc.xyz.legacydriver.LegacyDriverTaskInputData
java::import com.abc.xyz.legacydriver.LegacyDriverTaskEnum
set ticket [ lindex $argv 0 ];
set inputData [ java::call com.abc.xyz.legacydriver.TCLDriverWrapper pullNextInputData $ticket ]
は)ちょうどです通常のドライバのインスタンス化のようなコード(それはApacheのdbutilsを使用します)
private Connection getConnectionImpl() throws Exception{
Class.forName("driver name");
Properties props = new Properties();
props.put("user", UtilConf.getProperty("javawrapper.user"));
props.put("password", UtilConf.getProperty("javawrapper.password"));
return DriverManager.getConnection(UtilConf.getProperty("javawrapper.jdbc"), props);
}
すぐに3月16
スタックトレースがはるかに:-(
2016-03-17 01:49:10,034 INFO [QProcessor] Threads started (ok=0 nok=0 wait=0) org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:153)
at com.ericsson.xyz.tomee.q.QWorker.onMessageImpl(QWorker.java:776)
at com.ericsson.xyz.tomee.q.QWorker.onMessage(QWorker.java:303)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:182)
at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:164)
at org.apache.openejb.monitoring.StatsInterceptor.record(StatsInterceptor.java:180)
at org.apache.openejb.monitoring.StatsInterceptor.invoke(StatsInterceptor.java:99)
at sun.reflect.GeneratedMethodAccessor106.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:182)
at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:164)
at org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:80)
at org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:212)
at org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:181)
at org.apache.openejb.core.ivm.EjbObjectProxyHandler.synchronizedBusinessMethod(EjbObjectProxyHandler.java:268)
at org.apache.openejb.core.ivm.EjbObjectProxyHandler$1.call(EjbObjectProxyHandler.java:253)
at org.apache.openejb.async.AsynchronousPool$AsynchronousCall.call(AsynchronousPool.java:110)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
@Kenster問題は、私のコードが10種類のスレッドで動作し、9つで動作しますが、1で失敗します。明らかに、ファイルが存在しないことと、質問で明確にしたことではありません。 – Leo
ところで、なぜdownvote、誰か? – Leo
'cmd'は定数ですか? 'cmd'の内容を見せてください。また、スタックトレースで実際のエラーを確認すると便利です。 – Roman