本篇文章给大家谈谈java.lang.RuntimeException:java.lang.reflect.InvocationTargetException,同时本文还将给你拓展android中的j
本篇文章给大家谈谈java.lang.RuntimeException: java.lang.reflect.InvocationTargetException,同时本文还将给你拓展android中的java.lang.reflect.invocationtargetexception、applet中的java.lang.reflect.invocationtargetexception错误、Exception in thread “main“ java.io.IOException: java.lang.reflect.InvocationTargetException、hibernate bean 的 toJSon JSONException: java.lang.reflect.InvocationTargetException等相关知识,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:- java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
- android中的java.lang.reflect.invocationtargetexception
- applet中的java.lang.reflect.invocationtargetexception错误
- Exception in thread “main“ java.io.IOException: java.lang.reflect.InvocationTargetException
- hibernate bean 的 toJSon JSONException: java.lang.reflect.InvocationTargetException
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
@JFinal 你好,想跟你请教个问题:
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at com.jfinal.core.ActionInvocation.invoke(ActionInvocation.java:61) at com.qqtool8.controller.PermissionInterceptor.intercept(PermissionInterceptor.java:42) at com.jfinal.core.ActionInvocation.invoke(ActionInvocation.java:51) at com.jfinal.core.ActionHandler.handle(ActionHandler.java:77) at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:72) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:197) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1822) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) at java.lang.Thread.run(Thread.java:662) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.GeneratedMethodAccessor38.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.jfinal.core.ActionInvocation.invoke(ActionInvocation.java:55) ... 19 more Caused by: java.lang.StackOverflowError at atg.taglib.json.util.JSONTokener.nextValue(JSONTokener.java:322) at atg.taglib.json.util.JSONArray.<init>(JSONArray.java:124) at atg.taglib.json.util.JSONTokener.nextValue(JSONTokener.java:322) at atg.taglib.json.util.JSONArray.<init>(JSONArray.java:124) at atg.taglib.json.util.JSONTokener.nextValue(JSONTokener.java:322) at atg.taglib.json.util.JSONArray.<init>(JSONArray.java:124) at atg.taglib.json.util.JSONTokener.nextValue(JSONTokener.java:322) at atg.taglib.json.util.JSONArray.<init>(JSONArray.java:124) at atg.taglib.json.util.JSONTokener.nextValue(JSONTokener.java:322) at atg.taglib.json.util.JSONArray.<init>(JSONArray.java:124) at atg.taglib.json.util.JSONTokener.nextValue(JSONTokener.java:322) at atg.taglib.json.util.JSONArray.<init>(JSONArray.java:124) at atg.taglib.json.util.JSONTokener.nextValue(JSONTokener.java:322) 后面还有两千行 at atg.taglib.json.util.JSONArray.<init>(JSONArray.java:124) at atg.taglib.json.util.JSONTokener.nextValue(JSONTokener.java:322)
PermissionInterceptor
public class PermissionInterceptor implements Interceptor { public void intercept(ActionInvocation ai) { if (Const.OPENPERMISSION) { // 没权限就忽略本次请求 String code = ai.getController().getPara("code"); if (!MyEncrypt.decode(code)) { System.out.println("your sister!" + code); ai.getController().renderJson("result", Tools.makeRenderTxt(" your sister! ")); return; } else { if (Const.CodeMap.containsKey(code)) { ai.getController().renderJson("result", Tools.makeRenderTxt(" ce! ")); return; } else { Const.CodeMap.put(code, new Date()); ai.invoke(); } } } else { ai.invoke(); // ==>上面42行报错就是这里 at com.qqtool8.controller.PermissionInterceptor.intercept(PermissionInterceptor.java:42) } } }
这个项目运行了2快两年了 就今天这个问题导致程序内存溢出崩溃好几次了
还没有找到问题在哪里 最近也没有啥大的改动
看起来是哪里死循环了? Jfinal版本是1.5
android中的java.lang.reflect.invocationtargetexception
<ImageView android:id="@+id/edt_order" android:layout_width="50dp" android:layout_height="match_parent" android:layout_alignParentRight="true" android:layout_below="@+id/separator_bottom" android:background="#fff" android:clickable="true" android:onClick="clickHandler" android:src="@drawable/edit_button" /> <ImageView android:id="@+id/save_change_order_id" android:layout_width="100dp" android:layout_height="match_parent" android:layout_alignParentRight="true" android:layout_below="@+id/separator_bottom" android:background="#fff" android:clickable="true" android:visibility="gone" android:onClick="clickHandler" android:src="@drawable/save_button" />
实际上这是定义自定义alert-dialog的xml的一部分.我希望当我点击第一个ImageView(android:id =“@ id / edt_order”)时,它的可见性变为Invisible而代替这个ImageView setvisible另一个ImageView(android:id =“@ id / save_change_order_id”)
为此,我在java文件中写下以下代码:
public void clickHandler(View v) { if (v.getId() == R.id.edt_order) { System.out.println(" edit buton click"); System.out.println("Click my Order"); img_v_save_change_order_var.setVisibility(ImageView.VISIBLE); img_btn_edit_order_var.setVisibility(ImageView.INVISIBLE); int jcount = 0; // save_change_order_id jcount = countjournals(); System.out.println("jcount = " + jcount); if (jcount < 1) { alertShow(); } else { intiliazeOrderListDialog(); } } }
但我得到的例外情况如下:
01-09 06:12:14.550: D/AndroidRuntime(1981): Shutting down VM 01-09 06:12:14.550: W/dalvikvm(1981): threadid=1: thread exiting with uncaught exception (group=0xb3ab3b90) 01-09 06:12:14.730: E/AndroidRuntime(1981): FATAL EXCEPTION: main 01-09 06:12:14.730: E/AndroidRuntime(1981): Process: com.example.demoekot,PID: 1981 01-09 06:12:14.730: E/AndroidRuntime(1981): java.lang.IllegalStateException: Could not execute method of the activity 01-09 06:12:14.730: E/AndroidRuntime(1981): at android.view.View$1.onClick(View.java:3814) 01-09 06:12:14.730: E/AndroidRuntime(1981): at android.view.View.performClick(View.java:4424) 01-09 06:12:14.730: E/AndroidRuntime(1981): at android.view.View$PerformClick.run(View.java:18383) 01-09 06:12:14.730: E/AndroidRuntime(1981): at android.os.Handler.handleCallback(Handler.java:733) 01-09 06:12:14.730: E/AndroidRuntime(1981): at android.os.Handler.dispatchMessage(Handler.java:95) 01-09 06:12:14.730: E/AndroidRuntime(1981): at android.os.Looper.loop(Looper.java:137) 01-09 06:12:14.730: E/AndroidRuntime(1981): at android.app.ActivityThread.main(ActivityThread.java:4998) 01-09 06:12:14.730: E/AndroidRuntime(1981): at java.lang.reflect.Method.invokeNative(Native Method) 01-09 06:12:14.730: E/AndroidRuntime(1981): at java.lang.reflect.Method.invoke(Method.java:515) 01-09 06:12:14.730: E/AndroidRuntime(1981): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777) 01-09 06:12:14.730: E/AndroidRuntime(1981): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593) 01-09 06:12:14.730: E/AndroidRuntime(1981): at dalvik.system.NativeStart.main(Native Method) 01-09 06:12:14.730: E/AndroidRuntime(1981): Caused by: java.lang.reflect.InvocationTargetException 01-09 06:12:14.730: E/AndroidRuntime(1981): at java.lang.reflect.Method.invokeNative(Native Method) 01-09 06:12:14.730: E/AndroidRuntime(1981): at java.lang.reflect.Method.invoke(Method.java:515) 01-09 06:12:14.730: E/AndroidRuntime(1981): at android.view.View$1.onClick(View.java:3809) 01-09 06:12:14.730: E/AndroidRuntime(1981): ... 11 more 01-09 06:12:14.730: E/AndroidRuntime(1981): Caused by: java.lang.NullPointerException 01-09 06:12:14.730: E/AndroidRuntime(1981): at com.example.demoekot.MainScreen.clickHandler(MainScreen.java:428) 01-09 06:12:14.730: E/AndroidRuntime(1981): ... 14 more
为什么我得到这个例外?
解决方法
applet中的java.lang.reflect.invocationtargetexception错误
我的应用程序作为一个应用程序运行时没有错误,但是作为一个applet引发了以下错误:
java.lang.reflect.invocationtargetexception
这是我第一次尝试将应用程序用作applet,因此我可能做错了一些,但这是我的主要课程:
package main;import java.awt.BorderLayout;import java.awt.Dimension;import java.awt.GridLayout;import javax.swing.JApplet;import javax.swing.JFrame;public class MainGame extends JApplet { private static final long serialVersionUID = 1L; public static final String NAME = "Physics - Projectile Motion Example"; public static final int HEIGHT = 160; public static final int WIDTH = HEIGHT * 16 / 9; public static final int SCALE = 4; private long reportedFramerate; long framerate = 1000 / 60; // time the frame began long frameStart; // number of frames counted this second long frameCount = 0; // time elapsed during one frame long elapsedTime; // accumulates elapsed time over multiple frames long totalElapsedTime = 0; // the actual calculated framerate reported public MainGame() { run(); } public void run() { JFrame frame = new JFrame(MainGame.NAME); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); OptionsPanel options = new OptionsPanel(); GamePanel game = new GamePanel(options); frame.setSize(new Dimension ( WIDTH * SCALE, HEIGHT * SCALE )); frame.add(game, BorderLayout.CENTER); frame.add(options, BorderLayout.SOUTH); frame.setLocationRelativeTo(null); frame.setResizable(false); frame.setVisible(true); while(true) { frameStart = System.currentTimeMillis(); if(options.isStartGame() == true) { game.run(); } else { game.reset(); } // calculate the time it took to render the frame elapsedTime = System.currentTimeMillis() - frameStart; // sync the framerate try { // make sure framerate milliseconds have passed this frame if (elapsedTime < framerate) { Thread.sleep(framerate - elapsedTime); } else { // don''t starve the garbage collector Thread.sleep(5); } } catch (InterruptedException e) { break; } ++frameCount; totalElapsedTime += (System.currentTimeMillis() - frameStart); if (totalElapsedTime > 1000) { reportedFramerate = (long) ((double) frameCount / (double) totalElapsedTime * 1000.0); // show the framerate in the applet status window //System.out.println("fps: " + reportedFramerate); // repaint(); frameCount = 0; totalElapsedTime = 0; //System.out.println(reportedFramerate); } } } public void init() { new MainGame(); } public void start() { System.out.println("started"); } public void stop() { System.out.println("Stopped"); } public void destroy() { } public static void main(String[] args) { new MainGame(); }}
对象的HTML:
<p><object type="application/x-java-applet" name="physics" width="360" height="320"> <param name="code" value="main.MainGame.class" /> <param name="archive" value="physics.jar" /> <param name="scriptable" value="true" /> <param name="mayscript" value="true" /> <param name="file" value="/report_files/1-1272041330710YAIwK" /></object></p>
查看自己的错误的示例页面:http :
//fogest.com/java_example/
答案1
小编典典完整的堆栈跟踪为:
Java Plug-in 10.21.2.11Using JRE version 1.7.0_21-b11 Java HotSpot(TM) Client VMUser home directory = C:\Users\Andrew----------------------------------------------------c: clear console window...0-5: set trace level to <n>----------------------------------------------------Trace level set to 5: all ... completed.security: blacklist: hasBeenModifiedSince 1370282598700 (we have 1366432497929)security: blacklist: hasBeenModifiedSince 1366432497958 (we have 1366432497929)network: Created version ID: 1.7.0.21network: Created version ID: 1.7.0.21basic: exception: java.lang.reflect.InvocationTargetException.java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.runOnEDTAndWait(Unknown Source) at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.instantiateApplet(Unknown Source) at sun.plugin2.applet.Plugin2Manager.initAppletAdapter(Unknown Source) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source)Caused by: java.lang.reflect.InvocationTargetException at com.sun.deploy.uitoolkit.impl.awt.OldPluginAWTUtil.invokeAndWait(Unknown Source) ... 5 moreCaused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "exitVM.0") at java.security.AccessControlContext.checkPermission(Unknown Source) at java.security.AccessController.checkPermission(Unknown Source) at java.lang.SecurityManager.checkPermission(Unknown Source) at sun.plugin2.applet.AWTAppletSecurityManager.checkPermission(Unknown Source) at java.lang.SecurityManager.checkExit(Unknown Source) at javax.swing.JFrame.setDefaultCloseOperation(Unknown Source) at main.MainGame.run(MainGame.java:36) at main.MainGame.<init>(MainGame.java:31) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at java.lang.Class.newInstance0(Unknown Source) at java.lang.Class.newInstance(Unknown Source) at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter$1.run(Unknown Source) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$200(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)basic: Removed progress listener: sun.plugin.util.ProgressMonitorAdapter@1f312f0security: Reset deny session certificate storesecurity: blacklist: hasBeenModifiedSince 1366740392097 (we have 1366432497929)security: blacklist: hasBeenModifiedSince 1369035157319 (we have 1366432497929)network: CleanupThread used 6369043 usbasic: PluginMain.unregisterApplet: 1 from mananger sun.plugin2.applet.Applet2Manager@1823290network: Checking for update at: https://javadl-esd-secure.oracle.com/update/baseline.versionnetwork: Checking for update at: https://javadl-esd-secure.oracle.com/update/blacklisted.certsnetwork: Checking for update at: https://javadl-esd-secure.oracle.com/update/blacklistsecurity: JSS is not configurednetwork: Connecting https://javadl-esd-secure.oracle.com/update/baseline.version with proxy=DIRECTnetwork: Connecting https://javadl-esd-secure.oracle.com/update/blacklisted.certs with proxy=DIRECTnetwork: Connecting https://javadl-esd-secure.oracle.com/update/blacklist with proxy=DIRECTnetwork: Connecting http://javadl-esd-secure.oracle.com:443/ with proxy=DIRECTnetwork: Connecting http://javadl-esd-secure.oracle.com:443/ with proxy=DIRECTnetwork: Connecting http://javadl-esd-secure.oracle.com:443/ with proxy=DIRECTsecurity: Loading Root CA certificates from C:\Program Files (x86)\Java\jre7\lib\security\cacertssecurity: Loaded Root CA certificates from C:\Program Files (x86)\Java\jre7\lib\security\cacertssecurity: Loading SSL Root CA certificates from C:\Program Files (x86)\Java\jre7\lib\security\cacertssecurity: Loaded SSL Root CA certificates from C:\Program Files (x86)\Java\jre7\lib\security\cacertssecurity: Loading certificates from Deployment session certificate storesecurity: Loaded certificates from Deployment session certificate storesecurity: Loading certificates from Deployment session certificate storesecurity: Loaded certificates from Deployment session certificate storesecurity: Loading certificates from Deployment session certificate storesecurity: Loaded certificates from Deployment session certificate storenetwork: Cookie service is not available - use cache to determine "Cookie"network: Cookie service is not available - use cache to determine "Cookie"network: Cookie service is not available - use cache to determine "Cookie"
重要的部分是:
Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "exitVM.0")
原因是:
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
甚至没有一个受信任的applet也不能(或者至少应该尝试)退出JVM。
Exception in thread “main“ java.io.IOException: java.lang.reflect.InvocationTargetException
关于使用HBase-1.3.1版本 API 运行时出现 Exception in thread "main" java.io.IOException: java.lang.reflect.InvocationTargetException 异常的原因和解决方案
一 现象
二 原因
HBase-1.3.1版本和JDK版本不匹配,可以使用JDK1.7或者JDK1.8
三 解决办法:改JDK版本
(0)安装JDK1.8或者JDK1.7版本,要记得安装路径,等一下要用,比如我的安装路径是:
(1)点击Window下的Preferences
(2)添加JDK1.8或者JDK1.7的根目录
(3)添加JDK1.8或者JDK1.7
a)
b) 点击Directory找到你刚刚JDK的安装目录
c)上一步完整之后,点击Apply and Close
(4)修改当前项目的jdk
a)
b)
c)
d)
e)选择JDK1.8或者JDK1.7
f)最后点击Apply and Close ,然后重新运行程序就没问题啦!!!
hibernate bean 的 toJSon JSONException: java.lang.reflect.InvocationTargetException
将hibernate的 对象 使用 转换成json 对象的时候报错
JSONException: java.lang.reflect.InvocationTargetException
从错误异常,完全看不出是什么原因。
网上查询,一般都说是 时间 date 类型 转换的时候报错的。
那么我使用
JsonConfig cfg = new JsonConfig();
String[] excludes = { "date"};
都过滤掉 date 的字段属性,还是报错了。
只是有一个奇怪的地方,就是 新增和编辑的时候没有问题。只是在 其他地方引用这个对象的时候, 然后转换json的时候就报错了。
也是有点奇怪。
参考 https://blog.csdn.net/ye1992/article/details/17436765#reply
String[] excludes = 加上了 "handler", "hibernateLazyInitializer"
JsonConfig cfg = new JsonConfig();
String[] excludes = { "handler", "hibernateLazyInitializer" };
就解决了这个问题。 估计是 因为
只是在 其他地方引用这个对象的时候,可能是因为hibernate 懒加载出的对象,因此出了点其他的问题吧。
关于java.lang.RuntimeException: java.lang.reflect.InvocationTargetException的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于android中的java.lang.reflect.invocationtargetexception、applet中的java.lang.reflect.invocationtargetexception错误、Exception in thread “main“ java.io.IOException: java.lang.reflect.InvocationTargetException、hibernate bean 的 toJSon JSONException: java.lang.reflect.InvocationTargetException等相关知识的信息别忘了在本站进行查找喔。
本文标签: