

Have you ever run into ClassCastException while coding a Stash plugin?
I did several times enjoying the error widget on the right. There were several approaches to fix this including digging deep into the maven dependency tree and comparing dependencies and versions.
.... [INFO] [talledLocalContainer] java.lang.ClassCastException: info.lotharschulz.stash.MyCheck cannot be cast to com.atlassian.stash.scm.pull.MergeRequestCheck [INFO] [talledLocalContainer] at com.atlassian.stash.scm.pull.MergeRequestCheckModuleDescriptor. getModule(MergeRequestCheckModuleDescriptor.java:24) ~[stash-spi-3.3.0.jar:na] [INFO] [talledLocalContainer] at com.atlassian.stash.internal.pull.DefaultMergeRequestCheckService. check(DefaultMergeRequestCheckService.java:43) ~[stash-service-impl-3.3.0.jar:na] ....
Finally, the fix was to make sure the class doing the check (MyCheck in my sample) follows 2 rules:
- implements com.atlassian.stash.scm.pull.MergeRequestCheck
- is referenced in atlassian-plugin.xml within a merge-ckeck xml tag using the class property
(Unfortunately I used other tags like component initially.)
<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2"> <plugin-info> <description>${project.description}</description> ... </plugin-info> ... <merge-check key="MyCheck" class="info.lotharschulz.stash.MyCheck" /> </atlassian-plugin>
Leave a Reply