Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

jorphan Not Found, Adding it Causes Libs to be Incorrectly Populated #77

Closed
BinaryTweedDeej opened this Issue Sep 10, 2013 · 9 comments

Comments

Projects
None yet
5 participants

JOrphan doesn't appear to be on the classpath when attempting to use the JMeter Plugins exception; when I then add it as a plugin dependency, something very odd happens causing virtually all other jars to be be absent.

I get the following exception when trying to use the JMeter Plugins extension:

[info] Executing test: pluginTest.jmx
java.lang.NoClassDefFoundError: org/apache/jorphan/util/JMeterException

My POM looks like so:

...
<plugin>
    <groupId>com.lazerycode.jmeter</groupId>
    <artifactId>jmeter-maven-plugin</artifactId>
    <version>1.8.1</version>
    <executions>
        <execution>
            <id>jmeter-tests</id>
            <phase>verify</phase>
            <goals>
                <goal>jmeter</goal>
            </goals>
        </execution>
    </executions>
    <dependencies>
        <dependency>
            <groupId>kg.apc</groupId>
            <artifactId>jmeter-plugins</artifactId>
            <version>1.0.0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.thrift</groupId>
                    <artifactId>thrift</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>
</plugin>

With the POM as per the above, my target/jmeter/lib directory has many jars in it, as list below:

$ ls -la
total 19220
drwxr-xr-x    1 myuser  Administ    28672 Sep 10 11:14 .
drwxr-xr-x    1 myuser  Administ        0 Sep 10 11:14 ..
-rw-r--r--    1 myuser  Administ    11877 Aug 21 13:54 ApacheJMeter-2.9.jar
-rw-r--r--    1 myuser  Administ    69409 Aug 21 13:55 activation-1.1.1.jar
-rw-r--r--    1 myuser  Administ    95536 Aug 21 13:55 apache-mime4j-core-0.7.2.jar
-rw-r--r--    1 myuser  Administ   304810 Aug 21 13:55 apache-mime4j-dom-0.7.2.jar
-rw-r--r--    1 myuser  Administ    43033 Jul 18 11:56 asm-3.1.jar
-rw-r--r--    1 myuser  Administ   116219 Aug 21 13:55 aspectjrt-1.6.11.jar
-rw-r--r--    1 myuser  Administ    72851 Aug 21 13:54 avalon-framework-4.1.4.jar
-rw-r--r--    1 myuser  Administ   229116 Aug 21 13:55 bcmail-jdk15-1.45.jar
-rw-r--r--    1 myuser  Administ  1663318 Aug 21 13:55 bcprov-jdk15-1.45.jar
-rw-r--r--    1 myuser  Administ    92027 Aug 21 13:55 boilerpipe-1.1.0.jar
-rw-r--r--    1 myuser  Administ   113369 Aug 21 13:54 bsf-2.4.0.jar
-rw-r--r--    1 myuser  Administ   383846 Aug 21 13:55 bsh-2.0b5.jar
-rw-r--r--    1 myuser  Administ   232771 Aug 21 13:55 commons-codec-1.6.jar
-rw-r--r--    1 myuser  Administ   575389 Aug 20 12:29 commons-collections-3.2.1.jar
-rw-r--r--    1 myuser  Administ   241367 Aug 21 13:55 commons-compress-1.4.1.jar
-rw-r--r--    1 myuser  Administ   305001 Jul 18 11:50 commons-httpclient-3.1.jar
-rw-r--r--    1 myuser  Administ   173587 Aug  6 15:56 commons-io-2.2.jar
-rw-r--r--    1 myuser  Administ   132165 Aug 21 13:55 commons-jexl-1.1.jar
-rw-r--r--    1 myuser  Administ   267634 Aug 21 13:55 commons-jexl-2.1.1.jar
-rw-r--r--    1 myuser  Administ   315805 Jul 19 15:31 commons-lang3-3.1.jar
-rw-r--r--    1 myuser  Administ   273370 Jul 31 17:01 commons-net-3.1.jar
-rw-r--r--    1 myuser  Administ   313898 Jul 22 15:39 dom4j-1.6.1.jar
-rw-r--r--    1 myuser  Administ    56089 Aug 21 13:55 excalibur-datasource-1.1.1.jar
-rw-r--r--    1 myuser  Administ    17669 Aug 21 13:55 excalibur-instrument-1.0.jar
-rw-r--r--    1 myuser  Administ    76725 Aug 21 13:55 excalibur-logger-1.1.jar
-rw-r--r--    1 myuser  Administ    44462 Aug 21 13:55 excalibur-pool-1.2.jar
drwxr-xr-x    1 myuser  Administ    40960 Sep 10 11:14 ext
-rw-r--r--    1 myuser  Administ   188471 Aug 21 13:55 fontbox-1.7.1.jar
-rw-r--r--    1 myuser  Administ    32359 Jul 29 13:50 geronimo-jms_1.1_spec-1.1.1.jar
-rw-r--r--    1 myuser  Administ    28804 Aug 21 13:55 geronimo-stax-api_1.0_spec-1.0.1.jar
-rw-r--r--    1 myuser  Administ    76643 Jul 18 11:55 hamcrest-core-1.1.jar
-rw-r--r--    1 myuser  Administ    72245 Aug 21 13:55 htmllexer-2.1.jar
-rw-r--r--    1 myuser  Administ   138678 Aug 21 13:55 htmlparser-2.1.jar
-rw-r--r--    1 myuser  Administ   433071 Aug 21 13:55 httpclient-4.2.3.jar
-rw-r--r--    1 myuser  Administ   223571 Aug 21 13:55 httpcore-4.2.2.jar
-rw-r--r--    1 myuser  Administ    26477 Aug 21 13:55 httpmime-4.2.3.jar
-rw-r--r--    1 myuser  Administ   521237 Aug 21 13:55 isoparser-1.0-RC-1.jar
-rw-r--r--    1 myuser  Administ   142391 Aug 21 13:55 jcharts-0.7.5.jar
-rw-r--r--    1 myuser  Administ   153253 Jul 22 15:39 jdom-1.0.jar
-rw-r--r--    1 myuser  Administ   152526 Jul 19 10:23 jdom-1.1.2.jar
-rw-r--r--    1 myuser  Administ    50942 Aug 21 13:55 jempbox-1.7.1.jar
-rw-r--r--    1 myuser  Administ   415730 Aug 21 13:55 jodd-core-3.4.1.jar
-rw-r--r--    1 myuser  Administ   131082 Aug 21 13:55 jodd-lagarto-3.4.1.jar
-rw-r--r--    1 myuser  Administ   278273 Aug 21 13:55 jsoup-1.7.1.jar
-rw-r--r--    1 myuser  Administ   249924 Aug 21 13:55 jtidy-r938.jar
drwxr-xr-x    1 myuser  Administ        0 Sep 10 11:14 junit
-rw-r--r--    1 myuser  Administ   253160 Jul 18 11:55 junit-4.10.jar
-rw-r--r--    1 myuser  Administ   220813 Aug 21 13:55 juniversalchardet-1.0.3.jar
-rw-r--r--    1 myuser  Administ    81885 Aug 21 13:55 logkit-2.0.jar
-rw-r--r--    1 myuser  Administ   494924 Jul 18 11:56 mail-1.4.4.jar
-rw-r--r--    1 myuser  Administ   211185 Aug 21 13:55 metadata-extractor-2.6.2.jar
-rw-r--r--    1 myuser  Administ  4326608 Aug 21 13:55 netcdf-4.2-min.jar
-rw-r--r--    1 myuser  Administ    65261 Aug 21 13:55 oro-2.0.8.jar
-rw-r--r--    1 myuser  Administ  3910899 Aug 21 13:55 pdfbox-1.7.1.jar
-rw-r--r--    1 myuser  Administ  1820323 Aug 21 13:55 poi-3.8.jar
-rw-r--r--    1 myuser  Administ   933010 Aug 21 13:55 poi-ooxml-3.8.jar
-rw-r--r--    1 myuser  Administ  4706775 Aug 21 13:55 poi-ooxml-schemas-3.8.jar
-rw-r--r--    1 myuser  Administ  1186887 Aug 21 13:55 poi-scratchpad-3.8.jar
-rw-r--r--    1 myuser  Administ  1134765 Aug 21 13:55 rhino-1.7R4.jar
-rw-r--r--    1 myuser  Administ   208025 Aug 21 13:55 rome-0.9.jar
-rw-r--r--    1 myuser  Administ   278281 Aug 20 12:36 serializer-2.7.1.jar
-rw-r--r--    1 myuser  Administ    26083 Jul 18 14:01 slf4j-api-1.7.2.jar
-rw-r--r--    1 myuser  Administ   232498 Aug 21 13:55 soap-2.3.1.jar
-rw-r--r--    1 myuser  Administ    90722 Aug 21 13:55 tagsoup-1.2.1.jar
-rw-r--r--    1 myuser  Administ   475853 Aug 21 13:55 tika-core-1.3.jar
-rw-r--r--    1 myuser  Administ   486107 Aug 21 13:55 tika-parsers-1.3.jar
-rw-r--r--    1 myuser  Administ    47478 Aug 21 13:55 vorbis-java-core-0.1.jar
-rw-r--r--    1 myuser  Administ    14752 Aug 21 13:55 vorbis-java-tika-0.1.jar
-rw-r--r--    1 myuser  Administ  3176148 Aug 20 12:36 xalan-2.7.1.jar
-rw-r--r--    1 myuser  Administ  1229125 Aug 20 12:37 xercesImpl-2.9.1.jar
-rw-r--r--    1 myuser  Administ   194354 Aug 20 12:37 xml-apis-1.3.04.jar
-rw-r--r--    1 myuser  Administ  2666695 Aug 21 13:55 xmlbeans-2.3.0.jar
-rw-r--r--    1 myuser  Administ   517073 Aug 21 13:55 xmlgraphics-commons-1.3.1.jar
-rw-r--r--    1 myuser  Administ     7188 Jul 18 11:56 xmlpull-1.1.3.1.jar
-rw-r--r--    1 myuser  Administ   117333 Aug 21 13:55 xmpcore-5.1.2.jar
-rw-r--r--    1 myuser  Administ    24956 Jul 18 11:50 xpp3_min-1.1.4c.jar
-rw-r--r--    1 myuser  Administ   481672 Aug  6 15:56 xstream-1.4.2.jar
-rw-r--r--    1 myuser  Administ    94672 Aug 21 13:55 xz-1.0.jar

So, I tried adding jorphan as a dependency alongside the JMeter Plugins dependency. This had the strange effect of putting the jorphan jar in lib/ext as expected, but then making the contents of lib empty except for ApacheJMeter-2.9.jar

<plugin>
    <groupId>com.lazerycode.jmeter</groupId>
    <artifactId>jmeter-maven-plugin</artifactId>
    <version>1.8.1</version>
    <executions>
        <execution>
            <id>jmeter-tests</id>
            <phase>verify</phase>
            <goals>
                <goal>jmeter</goal>
            </goals>
        </execution>
    </executions>
    <dependencies>
        <dependency>
            <groupId>org.apache.jmeter</groupId>
            <artifactId>jorphan</artifactId>
            <version>2.9</version>
        </dependency>
        <dependency>
            <groupId>kg.apc</groupId>
            <artifactId>jmeter-plugins</artifactId>
            <version>1.0.0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.thrift</groupId>
                    <artifactId>thrift</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>
</plugin>
$ ls -la
total 26
drwxr-xr-x    5 myuser  Administ        0 Sep 10 11:21 .
drwxr-xr-x    6 myuser  Administ        0 Sep 10 11:21 ..
-rw-r--r--    1 myuser  Administ    11877 Aug 21 13:54 ApacheJMeter-2.9.jar
drwxr-xr-x   79 myuser  Administ    40960 Sep 10 11:21 ext
drwxr-xr-x    2 myuser  Administ        0 Sep 10 11:21 junit

I'm assuming there's a problem with the population of the JMeter lib directories, but there's no obvious log output to explain what's going on.

vazzolla commented Oct 8, 2013

Same issue found while trying to migrate from 1.8.0 to 1.8.1 for having the timestamp fix. Debugging the plugin seems that the directory structure /lib is not correctly populated (not sure if it does not have something to do with the conditions used to decide whether to copy or not the artifact... a long shot would be that is related to the commit "Clean up JMeter directory tree creation. : 9761130 " ). In my case the issue reproduces on Linux OpenSuse and Open JDK 1.7.

I had to resort to calling JMeter from the command line to work around this issue :/

Another workaround is to use maven-dependency-plugin:copy to copy jorphan to ${project.build.directory}/jmeter/lib/ext/

@ghost ghost assigned Ardesco Nov 27, 2013

Contributor

mlex commented Dec 11, 2013

The problem is related to 9761130 (as pointed out by @vazzolla). In https://github.com/Ronnie76er/jmeter-maven-plugin/blob/master/src/main/java/com/lazerycode/jmeter/JMeterAbstractMojo.java#L250, the artifacts are treated differently based on their scope.

Artifacts with scope=runtime are considered to be user-defined dependencies. That is: dependencies, that are introduced in the pom of the project where the jmeter-maven-plugin is used (like, for example, the kg.apc:jmeter-plugins dependency). These artifacts are copied into the /jmeter/lib/ext folder.

Artifacts with scope=compile are assumed to be either a dependency of the jmeter-maven-plugin itself (like org.apache.maven:maven-plugin-api). These artifacts are simply ignored. Or the artifacts are ApacheJMeter dependency. These are copied into the /jmeter/lib, /jmeter/bin or /jmeter/lib/ext folder.

The method, that should detect if an artifact is an ApacheJMeter dependency only looks at the dependencyTrail of this artifact. The problem with the user-defined kg.apc:jmeter-plugins and jorphan is, that jorphan is a dependency of both ApacheJMeter and jmeter-plugins. But the dependencyTrail of jorphan only contains jmeter-plugins.

So the jorphan artifact is not copied anywhere: It has scope=compile (because the dependency is introduced at compile-time through ApacheJMeter) but is not recognized as an ApacheJMeter dependency (because the dependencyTrail only contains jmeter-plugins).

Contributor

mlex commented Dec 11, 2013

A possible workaround for this problem is to exclude all ApacheJMeter dependencies when introducing new explicit dependencies. For the jmeter-plugins artifact, this would look like this:

            <plugin>
                <groupId>com.lazerycode.jmeter</groupId>
                <artifactId>jmeter-maven-plugin</artifactId>
                <version>1.8.1</version>
                <dependencies>
                    <dependency>
                        <groupId>kg.apc</groupId>
                        <artifactId>jmeter-plugins</artifactId>
                        <version>1.0.0</version>
                        <exclusions>
                            <exclusion>
                                <groupId>kg.apc</groupId>
                                <artifactId>perfmon</artifactId>
                            </exclusion>
                            <exclusion>
                                <groupId>org.apache.hadoop</groupId>
                                <artifactId>hadoop-core</artifactId>
                            </exclusion>
                            <exclusion>
                                <groupId>org.apache.hbase</groupId>
                                <artifactId>hbase</artifactId>
                            </exclusion>
                            <exclusion>
                                <groupId>org.apache.jmeter</groupId>
                                <artifactId>jorphan</artifactId>
                            </exclusion>
                            <exclusion>
                                <groupId>org.apache.bsf</groupId>
                                <artifactId>bsf-api</artifactId>
                            </exclusion>
                            <exclusion>
                                <groupId>org.bouncycastle</groupId>
                                <artifactId>bcmail-jdk15</artifactId>
                            </exclusion>
                            <exclusion>
                                <groupId>org.bouncycastle</groupId>
                                <artifactId>bcprov-jdk15</artifactId>
                            </exclusion>
                            <exclusion>
                                <groupId>javax.activation</groupId>
                                <artifactId>activation</artifactId>
                            </exclusion>
                            <exclusion>
                                <groupId>commons-logging</groupId>
                                <artifactId>commons-logging</artifactId>
                            </exclusion>
                        </exclusions>
                    </dependency>
                </dependencies>
            </plugin>

@Ardesco Ardesco closed this in 3fec2c7 Jan 6, 2014

Ardesco added a commit that referenced this issue Jan 6, 2014

Contributor

Ardesco commented Jan 6, 2014

Fix not confirmed yet

@Ardesco Ardesco reopened this Jan 6, 2014

Contributor

Ardesco commented Jan 8, 2014

So the fix will place everything in the lib directory, but it is unable to determine which artefacts (if any) need to be placed in the lib/ext directory. Right now meter plugins would be placed in the lib directory instead of lib/ext which is where it should be put.

This may work anyway but it's not really fixed at the moment in my opinion.

It's probably worth noting that I don't know how to fix this at the moment, we need a way to work out if an artefact is a meter plugin or not, I can't think of a sane way to do that at the moment.

@Ardesco Ardesco closed this in f34d208 Jan 9, 2014

Contributor

Ardesco commented Jan 10, 2014

The fix for #77 will add a new configuration setting that will allow you to mark explicit dependencies as meter plugins that should be in the lib/ext directory:

<jmeterPlugins>
    <plugin>
        <groupId>my.group</groupId>
        <artifactId>my.artifact</artifactId>
    </plugin>
</jmeterPlugins>

This does unfortunately mean a bit of duplication in the POM, but it's the only sane way I can come up with to do this.

Contributor

mlex commented Jan 14, 2014

This works very well. Thank you for the bugfix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment