Groovy not reading jar files in .groovy/lib - jdbc

I'm having a problem with jar files and groovy. For a few specific examples I'm trying to connect to a postgresql database and when using
sql = Sql.newInstance("jdbc:postgresql://localhost", "user", "pass", "org.postgresql.Driver")
I get a ClassNotFound exception for org.postgresql.Driver. I have the postgresql jar in my ${user.home}/.groovy/lib, and the line to load from there in the groovy-starter.conf is not commented out. I'm also having a similar problem with a dbunit.jar file.
If I try to manually add the classpath using groovy -cp I'm getting an error that says
Caught: java.io.UnsupportedEncodingException: p
Any ideas?

According to the CLI Help - http://groovy.codehaus.org/Groovy+CLI:
$groovy -help
usage: groovy
-a,--autosplit <splitPattern> automatically split current line
(defaults to '\s')
-c,--encoding <charset> specify the encoding of the files
-e <script> specify a command line script
-h,--help usage information
-i <extension> modify files in place
-l <port> listen on a port and process inbound lines
-n process files line by line
-p process files line by line and print result
-v,--version display the Groovy and JVM versions
groovy -cp will tell groovy to load characterset p which does not exist.
Your attempt to use ${user.home}/.groovy/lib should have worked assuming you used the correct path for ${user.home}. If you add info on your OS we might see if you got it right or not.
As a WA - just export the CLASSPATH environment variable to wherever the jars are located.
Windows: set CLASSPATH=c:\temp\postgresql.jar;c:\temp\dbunit.jar ...
Unix/Linux (KSH): export CLASSPATH=${HOME}/temp/postgresql.jar:${TEMP}/temp/dbunit.jar ...

Related

Partial data is getting generated in html report

jtl file contains 2 testcase but when i generate html report using the same only the data of latest entry is populating in html report,
Command used for Report generation:
sh jmeter.sh -g /home/sadha/Documents/apache-jmeter-5.4.1/logs/log.jtl -f -o /home/sadha/Documents/apache-jmeter-5.4.1/bin/Output/
Getting below message in terminal after executing above command,
File '/home/sadha/Documents/apache-jmeter-5.4.1/logs/log.jtl' does not contain the field names header, ensure the jmeter.save.saveservice.* properties are the same as when the CSV file was created or the file may be read incorrectly when generating report
JTL data:
1619015828359,121,aws_sns,200,,Thread2 2-1,text,true,,422,592,1,1,http://10.77.2.208:8080/graphql,117,0,66
1619015831675,137,solutionsinfini,200,,Thread2 2-1,text,true,,422,600,1,1,http://10.77.2.208:8080/graphql,130,0,65
Below is the screenshot of html report
You need to have the same Results File Configuration for JMeter instance(s) which:
run the test
generate the reporting dashboard
any inconsistencies will result in failure or data loss
Particularly in your case the "problematic" property which doesn't match is jmeter.save.saveservice.print_field_names, try modifying your command to set this property to false via -J command-line argument as:
sh jmeter.sh -Jjmeter.save.saveservice.print_field_names=false -g /home/sadha/Documents/apache-jmeter-5.4.1/logs/log.jtl -f -o /home/sadha/Documents/apache-jmeter-5.4.1/bin/Output/
in order to make the change permanent put the following line to user.properties file of your JMeter installation:
jmeter.save.saveservice.print_field_names=false
More information:
Configuring JMeter
Overriding Properties Via The Command Line
Apache JMeter Properties Customization Guide

maven archetype copy shell script having its own variable

I am trying to create project structure by using archetype as below.
mvn archetype:generate
-DarchetypeGroupId=com.td.abc.myplatform
-DarchetypeArtifactId=my-custom-archetype
-DarchetypeVersion=1.0.0-SNAPSHOT
-DgroupId=com.abc.myplatform.muntjac
-DartifactId=muntjac
-Dversion=1.0.0-SNAPSHOT
-DappName=muntjac
The archetype also copies some of the shell script which is having few lines as below.
my-shell.sh (part of my-shell.sh)
Line#1 RPM_PACKAGE_NAME="${appName}"
Line#2 RPM_PACKAGE_VERSION="1.0.0"
Line#3 RPM_PACKAGE_RELEASE="1"
Line#4 REVISION_VERSION="${BUILD_NUMBER}_${BUILD_VCS_NUMBER:0:8}"
However the archetype generation fails due to my shell script variable ${BUILD_VCS_NUMBER:0:8} by saying syntax error expected { or ( instead of :
Is there anyway I can make this work without modifying my shell script?
I don't think you can make it work without modifying your script.
I replaced every $ character in resource files with ${dollar}.
And added this on top of pom.xml: #set($dollar = '$')

Use fmpp command line parameter in template

I have some configuration templates which use FMPP to generate the
real runtime config files based upon info in a csv and properties
file (defined in config.fmpp).
I want to be able to configure a second cluster server for the same task using the same set of templates and config.fmpp information. However, there are slight differences needed in the generated runtime config and I can do this if I know which server instance I am on ("serverA" or "serverB") using a standard fmpp variable like ${myserver}.
But there must only be one set of templates and FMPP config files so I need to somehow get the value of "myserver" from the runtime
environment in each server.
Some of the options I might have are:
pass value of myserver on the command line tool invocation (best way); or
get it from an environment variable.
Does anyone have an example of the code to do any of these and any suggestions of the best approach? Online reference would be great.
fmpp -S /home/me/sample-project/src -Param myserver:serverA
Environment settings:
fmpp v0.9.14
freemarker v2.3.19
Use the -D command line option (see --help):
-D, --data=<TDD> Creates shared data that all templates will see. <TDD> is the
Textual Data Definition, e.g.:
-D "properties(style.properties), onLine:true"
Note that paths like "style.properties" are relative to the
data root directory.
Like:
fmpp -S /home/me/sample-project/src -D myserver:serverA
Note that there's a space after the -D. (It's not like the java command line syntax, but rather like the standard GNU command line syntax.
This -D has nothing to do with Java's -D option.
The documentation shows onLine:true, but such Boolean values are legacy and no longer accepted. Use online:yes to parse Boolean values.
For example:
fmpp \
-S /path/ \
--verbose \
-D "online:yes"
Then, within the template:
<p>
online: ${online}
</p>
Will result in:
online: yes
The --verbose command-line parameter is useful to show any errors when parsing the template.

JMeter: How to specify the users.csv file in the command line

When using JMeter from the command line, I get the following error in my log:
2014/08/05 14:29:43 ERROR - jmeter.config.CSVDataSet: java.io.FileNotFoundException:
/home/stew/YOU_FORGOT_TO_SPECIFY_USERS_CSV_FILE.csv (No such file or directory)
The user.csv file is in the same directory as the testplan.jmx file. Is there an option to specify the file in the command line?
Regards,
Wolf
If you use relative file name for path then it should work, as per reference documentation:
Filename Name of the file to be read. Relative file names are resolved with respect to the path of the active test plan. For distributed testing, the CSV file must be stored on the server host system in the correct relative directory to where the jmeter server is started.
For another solution, Have a look at :
http://jmeter.apache.org/usermanual/functions.html#__P
You use this function in CSV dataset :
${__P(resdir)}
and on command line:
-Jresdir=your path to csv file
I was using Jmeter to test load Moodle and used options -Jresdir and -Jusersfile options to pass usersfile name

How to install tomcat with a specific PATH under Windows?

I have the following Code:
tomcat5.exe //IS//%SERVICE_NAME% --StartPath "%BASE_DIR%\bin" --Jvm "%JAVA_HOME%\bin\%JAVA_MODE%\jvm.dll" --StartClass org.apache.catalina.startup.Bootstrap --StopClass org.apache.catalina.startup.Bootstrap --StartParams "-config;%CONFIG%;start" --StopParams stop --Startup auto
tomcat5.exe //US//%SERVICE_NAME% --JvmOptions "-Dcatalina.base=%CATALINA_BASE%#-Dcatalina.home=%CATALINA_HOME%#-Djava.endorsed.dirs=%CATALINA_HOME%\common\endorsed#-Xrs#-Djava.library.path=%DLL_DIR%#-DimageservicePath=%imageservicePath%" --StartMode jvm --StopMode jvm
tomcat5.exe //US//%SERVICE_NAME% ++JvmOptions "-Djava.io.tmpdir=%CATALINA_BASE%\temp"
tomcat5.exe //US//%SERVICE_NAME% --JvmMx %MEMORY% --JvmMs %MIN_MEMORY%
tomcat5.exe //US//%SERVICE_NAME% --Environment "PATH=.\;c:\path\bin"
I need to specify a special PATH, because some native-code loading issues.
My problem is, that the service-installer will change provided PATH:
http://tomcat.apache.org/tomcat-5.5-doc/windows-service-howto.html
--Environment
List of environment variables that will be provided to the service in the form key=value. They are separated using either # or ; characters
I need to specify a Windowes PATH with two locations: PATH=.;c:\path\bin
The path will be stored within the registry:
PATH=.
c:\path\bin
it should be:
PATH=.;c:\path\bin
It works as described, so I think I missed something, but I did not find anything about how to set the PATH and solve this issue...
PS:
I know I'm using an outdated version of tomcat.
Well, after I downloaded the source and figured out, that the apache-commons procrun deamon is used and I finally found the solution. The documentation at the tomcat project wasn't complete:
http://commons.apache.org/daemon/procrun.html
++Environment
List of environment variables that will be provided to the service in the form key=value. They are separated using either # or ; characters. If you need to embed either # or ; character within a value put them inside single quotes.
The last sentence lead to the solution:
"%EXECUTABLE%" //US//%SERVICE_NAME% --Environment "PATH='%PATH%'"

Resources