Maven build error: “Caused by: java.io.IOException: Incompatible version 1007”

I was encountering this error in Jenkins when it tried to build a project I was working on:


Caused by: java.io.IOException: Incompatible version 1007.
at org.jacoco.core.data.ExecutionDataReader.readHeader(ExecutionDataReader.java:127)
at org.jacoco.core.data.ExecutionDataReader.readBlock(ExecutionDataReader.java:107)
at org.jacoco.core.data.ExecutionDataReader.read(ExecutionDataReader.java:87)
at org.sonar.plugins.jacoco.AbstractAnalyzer.readExecutionData(AbstractAnalyzer.java:134)
at org.sonar.plugins.jacoco.AbstractAnalyzer.analyse(AbstractAnalyzer.java:107)

The problem was due to a breakage/bug in the jacoco-maven-plugin. To fix, simply add a version in your pom.xml, like so:


<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.7.4.201502262128</version>
    <executions>
        <execution>
            <goals>
                <goal>prepare-agent</goal>
            </goals>
        </execution>
    </executions>
</plugin>

That’s it!

Maven Error: “Bare Repository has neither a working tree, nor an index”

I suddenly couldn’t build a Maven project at work because of the error below…. Did some googling but didn’t really find helpful info, other than that I was touching a “bare” repository. I thought about it for a second and realized that maybe my changing the artifact version in the pom had something to do with it (I did this as another branch had increased the version).

I quickly rolled it back to the previous version, committed and pushed, and, voila, Jenkins started building my project successfully again.

Adding it here in case someone gets bit with this [annoying] error.


18:17:46 [info] HEAD is [ de8cb9011de6b1fc101ac8133875aaf076b9bbe3 ]
18:17:46 org.eclipse.jgit.errors.NoWorkTreeException: Bare Repository has neither a working tree, nor an index
18:17:46 at org.eclipse.jgit.lib.Repository.getWorkTree(Repository.java:1246)
18:17:46 at org.eclipse.jgit.treewalk.FileTreeIterator.(FileTreeIterator.java:88)
18:17:46 at org.eclipse.jgit.api.StatusCommand.call(StatusCommand.java:126)
18:17:46 at pl.project13.jgit.DescribeCommand.findDirtyState(DescribeCommand.java:360)
18:17:46 at pl.project13.jgit.DescribeCommand.call(DescribeCommand.java:296)
18:17:46 at pl.project13.maven.git.JGitProvider.getGitDescribe(JGitProvider.java:225)
18:17:46 at pl.project13.maven.git.JGitProvider.getGitDescribe(JGitProvider.java:122)
18:17:46 at pl.project13.maven.git.GitDataProvider.maybePutGitDescribe(GitDataProvider.java:93)
18:17:46 at pl.project13.maven.git.GitDataProvider.loadGitData(GitDataProvider.java:63)
18:17:46 at pl.project13.maven.git.GitCommitIdMojo.loadGitDataWithJGit(GitCommitIdMojo.java:485)
18:17:46 at pl.project13.maven.git.GitCommitIdMojo.loadGitData(GitCommitIdMojo.java:457)
18:17:46 at pl.project13.maven.git.GitCommitIdMojo.execute(GitCommitIdMojo.java:315)
18:17:46 at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
18:17:46 at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
18:17:46 at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
18:17:46 at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
18:17:46 at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
18:17:46 at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
18:17:46 at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
18:17:46 at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
18:17:46 at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
18:17:46 at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
18:17:46 at org.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:117)
18:17:46 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
18:17:46 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
18:17:46 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
18:17:46 at java.lang.reflect.Method.invoke(Method.java:483)
18:17:46 at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:329)
18:17:46 at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
18:17:46 at org.jvnet.hudson.maven3.agent.Maven3Main.launch(Maven3Main.java:178)
18:17:46 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
18:17:46 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
18:17:46 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
18:17:46 at java.lang.reflect.Method.invoke(Method.java:483)
18:17:46 at hudson.maven.Maven3Builder.call(Maven3Builder.java:136)
18:17:46 at hudson.maven.Maven3Builder.call(Maven3Builder.java:71)
18:17:46 at hudson.remoting.UserRequest.perform(UserRequest.java:121)
18:17:46 at hudson.remoting.UserRequest.perform(UserRequest.java:49)
18:17:46 at hudson.remoting.Request$2.run(Request.java:324)
18:17:46 at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
18:17:46 at java.util.concurrent.FutureTask.run(FutureTask.java:266)
18:17:46 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
18:17:46 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
18:17:46 at java.lang.Thread.run(Thread.java:744)

ActiveMQ error: “java.lang.RuntimeException: javax.jms.JMSException: Invalid version: 6, could not load org.apache.activemq.openwire.v6.MarshallerFactory”

I was working on a project that needed to send JMS messages to an Apache ActiveMQ broker that was running an older version, specifically, 5.4.x. It started failing with the error below when I switched to it, but had no issues when it was connecting to another broker running 5.9.0.

java.lang.RuntimeException: javax.jms.JMSException: Invalid version: 6, could not load org.apache.activemq.openwire.v6.MarshallerFactory

Note: It could be another version.

I googled to see what the problem was and read that it had to do with a version mismatch between my client and broker. Turned out that I was using 5.9.0, which is why it didn’t conk out with the other broker. Unfortunately, I didn’t have control of the current broker running 5.4.x, so it was back to the drawing board.

Thankfully, I found that ActiveMQ has a legacy dependency that you can use to resolve the issue. Simply add the following and you’ll be good to go:


<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-openwire-legacy</artifactId>
    <version>5.9.0</version>
</dependency>

IntelliJ IDEA: Pass M2_HOME to the IDE on OS X Yosemite

I had issues in Yosemite with IntelliJ always complaining that it couldn’t see my M2_HOME variable, even though I had it in my .bash_profile.  Turns out that only works in the terminal.

In any case, this worked — I verified it on my Mac, which runs v10.10.5.

1. Save this plist in ~/Library/LaunchAgents/ as custom.startup.plist



Label
my.startup
ProgramArguments

sh
-c
launchctl setenv VARIABLE_NAME1 VARIABLE_VALUE1 | launchctl setenv VARIABLE_NAME2 VARIABLE_VALUE2 | launchctl setenv VARIABLE_NAME3 VARIABLE_VALUE3

RunAtLoad
2. Log out then back in

3. That's it!

Maven: How to only execute certain Cucumber tags

I needed Maven to only run certain tests that had a specific tag (i.e., @regression).  I couldn’t easily find information via the Cucumber website, so I’m logging it her for archiving.  Note: This command also works in Jenkins via the “Goals and options” section.

clean install -Dcucumber.options="--tags @regression"