Add several properties in a custom resource in GlassFish - glassfish

I need to add a JNDI custom resource in GlassFish of class Properties that has several properties. I need to do that with the command line. This is what I am using to create the custom resource with one parameter:
asadmin create-custom-resource --restype=java.util.Properties --factoryclass=org.glassfish.resources.custom.factory.PropertiesFactory --property param1="this is param1" my.parameter.name
But what I want is to add more than one property. I have tried to do this but it doesn't work:
asadmin create-custom-resource --restype=java.util.Properties --factoryclass=org.glassfish.resources.custom.factory.PropertiesFactory --property param1="this is param1" param2="this is param2" my.parameter.name
I don't need to create all the parameters in one command, if there is a way to add the properties after creating the first, would also work for me.
I know I can go to the admin console, edit the custom resource and add the new property there, but I need to do it with the command line.

I found the solution:
asadmin create-custom-resource --restype=java.util.Properties --factoryclass=org.glassfish.resources.custom.factory.PropertiesFactory --property "param1=\"this is param1+":param2=\"this is param2\" my.parameter.name

Related

How to use kafka-avro-console-producer ?

If I use 'kafka-console-producer' - it automatically picks up JASS file and runs normally (can produce to a remote topic).
If I use 'kafka-avro-console-producer' with exact same configuration but with added schema property - it complains about JASS configuration:
'Could not find a 'KafkaClient' entry in the JAAS configuration. System property 'java.security.auth.login.config' is not set'
How to make it working?
Please look into these blogs, you will know that how can you update your security and how can you add property to procedure.
Authentication using SASL
secure-kafka-java-producer-with-kerberos

Set security policy on JNDI root using WLST (Weblogic)

Can WLST be used to set a security policy on the root of the JNDI tree?
Alternatively, can this be done during installation?
We are trying to remove the everyone policy currently on the root of the JNDI by default as it is a security requirement. We want to replace it with a role/group of our choosing. I have tried exporting the realm settings, which appear to include the setting of the jndi, but including this on the install seems to have no affect.
Pretty new to weblogic, so if any other info would help, please add a comment and i'll share what i can!!
Remove the existing policy that covers type=<jndi> then add a replacement
cd("/SecurityConfiguration/MyDomain/Realms/My-Realm/Authorizers/XACMLAuthorizer")
cmo.removePolicy("type=<jndi>")
cmo.createPolicy("type=<jndi>", "Rol(Admin)")
For reference, the below removes the default lookup action on the jms part of the tree, replacing it with the allow everyone option. Wasn't asked in the question, but might be useful for any else struggling with WLST and security policies!
cmo.removePolicy("type=<jndi>, application=, path={jms}, action=lookup")
cmo.createPolicy("type=<jndi>, application=, path={jms}, action=lookup", "?weblogic.entitlement.rules.UncheckedPolicy()")

how to add db directory to web.xml

I have a java web app configured with apache v9.0 and eclipse IDE. What I need is to keep my database in C:\db so It cannot be access directly from outside and should be away from my webapp project directory. What I don't is how to let my web app know that if a user request for a file it should go and check it in my C:\db and reply back with the file.
Based in my research, some was saying to specify my directory in my webapp web.xml file and others was saying I need to specify it in my tomcat/conf/server.xml file.
I'd really appreciate if somebody tell me what to do?
Try adding your database path C:\db as JVM argument and accessing it in application. you may try this as two ways either set as system property and access when it required or set as JVM argument and access it.
SetSystemProperties
System.setProperty("database", "C:\\db");
.
.
access it as and when required
String databasepath= System.getProperty("database");
Setting as JVM Arguments.
Double Click on your tomcat server on which your web application is present.
Click on "Open launch configuration" link and go to Arguments Tab.
in vmArguments apend the entry like below.
-Ddatabase="C:\db"
A -D is placed in front of each system property that we are passing in as a VM argument, and following this is an equal sign followed by the value of that system property.
And access it in your project where its required like below.
String databasepath= System.getProperty("database");

How do I add a JNDI entry called "properties" in Glassfish on startup without using the admin?

In the code for our project there is this line:
(Properties) new InitialContext().lookup("properties")
One of the other developers said I had to add the entry through the admin for my instance of Glassfish. Having to use the admin to do this seemed suspect to me. Isn't there a way to add a JNDI entry at startup in web.xml, or something similar?
I think the idea here is that it must be done via the admin application so that the values aren't embedded in the application.

How do I configure my nhibernate project to use memcached in the hibernate.cfg.xml?

I am trying to configure the hibernate.cfg.xml file to use memcache. I see the properties
"cache.provider_class" and "cache.use_second_level_cache" however I do not see how I can add the server host/port.
You'd set those properties in the <memcache> settings.
See this question for an example.