View | Details | Raw Unified | Return to bug 55503
Collapse All | Expand All

(-)src/core/org/apache/jmeter/JMeter.java (-9 / +15 lines)
Lines 403-413 Link Here
403
403
404
    // Update classloader if necessary
404
    // Update classloader if necessary
405
    private void updateClassLoader() {
405
    private void updateClassLoader() {
406
            updatePath("search_paths",";"); //$NON-NLS-1$//$NON-NLS-2$
406
            updatePath("search_paths",";", true); //$NON-NLS-1$//$NON-NLS-2$
407
            updatePath("user.classpath",File.pathSeparator);//$NON-NLS-1$
407
            updatePath("user.classpath",File.pathSeparator, true);//$NON-NLS-1$
408
            updatePath("plugin_dependency_paths",";", false);//$NON-NLS-1$
408
    }
409
    }
409
410
410
    private void updatePath(String property, String sep) {
411
    private void updatePath(String property, String sep, boolean cp) {
411
        String userpath= JMeterUtils.getPropDefault(property,"");// $NON-NLS-1$
412
        String userpath= JMeterUtils.getPropDefault(property,"");// $NON-NLS-1$
412
        if (userpath.length() <= 0) { return; }
413
        if (userpath.length() <= 0) { return; }
413
        log.info(property+"="+userpath); //$NON-NLS-1$
414
        log.info(property+"="+userpath); //$NON-NLS-1$
Lines 418-428 Link Here
418
            if (!f.canRead() && !f.isDirectory()) {
419
            if (!f.canRead() && !f.isDirectory()) {
419
                log.warn("Can't read "+path);
420
                log.warn("Can't read "+path);
420
            } else {
421
            } else {
421
                log.info("Adding to classpath: "+path);
422
                if (cp) {
422
                try {
423
                    log.info("Adding to classpath and loader: "+path);
423
                    NewDriver.addPath(path);
424
                    try {
424
                } catch (MalformedURLException e) {
425
                        NewDriver.addPath(path);
425
                    log.warn("Error adding: "+path+" "+e.getLocalizedMessage());
426
                    } catch (MalformedURLException e) {
427
                        log.warn("Error adding: "+path+" "+e.getLocalizedMessage());
428
                    }
429
                } else {
430
                    log.info("Adding to loader: "+path);
431
                    NewDriver.addURL(path);
426
                }
432
                }
427
            }
433
            }
428
        }
434
        }
Lines 1175-1178 Link Here
1175
1181
1176
        return socket;
1182
        return socket;
1177
    }
1183
    }
1178
}
1184
}
(-)src/core/org/apache/jmeter/NewDriver.java (+33 lines)
Lines 152-157 Link Here
152
        } catch (MalformedURLException e) {
152
        } catch (MalformedURLException e) {
153
            e.printStackTrace();
153
            e.printStackTrace();
154
        }
154
        }
155
        if (furl.exists() && furl.isDirectory()) {
156
            File[] jars = furl.listFiles(new FilenameFilter() {
157
                @Override
158
                public boolean accept(File f, String name) {
159
                    return name.endsWith(".jar") && (new File(f, name)).isFile();// $NON-NLS-1$
160
                }
161
            });
162
            for (int x = 0; x < jars.length; x++) {
163
                try {
164
                    loader.addURL(jars[x].toURI().toURL()); // See Java bug 4496398
165
                } catch (MalformedURLException e) {
166
                    e.printStackTrace();
167
                }
168
            }
169
        }
155
    }
170
    }
156
171
157
    /**
172
    /**
Lines 179-184 Link Here
179
        StringBuilder sb = new StringBuilder(System.getProperty(JAVA_CLASS_PATH));
194
        StringBuilder sb = new StringBuilder(System.getProperty(JAVA_CLASS_PATH));
180
        sb.append(CLASSPATH_SEPARATOR);
195
        sb.append(CLASSPATH_SEPARATOR);
181
        sb.append(path);
196
        sb.append(path);
197
        if (file.exists() && file.isDirectory()) {
198
            File[] jars = file.listFiles(new FilenameFilter() {
199
                @Override
200
                public boolean accept(File f, String name) {
201
                    return name.endsWith(".jar") && (new File(f, name)).isFile();// $NON-NLS-1$
202
                }
203
            });
204
            for (int x = 0; x < jars.length; x++) {
205
                try {
206
                    loader.addURL(jars[x].toURI().toURL()); // See Java bug 4496398
207
                    sb.append(CLASSPATH_SEPARATOR);
208
                    sb.append(jars[x].getPath());
209
                } catch (MalformedURLException e) {
210
                    e.printStackTrace();
211
                }
212
            }
213
        }
214
182
        // ClassFinder needs this
215
        // ClassFinder needs this
183
        System.setProperty(JAVA_CLASS_PATH,sb.toString());
216
        System.setProperty(JAVA_CLASS_PATH,sb.toString());
184
    }
217
    }
(-)bin/jmeter.properties (-9 / +26 lines)
Lines 912-929 Link Here
912
# Classpath configuration
912
# Classpath configuration
913
#---------------------------------------------------------------------------
913
#---------------------------------------------------------------------------
914
914
915
# List of paths (separated by ;) to search for additional JMeter extension classes
915
# List of paths (separated by ;) to search for additional JMeter plugin classes,
916
# - for example new GUI elements and samplers
916
# for example new GUI elements and samplers.
917
# These are in addition to lib/ext. Do not use this for utility jars.
917
# A path item can either be a jar file or a directory.
918
# Any jar file directly located in such a directory will be automatically included.
919
# The given value is in addition to any jars found in the lib/ext directory.
920
# Do not use this for utility ir plugin dependecy jars.
918
#search_paths=/app1/lib;/app2/lib
921
#search_paths=/app1/lib;/app2/lib
919
922
920
# Users can define additional classpath items by setting the property below
923
# List of paths that JMeter will search for utility and plugin dependency classes.
921
# - for example, utility jars or JUnit test cases
924
# Use your platform path separator to separate multiple paths.
922
#
925
# A path item can either be a jar file or a directory.
923
# Use the default separator for the host version of Java
926
# Any jar file directly located in such a directory will be automatically included.
927
# The given value is in addition to any jars found in the lib directory.
928
# All entries will be added to the class path of the system class loader
929
# and also to the path of the JMeter internal loader.
924
# Paths with spaces may cause problems for the JVM
930
# Paths with spaces may cause problems for the JVM
925
#user.classpath=../classes;../jars/jar1.jar
931
#user.classpath=../classes;../lib;../app1/jar1.jar;../app2/jar2.jar
926
932
933
# List of paths (separated by ;) that JMeter will search for utility
934
# and plugin dependency classes.
935
# A path item can either be a jar file or a directory.
936
# Any jar file directly located in such a directory will be automatically included.
937
# The given value is in addition to any jars found in the lib directory
938
# or given by the user.classpath property.
939
# All entries will be added to the path of the JMeter internal loader only.
940
# For plugin dependencies using plugin_dependency_paths should be preferred over
941
# user.classpath.
942
#plugin_dependency_paths=../dependencies/lib;../app1/jar1.jar;../app2/jar2.jar
943
927
# Classpath finder
944
# Classpath finder
928
# ================
945
# ================
929
# The classpath finder currently needs to load every single JMeter class to find
946
# The classpath finder currently needs to load every single JMeter class to find
Lines 952-955 Link Here
952
969
953
# Comma separated list of files that contain reference to templates and their description
970
# Comma separated list of files that contain reference to templates and their description
954
# Path must be relative to jmeter root folder
971
# Path must be relative to jmeter root folder
955
#template.files=/bin/templates/templates.xml
972
#template.files=/bin/templates/templates.xml
(-)bin/user.properties (-8 / +25 lines)
Lines 19-36 Link Here
19
# Classpath configuration
19
# Classpath configuration
20
#---------------------------------------------------------------------------
20
#---------------------------------------------------------------------------
21
#
21
#
22
# List of paths (separated by ;) to search for additional JMeter extension classes
22
# List of paths (separated by ;) to search for additional JMeter plugin classes,
23
# - for example new GUI elements and samplers
23
# for example new GUI elements and samplers.
24
# These are in addition to lib/ext. Do not use this for utility jars.
24
# A path item can either be a jar file or a directory.
25
# Any jar file directly located in such a directory will be automatically included.
26
# The given value is in addition to any jars found in the lib/ext directory.
27
# Do not use this for utility ir plugin dependecy jars.
25
#search_paths=/app1/lib;/app2/lib
28
#search_paths=/app1/lib;/app2/lib
26
29
27
# Users can define additional classpath items by setting the property below
30
# List of paths that JMeter will search for utility and plugin dependency classes.
28
# - for example, utility jars or JUnit test cases
31
# Use your platform path separator to separate multiple paths.
29
#
32
# A path item can either be a jar file or a directory.
30
# Use the default separator for the host version of Java
33
# Any jar file directly located in such a directory will be automatically included.
34
# The given value is in addition to any jars found in the lib directory.
35
# All entries will be added to the class path of the system class loader
36
# and also to the path of the JMeter internal loader.
31
# Paths with spaces may cause problems for the JVM
37
# Paths with spaces may cause problems for the JVM
32
#user.classpath=../classes;../jars/jar1.jar
38
#user.classpath=../classes;../lib;../app1/jar1.jar;../app2/jar2.jar
33
39
40
# List of paths (separated by ;) that JMeter will search for utility
41
# and plugin dependency classes.
42
# A path item can either be a jar file or a directory.
43
# Any jar file directly located in such a directory will be automatically included.
44
# The given value is in addition to any jars found in the lib directory
45
# or given by the user.classpath property.
46
# All entries will be added to the path of the JMeter internal loader only.
47
# For plugin dependencies using plugin_dependency_paths should be preferred over
48
# user.classpath.
49
#plugin_dependency_paths=../dependencies/lib;../app1/jar1.jar;../app2/jar2.jar
50
34
#---------------------------------------------------------------------------
51
#---------------------------------------------------------------------------
35
# Logging configuration
52
# Logging configuration
36
#---------------------------------------------------------------------------
53
#---------------------------------------------------------------------------
(-)xdocs/changes.xml (+9 lines)
Lines 107-112 Link Here
107
107
108
<h4>* ModuleController has been improved to better handle changes to referenced controllers</h4>
108
<h4>* ModuleController has been improved to better handle changes to referenced controllers</h4>
109
109
110
<h4>* Improved class loader configuration</h4>
111
<p>
112
<ul>
113
<li>New property "plugin_dependency_paths" for plugin dependencies</li>
114
<li>Properties "search_paths", "user.classpath" and "plugin_dependency_paths"
115
    now automatically add all jars form configured directories</li>
116
</ul>
117
</p>
118
110
<h4>* Best-practices section has been improved, ensure you read it to get the most out of JMeter</h4>
119
<h4>* Best-practices section has been improved, ensure you read it to get the most out of JMeter</h4>
111
120
112
<h3><u>GUI and ergonomy Improvements:</u></h3>
121
<h3><u>GUI and ergonomy Improvements:</u></h3>
(-)xdocs/usermanual/component_reference.xml (-3 / +7 lines)
Lines 5569-5581 Link Here
5569
</p>
5569
</p>
5570
<p>
5570
<p>
5571
Test plan now provides an easy way to add classpath setting to a specific test plan. 
5571
Test plan now provides an easy way to add classpath setting to a specific test plan. 
5572
The feature is additive, meaning that you can add jar files or directories, but removing an entry requires restarting JMeter.
5572
The feature is additive, meaning that you can add jar files or directories,
5573
but removing an entry requires restarting JMeter.
5573
Note that this cannot be used to add JMeter GUI plugins, because they are processed earlier.
5574
Note that this cannot be used to add JMeter GUI plugins, because they are processed earlier.
5574
However it can be useful for utility jars such as JDBC drivers. 
5575
However it can be useful for utility jars such as JDBC drivers. The jars are only added to
5576
the search path for the JMeter loader, not for the system class loader.
5575
</p>
5577
</p>
5576
<p>
5578
<p>
5577
JMeter properties also provides an entry for loading additional classpaths.
5579
JMeter properties also provides an entry for loading additional classpaths.
5578
In jmeter.properties, edit "user.classpath" to include additional libraries.
5580
In jmeter.properties, edit "user.classpath" or "plugin_dependency_paths" to include additional libraries.
5581
See <a href="get-started.html#classpath">JMeter's Classpath</a> and
5582
<a href="get-started.html#configuring_jmeter">Configuring JMeter</a> for details.
5579
</p>
5583
</p>
5580
</description>
5584
</description>
5581
</component>
5585
</component>
(-)xdocs/usermanual/get-started.xml (-11 / +36 lines)
Lines 257-277 Link Here
257
<p>JMeter automatically finds classes from jars in the following directories:</p>
257
<p>JMeter automatically finds classes from jars in the following directories:</p>
258
<ul>
258
<ul>
259
<li>JMETER_HOME/lib - used for utility jars</li>
259
<li>JMETER_HOME/lib - used for utility jars</li>
260
<li>JMETER_HOME/lib/ext - used for JMeter components and add-ons</li>
260
<li>JMETER_HOME/lib/ext - used for JMeter components and plugins</li>
261
</ul>
261
</ul>
262
<p>If you have developed new JMeter components,
262
<p>If you have developed new JMeter components,
263
then you should jar them and copy the jar into JMeter's <b>lib/ext</b> directory.
263
then you should jar them and copy the jar into JMeter's <b>lib/ext</b> directory.
264
JMeter will automatically find JMeter components in any jars found here.
264
JMeter will automatically find JMeter components in any jars found here.
265
Do not use lib/ext for utility jars or dependency jars used by the plugins;
266
it is only intended for JMeter components and plugins.
265
</p>
267
</p>
266
<p>Support jars (libraries etc) should be placed in the <b>lib</b> directory.</p>
268
<p>If you don't want to put JMeter plugin jars in the <b>lib/ext</b> directory,
267
268
<p>If you don't want to put JMeter extension jars in the <b>lib/ext</b> directory,
269
then define the property <b>search_paths</b> in jmeter.properties.
269
then define the property <b>search_paths</b> in jmeter.properties.
270
Do not use lib/ext for utility jars; it is only intended for JMeter components.
271
</p>
270
</p>
271
<p>Utility and dependency jars (libraries etc) can be placed in the <b>lib</b> directory.</p>
272
<p>If you don't want to put such jars in the <b>lib</b> directory,
273
then define the property <b>user.classpath</b> or <b>plugin_dependency_paths</b>
274
in jmeter.properties. See below for an explanation of the differences.
275
</p>
272
<p>
276
<p>
273
Other jars (such as JDBC, JMS implementations and any other support libaries needed by the JMeter code)
277
Other jars (such as JDBC, JMS implementations and any other support libaries needed by the JMeter code)
274
 should be placed in the <b>lib</b> directory - not the <b>lib/ext</b> directory</p>
278
should be placed in the <b>lib</b> directory - not the <b>lib/ext</b> directory,
279
or added to <b>user.classpath</b>.</p>
275
<p>Note: JMeter will only find .jar files, not .zip.</p>
280
<p>Note: JMeter will only find .jar files, not .zip.</p>
276
<p>You can also install utility Jar files in $JAVA_HOME/jre/lib/ext, or you can set the property <b>user.classpath</b> in jmeter.properties</p>
281
<p>You can also install utility Jar files in $JAVA_HOME/jre/lib/ext, or you can set the property <b>user.classpath</b> in jmeter.properties</p>
277
<p>Note that setting the CLASSPATH environment variable will have no effect.
282
<p>Note that setting the CLASSPATH environment variable will have no effect.
Lines 543-556 Link Here
543
  You may list their classname or their class label (the string that appears
548
  You may list their classname or their class label (the string that appears
544
  in JMeter's UI) here, and they will no longer appear in the menus.</property>
549
  in JMeter's UI) here, and they will no longer appear in the menus.</property>
545
  <property name="search_paths">
550
  <property name="search_paths">
546
  List of paths (separated by ;) that JMeter will search for JMeter add-on classes;
551
  List of paths (separated by ;) that JMeter will search for JMeter plugin classes,
547
  for example additional samplers.
552
  for example additional samplers. A path item can either be a jar file or a directory.
548
  This is in addition to any jars found in the lib/ext directory.
553
  Any jar file directly located in such a directory will be automatically included
554
  in search_paths.
555
  The given value is in addition to any jars found in the lib/ext directory.
549
  </property>
556
  </property>
550
  <property name="user.classpath">
557
  <property name="user.classpath">
551
  List of paths that JMeter will search for utility classes.
558
  List of paths that JMeter will search for utility and plugin dependency classes.
552
  This is in addition to any jars found in the lib directory.
559
  Use your platform path separator to separate multiple paths.
560
  A path item can either be a jar file or a directory.
561
  Any jar file directly located in such a directory will be automatically included
562
  in user.classpath.
563
  The given value is in addition to any jars found in the lib directory.
564
  All entries will be added to the class path of the system class loader
565
  and also to the path of the JMeter internal loader.
553
  </property>
566
  </property>
567
  <property name="plugin_dependency_paths">
568
  List of paths (separated by ;) that JMeter will search for utility
569
  and plugin dependency classes.
570
  A path item can either be a jar file or a directory.
571
  Any jar file directly located in such a directory will be automatically included
572
  in plugin_dependency_paths.
573
  The given value is in addition to any jars found in the lib directory
574
  or given by the user.classpath property.
575
  All entries will be added to the path of the JMeter internal loader only.
576
  For plugin dependencies using plugin_dependency_paths should be preferred over
577
  user.classpath.
578
  </property>
554
  <property name="user.properties">
579
  <property name="user.properties">
555
  Name of file containing additional JMeter properties. 
580
  Name of file containing additional JMeter properties. 
556
  These are added after the initial property file, but before the -q and -J options are processed.
581
  These are added after the initial property file, but before the -q and -J options are processed.

Return to bug 55503