异常HTTP Status 500 - Illegal access to constructor, is it public? java.lang.IllegalAccessException: Class com.opensymphony.xwork2.ObjectFactory can not access a member of class action.CoreAction with

Exception report

message Illegal access to constructor, is it public?

description The server encountered an internal error that prevented it from fulfilling this request.

exception

Illegal access to constructor, is it public?
	com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:297)
	com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:393)
	com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:194)
	org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
	org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
	com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
	org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:534)
	org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
	org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)

 

root cause

java.lang.IllegalAccessException: Class com.opensymphony.xwork2.ObjectFactory can not access a member of class action.CoreAction with modifiers ""
	sun.reflect.Reflection.ensureMemberAccess(Reflection.java:109)
	java.lang.Class.newInstance(Class.java:368)
	com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:131)
	com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:162)
	com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:151)
	com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:121)
	com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:293)
	com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:393)
	com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:194)
	org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
	org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
	com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
	org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:534)
	org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
	org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
解决办法:有两个办法

1、原因是 自己的粗心造成的你的javaBean忘记写public关键字了

 

解决方法:javaBean类前加上public的修饰符

2、原因是 Class com.opensymphony.xwork2.ObjectFactory与JavaBean不在同一个包下,java的默认修饰符范围在同一个包下

解决方法:javaBean的构造方法不写或者加个public的修饰符

posted @ 2018-04-05 16:22  慕容天白  阅读(1031)  评论(0编辑  收藏  举报