我有一个非常奇怪的情况。我的应用程序中的反射可以在Tomcat7上工作,但不能在Tomcat8上工作。我正在使用反射从生成的对象中按名称检查公共字段。
发生的情况是,当应用程序在Tomcat8上运行时,我得到非法访问异常。
Field field = response.getClass().getDeclaredField(RESPONSE_FIELD);
field.setAccessible(true);
// get response status
String status = (String) field.get(response);
java.lang.IllegalAccessException: Class com.ccf.services.DistributedCustomerCareService can not access a member of class com.ccf.generated.CcfGetProfileRes with modifiers "protected".我不知道这个错误是怎么发生的,有谁知道吗?
注意: Java 7在两台PC上都使用。
发布于 2015-07-02 20:06:29
这似乎是Tomcat和/或从XSD生成的类的一些临时问题。在两次重新部署后,issue自行删除。
https://stackoverflow.com/questions/31184168
复制相似问题