问题
I am trying to create a custom WCMCommand in CQ5.5. I have JDK1.7 and am getting the dreaded VerifyError.
ERROR [OsgiInstallerImpl] pack.age.name [pack.age.name] Error during instantiation of the implementation object (java.lang.VerifyError: Expecting a stackmap frame at branch target 13 in method pack.age.name.unbindRepo(Lorg/apache/sling/jcr/api/SlingRepository;)V at offset 5) java.lang.VerifyError: Expecting a stackmap frame at branch target 13 in method pack.age.name.unbindRepo(Lorg/apache/sling/jcr/api/SlingRepository;)V at offset 5
The method unbindRepo as far as I can tell is out of my control so there is nothing I can do on that end. The two fixes I have seen are to downgrade to JDK1.6 (which I would like to avoid) and to add "XX:-UseSplitVerifier to the startup parameter". I have seen various sources say to add it to the JVM startup commands. Only a few of these sources really go into any detail and none of them go into enough detail or reference doing it within the CQ environment directly at all.
So, how do I either add it as a startup parameter directly to the JVM outside of CQ, or how do I add it to the Build Bundle Process within CQ? I am hoping if I can build the bundle with this flag triggered that the bundle will be able to build properly.
As far as I can tell most of the JVM commands are meant to be used from the command line and that just doesn't seem to have an equivalent process when building a bundle in CQ.
Do I NEED to use eclipse in order to add command line args or is it possible to do it from with CRXDE /Lite?
Some Clarification: When I go to build the bundle, it builds perfectly fine. There are no errors in the console, it appears in the bundles list as active and the component appears as active as well. I don't exactly know when in the 'build bundle' lifecycle the error occurs but according to CQ it is perfectly fine but it just can't use it for some reason.
EDIT: I 'technically' fixed the problem. As you can see above the function 'unbindRepo' was throwing the error. So despite not knowing what it is supposed to do but I added
public void unbindRepo(SlingRepository repo)
{
// doNothing();
}
and it stopped throwing the error and everything is allowed to move on now. I do not recommend it as a solution but it let me at least move on for now which was really all I wanted. Since my question was worded in a way that Tomek did answer my actual question it is still appropriate that his is the accepted answer.
回答1:
UseSplitVerifier
is a JVM parameter and as such have to be added to the CQ startup command line. It is on the lower level than OSGi bundles, CRX DE, etc. You can set it in the CQ startup script.
On Linux machines the file is crx-quickstart/bin/start
and on Windows it's start.bat
in the same directory. Look for the line defining CQ_JVM_OPTS
variable and add following parameter at the end:
-XX:-UseSplitVerifier
回答2:
I think it's important to clarify the problem that you encountered here so that someone who encounters something similar will be able to get a better understanding of the issue.
To summarize, you created a custom osgi bundle with a new service based on WCMCommand
The error you received:
java.lang.VerifyError: Expecting a stackmap frame at branch target 13 in method
pack.age.name.unbindRepo(Lorg/apache/sling/jcr/api/SlingRepository;)V
Is saying that when Java 7 attempts to validate the signature of your method. It's encountering an error. This only occurs in Java7 as Oracle increased the level of validation that occurs. The error that is occuring is in the method signature:
unbindRepo(SlingRepository repo);
If you look at your java class you'll notice that method doesn't exist. The reason it doesn't exist is that it is created for you when you use the Apache Sling @Reference annotation. So there is a good change that in your code you have the following line.
@Reference
private SlingRepository repo;
Which, when compiling, creates the bind and unbind methods for that attribute. When you created a new method manually for the unbind with no arguments you are circumventing the frameworks process. What impact that has in the long term is hard to determine but is certainly not good practice if you don't know what's required to unbind the object in the first place.
To correct your problem I would confirm that you have a signature for the repo object is as I described, and that your aren't using something like.
@Reference
private Repository repo;
If you continue to have problems with this I would consider approaching the Apache Sling people with this issue as it's a potential problem with Annotation process. Additionally to answer specifically your question on how to do set -XX:-UseSplitVerifier my answer is you don't. The problem is in the code that you created, you need to fix that, and Oracle is in the process of removing that parameter, so that it may not even work.
来源:https://stackoverflow.com/questions/22259579/how-do-i-add-the-command-xx-usesplitverifier-to-an-osgi-bundle-built-in-crxde-l