所以基本上我开始了一个虚拟的 JavaFX 项目只是为了为我的实际问题实现一个简约的例子。但现在我什至无法再运行那个简约的项目,也没有收到足够的错误信息来实际自己用谷歌搜索出来。所以现在,当我运行代码时,我收到了给定的错误堆栈,它不会引导我到任何地方。
我正在使用 IntelliJ。JavaFX 库设置正确,VM 选项设置为:
--module-path "C:\Program Files\Java\javafx-sdk-11.0.2\lib" --add-modules javafx.controls,javafx.fxml
最重要的是,当我运行代码时,这些错误会在控制台中弹出,但应用程序似乎仍在运行,因为我需要按下 IntelliJ 的红色停止按钮才能真正停止它。
有没有人猜测,这里出了什么问题?我没有足够的经验来跟踪这些错误,因为它们没有指向我的代码,而是指向一些 Deep Java 代码。
例外:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.NullPointerException
at java.base/java.lang.reflect.Method.invoke(Method.java:559)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
... 5 more
Run Code Online (Sandbox Code Playgroud)
主.java:
package sample;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
import java.io.IOException;
public class Main extends Application {
private Stage rootStage;
public BorderPane mainWindow;
public AnchorPane left; …Run Code Online (Sandbox Code Playgroud) java javafx intellij-idea nullpointerexception invocationtargetexception
我试图在我的文件中捕获 InvocationTargetException,但如果我没有明确地为它编写 import 语句,我就会收到这个错误。
既然在java.lang的一个子包下,不知道为什么要导入。
//this is the import statement that worked
import java.lang.reflect.InvocationTargetException;
Run Code Online (Sandbox Code Playgroud)
这是错误消息:
source\DatabaseDemo.java:38: error: cannot find symbol
}catch (NoSuchMethodException | InstantiationException | SQLException | ClassNotFoundException | IllegalAccessException | InvocationTargetException e ){
^
symbol: class InvocationTargetException
location: class DatabaseDemo
Run Code Online (Sandbox Code Playgroud) 如果这个问题有点模糊,我很抱歉,但我很困惑。
我有一个控制器,它调用服务来删除实体,然后在其位置创建一个实体。在服务中,我有我的 DAO 和我的实体,我想删除我的实体,所以我调用
DAO.delete(entity);
Run Code Online (Sandbox Code Playgroud)
然后,似乎不知从何而来,我得到了一个 InitationTargetException 异常。这里的参数是:
method: public org.springframework.web.servlet.ModelAndView tld.myproject.view.web.controller.MyController.replaceEntity(org.springframework.web.multipart.MultipartFile,javax.servlet.http.HttpServletRequest)
target: tld.myproject.view.web.controller.MyController@185918e
args: [org.springframework.web.multipart.commons.CommonsMultipartFile@14812a6, org.springframework.web.multipart.support.DefaultMultipartHttpServletRequest@c08a64]
ex: java.lang.reflect.InvocationTargetException
Run Code Online (Sandbox Code Playgroud)
失败的地方在下面的 Spring 代码中
private Object doInvokeMethod(Method method, Object target, Object[] args) throws Exception {
ReflectionUtils.makeAccessible(method);
try {
return method.invoke(target, args);
}
catch (InvocationTargetException ex) {
ReflectionUtils.rethrowException(ex.getTargetException());
}
throw new IllegalStateException("Should never get here");
}
Run Code Online (Sandbox Code Playgroud)
有人对发生的事情有建议吗?我可以在调试中使用什么?
更新: 这是堆栈跟踪:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doInvokeMethod(HandlerMethodInvoker.java:710)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:167)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:414)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:402)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647) …Run Code Online (Sandbox Code Playgroud) 我已经为 .NET Framework 项目创建了一个构建管道。当管道由拉取请求触发时,我在任务中遇到以下错误:“NuGet 恢复”
##[错误]nuget 命令失败,退出代码(1) 和错误(解析解决方案文件时出错
d:\a\1\s\***.sln:调用目标已引发异常。无法加载项目文件。无法加载文件或程序集Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a或其依赖项之一。系统找不到指定的文件。d:\a\1\s\***.sln)##[error]包恢复失败
当我尝试在与目标分支合并后在本地计算机上编译解决方案时,没有任何冲突或错误。
这是我的 YML 文件:
pool:
name: Hosted Windows 2019 with VS2019
demands:
- msbuild
- visualstudio
- vstest
steps:
- task: NuGetToolInstaller@0
displayName: 'Use NuGet 4.4.1'
inputs:
versionSpec: 4.4.1
- task: NuGetCommand@2 # --> This task fails.
displayName: 'NuGet restore'
inputs:
restoreSolution: '***.sln'
- task: VSBuild@1
displayName: 'Build solution'
inputs:
solution: '***.sln'
platform: 'any cpu'
configuration: 'release'
- task: PublishSymbols@2
displayName: 'Publish …Run Code Online (Sandbox Code Playgroud) 我正在使用Method.invoke()来调用第三方jar中的函数.有时我会抛出java.lang.reflect.InvocationTargetException.你怎么能弄清楚真正的例外是什么呢?
在调用Asynctask内部之后,仅在向父RelativeLayout添加背景图像后出现多个错误(此错误仅在使用模拟器时出现,但在与实际设备一起使用时,堆栈跟踪未显示任何内容或正常):
public class UserAuthTask extends AsyncTask<String, Void, String> {
private boolean success = false;
@Override
protected String doInBackground(String... path) {
// TODO: attempt authentication against a network service.
try {
// Simulate network access.
Thread.sleep(2000);
} catch (InterruptedException e) {
return null;
}
Log.d(Constant.TAG_AUTH, path[0]);
String apiRequestReturn = WebServiceUtil.getRequest(path[0]);
if (apiRequestReturn.equals("")) {
Log.d(Constant.TAG_AUTH, "WebService request is null");
return null;
} else {
Log.d(Constant.TAG_AUTH, "WebService request has data");
return apiRequestReturn;
}
}
@Override
protected void onPostExecute(String result) {
userAuthTask = null; …Run Code Online (Sandbox Code Playgroud) android out-of-memory invocationtargetexception runtimeexception inflate-exception
我在使用 JSON 和 Java 时遇到了一些问题,我有一个可以将数据结构导出为 JSON 并将其保存在文件中的工作功能。但是,当我尝试反向操作并将数据结构导入回 java 时,出现错误,其输出为:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at .....
Caused by: java.lang.RuntimeException: JSONObject["nodeID"] not found.
at processing.data.JSONObject.get(JSONObject.java:549)
at processing.data.JSONObject.getString(JSONObject.java:568)
at Graph.loadJSON(Graph.java:934)
... 21 more
Run Code Online (Sandbox Code Playgroud)
从那个错误中,我认为在节点中找不到字符串“nodeID”,但它在 JSON 输出中,如下所示:
{"network": [
{"node": {
"nodeID": "1",
"radius": 40
"atom": {
"id": "a-2675-EH",
"activeTime": 0,
"type": "Motor",
"linkFrom": [{
"atomID": "a-2312-TL",
"delay": 0.20000000298023224
}],
"linkTo": [{
"atomID": "a-3289-Ql",
"delay": 0.20000000298023224
}]
},
.....
Run Code Online (Sandbox Code Playgroud)
JSON 代码是包含在网络中的节点数组,然后每个节点对象包含一个 String nodeID 和 3 个 Float 变量,然后是一个名为 atom 的对象。然后这个原子包含两个字符串、一个浮点数和两个名为linkTo和linkFrom的数组,它们包含表示链接的对象(atomID和delay,分别是string和float)
从网络加载每个节点的 Java 代码如下所示:
JSONObject …Run Code Online (Sandbox Code Playgroud) java processing json runtime-error invocationtargetexception
我在我的应用程序中有这个活动,其中当用户点击按钮时,它将执行CameraUpdate在方法内部.这是代码:
LocationsActivity.java
public class TermLocActivity extends AppCompatActivity implements OnMapReadyCallback {
GoogleMap map;
public static final CameraPosition MoloTerminal =
new CameraPosition.Builder().target(new LatLng(10.699160, 122.547208))
.zoom(16)
.bearing(300)
.tilt(50)
.build();
public static final CameraPosition TagbakTerminal =
new CameraPosition.Builder().target(new LatLng(10.761854, 122.577128))
.zoom(16)
.bearing(300)
.tilt(50)
.build();
public static final CameraPosition CeresTerminal =
new CameraPosition.Builder().target(new LatLng(10.758862, 122.567774))
.zoom(16)
.bearing(300)
.tilt(50)
.build();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_term_loc);
SupportMapFragment mapFragment =
(SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap map) {
map.addMarker(new MarkerOptions().position(new LatLng(10.699160, …Run Code Online (Sandbox Code Playgroud) UnsupportedOperationExceptionBindings.bindContent()将对象绑定到时抛出TableView。为什么?如何解决这个问题?
我正在使用Java 8 update181。
Exception in Application start method java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.UnsupportedOperationException
at java.util.AbstractList.remove(AbstractList.java:161)
at java.util.AbstractList$Itr.remove(AbstractList.java:374)
at java.util.AbstractList.removeRange(AbstractList.java:571)
at java.util.AbstractList.clear(AbstractList.java:234)
at com.sun.javafx.binding.ContentBinding.bind(ContentBinding.java:55)
at javafx.beans.binding.Bindings.bindContent(Bindings.java:1020)
at problem_bind.Main.start(Main.java:42)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294) …Run Code Online (Sandbox Code Playgroud) binding javafx tableview invocationtargetexception unsupportedoperation