我得到这个Tomcat错误:
Sep 09, 2012 4:16:54 PM org.apache.catalina.core.AprLifecycleListener init
Information: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Products\jdk1.7.0_03\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Products/jdk1.7.0_03/jre/bin/client;C:/Products/jdk1.7.0_03/jre/bin;C:/Products/jdk1.7.0_03/jre/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Products\jdk1.7.0_03\jre\bin;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;c:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\Products\eclipse32;;.
Sep 09, 2012 4:16:54 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
Warnung: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:NAR_JDBC_DBO' did not find a matching property.
Sep 09, 2012 4:16:55 PM org.apache.coyote.AbstractProtocol init
Information: Initializing ProtocolHandler ["http-bio-80"]
Sep …Run Code Online (Sandbox Code Playgroud) 我有一个方法,通过超时执行一些任务.我使用ExecutorServer.submit()来获取Future对象,然后使用超时调用future.get().这工作正常,但我的问题是处理我的任务可以抛出的已检查异常的最佳方法.以下代码有效,并保留已检查的异常,但如果方法签名中的已检查异常列表发生更改,则它似乎非常笨拙且容易中断.
对于如何解决这个问题,有任何的建议吗?我需要针对Java 5,但我也很想知道在较新版本的Java中是否有好的解决方案.
public static byte[] doSomethingWithTimeout( int timeout ) throws ProcessExecutionException, InterruptedException, IOException, TimeoutException {
Callable<byte[]> callable = new Callable<byte[]>() {
public byte[] call() throws IOException, InterruptedException, ProcessExecutionException {
//Do some work that could throw one of these exceptions
return null;
}
};
try {
ExecutorService service = Executors.newSingleThreadExecutor();
try {
Future<byte[]> future = service.submit( callable );
return future.get( timeout, TimeUnit.MILLISECONDS );
} finally {
service.shutdown();
}
} catch( Throwable t ) { //Exception handling of nested exceptions is …Run Code Online (Sandbox Code Playgroud) 假设我有一个类定义了要完成的大块工作,可以产生几个已检查的异常.
class WorkerClass{
public Output work(Input input) throws InvalidInputException, MiscalculationException {
...
}
}
Run Code Online (Sandbox Code Playgroud)
现在假设我有一个可以调用这个类的GUI.我使用SwingWorker委派任务.
Final Input input = getInput();
SwingWorker<Output, Void> worker = new SwingWorker<Output, Void>() {
@Override
protected Output doInBackground() throws Exception {
return new WorkerClass().work(input);
}
};
Run Code Online (Sandbox Code Playgroud)
如何处理从SwingWorker抛出的可能异常?我想区分我的worker类的异常(InvalidInputException和MiscalculationException),但ExecutionException包装器使事情变得复杂.我只想处理这些异常 - 不应该捕获OutOfMemoryError.
try{
worker.execute();
worker.get();
} catch(InterruptedException e){
//Not relevant
} catch(ExecutionException e){
try{
throw e.getCause(); //is a Throwable!
} catch(InvalidInputException e){
//error handling 1
} catch(MiscalculationException e){
//error handling 2
}
}
//Problem: Since a Throwable is thrown, …Run Code Online (Sandbox Code Playgroud) 不知何故,构建崩溃并出现与位置组件相关的奇怪错误,该错误位于“src..\location\FlutterLocationService.kt:”中
这是错误:
e: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\location-4.3.0\android\src\main\java\com\lyokone\location\FlutterLocationService.kt: (124, 1): Class 'FlutterLocationService' is not abstract and does not implement abstract member public abstract fun onRequestPermissionsResult(p0: Int, p1: Array<(out) String!>, p2: IntArray): Boolean defined in io.flutter.plugin.common.PluginRegistry.RequestPermissionsResultListener
Run Code Online (Sandbox Code Playgroud) 我的代码的一部分是抛出java.util.concurrent.ExecutionException异常.我怎么处理这个?我可以使用throws条款吗?我对java有点新鲜.
我知道 Java 异常的开销已经在 SO 上搞砸了,但我没有找到任何可以解决我的情况的东西。我有一个 Future,它在调用 get() 时可能会抛出一个包含任意数量的特定于应用程序的异常的 ExecutionException。我想知道使用看起来更好的 try-catch 块而不是丑陋的 if-instanceof-then-cast 模式是否会产生显着的开销。例如,它可能看起来像这样:
private Response handleException(ExecutionException e) throws MyApplicationException {
try {
throw e.getCause();
} catch (ApplicationException1 e1) {
// known error
throw MyApplicationException.convert(e1);
} catch (ApplicationException2 e2) {
// create error response
return new Response(e2);
} catch (Throwable t) {
// unknown error
throw new RuntimeException(t);
}
}
private Response handleException2(ExecutionException e) throws MyApplicationException {
Throwable cause = e.getCause();
if (cause instanceof ApplicationException1) {
ApplicationException1 e1 = (ApplicationException1) cause; …Run Code Online (Sandbox Code Playgroud) java ×5
android ×1
catalina ×1
exception ×1
flutter ×1
future ×1
performance ×1
swingworker ×1
tomcat ×1