I want to create a JMSProvider object with a custom classpath. Here's how I'm doing it in jython:
...
classpath = "a.jar:b.jar:c.jar".replace(":", "\n")
properties = [
['name', name],
['description', description],
['classpath', classpath],
['externalInitialContextFactory', externalInitialContextFactory],
['externalProviderURL', externalProviderURL],
['nativepath',[]],
['supportsASF','true']
]
AdminConfig.create('JMSProvider', node, properties)
AdminConfig.save()
The JMSProvider is created, but the classpath variable has the newlines escaped:
a.jar\nb.jar\nc.jar
How can I tell wsadmin to not escape the newlines?
Whilst the WAS admin console (the web page) requires you to enter the classpath with newlines, the wsadmin tool requires that it be separated by the host O/S file separator. So there is no need to modify the input string at all.
classpath = "a.jar;b.jar;c.jar"
Will work just fine.
"\n" is a real newline.
Compare repr(classpath) immediately after classpath.replace() with the repr(classpath) that JMSProvider sees they should be the same.
Related
I'm trying to install tomcat as a service using service.bat in the following path :
C:\Program Files\text with' quote\Tomcat
but I keep getting the following error :
java.io.FileNotFoundException: C:\Program Files\text with quote\Tomcat\conf\logging.properties; (The system cannot find the path specified)
as you can see from the error message the ' is being ignored and thus keeping some files from being found/loaded properly.
If I switch to a path without a quote, everything works well. Is there a way around this as I need to include a ' in the path?
Your problem comes from the way Procrun parses its command line parameters. In those parameters which accept lists of values (++DependsOn, ++Environment, ++JvmOptions, ++JvmOptions9, ++StartParams and ++StopParams) single quotes ' are stripped after the parameter value has been split into single values. There is no way to quote them (cf. source code).
Therefore the ++JvmOptions parameter used in service.bat is interpreted as follows (one value per line):
-Dcatalina.home=C:\Scarlett oHara;-Dcatalina.base=C:\Scarlett oHara
-Dignore.endorsed.dirs=C:\Scarlett oHara\endorsed;-Djava.io.tmpdir=C:\Scarlett oHara\temp
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.util.logging.config.file=C:\Scarlett oHara\conf\logging.properties;
You might notice that some entries are joined by ;, due to the ' unintentional quoting.
The only way to fix this is to start Prunmgr (the executable renamed as tomcat*w.exe) and fix them in the "Java" tab:
-Dcatalina.home=C:\Scarlett o'Hara
-Dcatalina.base=C:\Scarlett o'Hara
-Dignore.endorsed.dirs=C:\Scarlett o'Hara\endorsed
-Djava.io.tmpdir=C:\Scarlett o'Hara\temp
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.util.logging.config.file=C:\Scarlett o'Hara\conf\logging.properties;
or work directly on the HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Apache Software Foundation\Procrun 2.0 registry keys.
See also:
a similar problem due to quoting: Adding multiple values to an environment in registry and retrieving in Java application
I have configured Zscaler NSS log forward to send logs on Linux server which is using ubuntu rsyslog service, I am able to receive logs, however, file name which getting generated it's with Special character, which is causing an issue to copy via script. Below is nss.conf file created under /etc/rsyslog.d/nss.conf
template(name="TmplMsg" type="list") {
constant(value="/rsys/log/client_logs/")
property(name="hostname")
constant(value="/")
property(name="programname" SecurePath="replace")
constant(value=".log")
}
template(name="TmplAuth" type="list") {
constant(value="/rsys/log/client_logs/")
property(name="hostname")
constant(value="/")
property(name="programname" SecurePath="replace")
constant(value=".log")
}
authpriv.* ?TmplAuth
*.info;mail.none;authpriv.none;cron.none ?TmplMsg
According to the templates doc, as well as securepath="replace", which replaces "/" in the property by "_", you can also use controlcharacters=. This can have one of 3 values:
"escape" to replace non-printing characters by #ddd (3 digit decimal value),
"drop" to remove them
or "space" to replace them by a space.
I'm learning Gradle (version 4.10 now) and i am confused with setting path using separators ':' and '/'. In which situations it's propper to use this types?
I'm not sure but it looks like colons can be used only when setting dependencies, including projects,adding tasks on the other hand slashes are used to setting paths for ex:
// works
def webappDir = "$projectDir/src/main/webapp"
// doesn't work output: home/projectName/:src:main:webapp
def webappDir = "$projectDir:src:main:webapp"
You have to use '/' character when dealing with resources of type File (as in your example): this is the standard file separator character
// path to the webapp directory
def webappDir = "$projectDir/src/main/webapp"
There are two main situations where you will use ':' character:
Project or Task paths
When working in a multi-projects build, the character ':' is used to identify a project or a task in the hierarchy : :subProject1, :subProject:taskA for example.
A project path has the following pattern: It starts with an optional colon, which denotes the root project. The root project is the only project in a path that is not specified by its name. The rest of a project path is a colon-separated sequence of project names, where the next project is a subproject of the previous project.
More information here : https://docs.gradle.org/current/userguide/multi_project_builds.html#sec:project_and_task_paths
Dependency configuration
When using the "string notation" for declaring dependencies, you will use ':' as a separator for group/module/version parts, for example: runtime 'org.springframework:spring-core:2.5' . More information about the dependency notations here: https://docs.gradle.org/current/userguide/dependency_types.html
I have an application that receives a path as a command line argument. The path can contain spaces, so it can be sended with quotes. I need to verify if this path is correct, so I execute 'exists' method from 'File' class:
public static void main (String... args) {
System.out.println("arg=" + args[0]);
File f = new File(args[0]);
System.out.println("exists=" + f.exists());
}
When I run the application with the follow arguments, I obtain this results (assume that "c:\folder" exists). Pay attention with final slash and quotes:
> java Test c:\folder
args=c:\folder
exists=true
> java Test c:\folder\
args=c:\folder\
exists=true
> java Test "c:\folder"
args=c:\folder
exists=true
> java Test "c:\folder\"
args=c:\folder
exists=false
I don't understand what's happens with last example. First in args result don't print final slash and then File class say that path doesn't exists. Second example without quotes works well.
Argument path has a free user edition, so it's possible that can include quotes (if path has folder with spaces) and a final slash.
It is not java issue but your shell. \ act as escape character if it is used before " in Windows. To work around that you can write parameter as "c:\folder\\"
It is also strange output. When i did the same I got args=c:\folder" in last case.
i have a little problem with my jmeter test plan.
i have a jdbc request to extract customers in sql databases
from this sql query i retrieve first name and last name only
after that i have a beanshell little script to write all my customers in a csv file :
f = new FileOutputStream(vars.get("InputFilePath"));
p = new PrintStream(f);
nb_customer=Integer.parseInt(vars.get("NOM_#"));
for (i=1;i<=nb_customer;i++) {
p.println(vars.get("NOM_"+i) + ";" + vars.get("PRENOM_"+i));
}
p.close();
f.close();
my problem is that it is an application for our subsidiary company in polska
so, all customers first and last name are in polish language with different symbol, characters.
in the csv file, they appears with a ? in spite of the real character.
can you help me please ?
thanks a lot
Ludo
Try explicitly setting encoding to UTF-8, initialize PrintStream as:
p = new PrintStream(f, true, "UTF-8");
Check out JMeter default encoding as:
log.info(System.getProperty("file.encoding"));
If output is different from UTF-8 add the next line to system.properties file (lives under /bin folder of your JMeter installation:
file.encoding=UTF-8
and restart JMeter. Alternatively you can pass it via -D command line argument like:
jmeter -Dfile.encoding=UTF-8
See Apache JMeter Properties Customization Guide for more information on Jmeter properties and ways of setting and overriding them.
Check file contents in JMeter itself by using FileUtils.readFileToString() method like: