简体   繁体   English

Tomcat 8无法通过反射访问受保护的成员

[英]Tomcat 8 cannot access protected member via reflection

I have a very strange situation. 我的情况很奇怪。 Reflection in my application works on Tomcat 7 but not on Tomcat 8. I am using reflection to inspect common field from generated objects by name. 我的应用程序中的反射在Tomcat 7上起作用,但在Tomcat 8上却不起作用。我使用反射来按名称检查生成的对象中的公共字段。

What happens is that when application is ran on Tomcat 8 i get illegal access exception. 发生的是,当在Tomcat 8上运行应用程序时,我得到了非法访问异常。

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".

I have no clue how is this error possible, does anyboe have an idea? 我不知道这个错误怎么可能,有人有想法吗?

Note: Java 7 is used on both PCs. 注意:两台PC均使用Java 7。

This appears to be some temporary issue with Tomcat and/or generated class from XSD. 这似乎是Tomcat和/或XSD生成的类的暂时问题。 After two redeploys, issue removed itself. 重新部署两次后,问题被删除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM