No passo 6 (Serviço com XML) da aula 06, o meu navegador apresenta erro HTTP 500. Meu código está assim:
XStream xstream = new XStream();
xstream.alias("empresa", Empresa.class);
String xml = xstream.toXML(empresas);
response.setContentType("application/xml");
response.getWriter().print(xml);
O erro aparece assim:
Type Exception Report
Message Servlet execution threw an exception
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
javax.servlet.ServletException: Servlet execution threw an exception org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) Root Cause
java.lang.ExceptionInInitializerError com.thoughtworks.xstream.XStream.setupConverters(XStream.java:1002) com.thoughtworks.xstream.XStream.(XStream.java:592) com.thoughtworks.xstream.XStream.(XStream.java:514) com.thoughtworks.xstream.XStream.(XStream.java:483) com.thoughtworks.xstream.XStream.(XStream.java:429) com.thoughtworks.xstream.XStream.(XStream.java:368) br.com.alura.gerenciador.servlet.EmpresasService.service(EmpresasService.java:29) javax.servlet.http.HttpServlet.service(HttpServlet.java:764) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) Root Cause
java.lang.reflect.InaccessibleObjectException: Unable to make field protected java.lang.reflect.InvocationHandler java.lang.reflect.Proxy.h accessible: module java.base does not "opens java.lang.reflect" to unnamed module @2a1e30ff java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354) java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297) java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178) java.base/java.lang.reflect.Field.setAccessible(Field.java:172) com.thoughtworks.xstream.core.util.Fields.locate(Fields.java:40) com.thoughtworks.xstream.converters.extended.DynamicProxyConverter.(DynamicProxyConverter.java:42) com.thoughtworks.xstream.XStream.setupConverters(XStream.java:1002) com.thoughtworks.xstream.XStream.(XStream.java:592) com.thoughtworks.xstream.XStream.(XStream.java:514) com.thoughtworks.xstream.XStream.(XStream.java:483) com.thoughtworks.xstream.XStream.(XStream.java:429) com.thoughtworks.xstream.XStream.(XStream.java:368) br.com.alura.gerenciador.servlet.EmpresasService.service(EmpresasService.java:29) javax.servlet.http.HttpServlet.service(HttpServlet.java:764) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)