Has anybody run into this before? I'm tempted to thing it's a defect in Sling
8.
I write a @Service for OSGI, and it has a @Reference to another service,
such as a ResourceResolverFactory, and deploy it to Sling the same way I
have for several years, and it fails to get the Reference, with the
following:
Error during instantiation of the implementation object
(java.lang.VerifyError: Expecting a stackmap frame at branch target 13
Exception Details:
Location:
com/edliohelloworld/image_microservice/ImageServlet.unbindResolverFactory(Lorg/apache/sling/api/resource/ResourceResolverFactory;)V
@5: if_acmpne
Reason:
Expected stackmap frame at this location.
Bytecode:
0x0000000: 2ab4 002c 2ba6 0008 2a01 b500 2cb1
)
java.lang.VerifyError: Expecting a stackmap frame at branch target 13
Exception Details:
Location:
com/edliohelloworld/image_microservice/ImageServlet.unbindResolverFactory(Lorg/apache/sling/api/resource/ResourceResolverFactory;)V
@5: if_acmpne
Reason:
Expected stackmap frame at this location.
Bytecode:
0x0000000: 2ab4 002c 2ba6 0008 2a01 b500 2cb1
****************************
Steps to reproduce:
- Running on Java 8 HotSpot JVM
- Download latest Sling 8 from http://sling.apache.org/downloads.cgi. You
can use either standalone or "Web Application," I've confirmed on both.
- Start the Sling server
- Write and Compile a simple OSGI bundle using the maven-bundle-plugin
- Include the following Servlet
@SlingServlet(
paths = "/myservice/image",
methods = {"GET" , "POST"})
public class ImageServlet extends SlingSafeMethodsServlet{
@Reference
ResourceResolverFactory resolverFactory;
@Override
protected void doGet(SlingHttpServletRequest request,
SlingHttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("
" + "HELLO WITH A " + resolverFactory + " FROM SERVLET" + "
");
}
}
You'll get the error on deployment of the bundle, and the servlet will not
register, and you'll get a 404 when attempting to hit the servlet. If you
comment out the @Reference annotation, so that Sling doesn't try to inject
the ResourceResolverFactory, then the Servlet will register, but of course
the resolverFactory will be null.
I also tested by writing my own *very* simple hello world service, and that
gets the same java.lang.VerifyError on instantiation.
My best guess is that I need to use a different JVM version or some JVM
arguments so that it doesn't do this verification??
--
View this message in context:
http://apache-sling.73963.n3.nabble.com/java-lang-VerifyError-tp4070000.html
Sent from the Sling - Users mailing list archive at Nabble.com.