We have an application running on websphere 8.5 and we'd like to pull the value of a custom property created using the following method in websphere admin console:
Servers->Application Servers->server1->Process Definition->Java Virtual Machine->Custom Properties -> (new)
In the code, we are trying System.getProperty("property_name") to retrieve the property but to no avail as the result is coming out null. We've seen examples online but they are only pulling websphere variables.
Has anyone encountered and fixed this issue before ? We are using this code in static block (though we don't think that it'll make a difference).
Thanks,
JVM "custom properties" in the admin console are just system properties used to start the JVM, so System.getProperty should work, but you must restart the JVM for the system properties to be used.
Related
I have a filter used for authorization. It's the first step entering application. Without it is not possible to do anything in the application.
I set a systemout on the very first line of doFilter method to monitor the behaviour, so comparing websphere server log files I'm sure that filter (same Ear deployed) on Test environment works and on Production environment not.
Maybe it's server configuration issue...?
I have access to read and modify WAS Console of test environment.
I have access only to read WAS Console of production environment.
So I can compare them, and maybe test some change on test environment to replicate the behavior and say to production administrator what exactly setup....
Any suggestion on which setting I can check (Was console, maybe in relation with Web.xml, etc...)?
Thx a lot for any suggestion.
EDIT
I was able to retrieve via FTP the EAR in InstalledApps of Production environment. I noted a file named "web_merged.xml" in which is missing the entry of the filter.
Maybe the problem is here? When is created and why? Why could be missing the entry there? How let WAS to create the right file (if the problem is there)?
The problem was the one on the EDIT in the question, webmerged.xml was wrong. We weren't able to understand why WAS generated this file in wrong way.
What I understand is generated during deploy and is a mix of web.xml of the applicatin with application server configuration.
That's a WebSphere issue, we guessed it has to do with application server cache. We asked to System Administrator to:
Uninstall the application
Stop the server in which the application was installed
Clear the cache
Restart the server
Reinstall application
From this point the file was generated in the right manner, as the application bahaviour.
Websphere version is 8.5
I've been using an embedded neo4j server in my project so far.
Now I want to try out the new bolt protocol with a standalone server, however only for my deployed application. For convenience, I still want to use an embedded database when running from IDE (permanent) or when running tests (impermanent).
In order to support this, I've migrated from the java based configuration to the use of a ogm.properties file. Depending on the environment I run in, I want to use the file which configures the respective driver/database location.
I have placed a default configuration in the root of my resources folder. However I am not able to "override" this in other environment.
In order to do that I placed a different ogm.properties in the root folder of the deployed application. This doesn't seem to work. This the mechanism that I previously already used in order to have different application.properties and logback.xml configurations.
Is this not supported by neo4j-ogm? If not, how can one achieve this? It also isn't (trivially) possible with the java based configuration.
I am a bit confused, since this doesn't sound like such an unlikely requirement...
You can use Spring Profile for this to configure different properties for different environments and you can look here.
You can use application.properties (spring.profiles.active) to load a different profile or by using a runtime argument if you are using Spring boot with CommandLineRunner.
I need to change my properties based on environment passed as argument to tomEE 6 server.
I have the following code:
String envProperties = System.getProperty("envProperties");
System.out.println("environment properties: "+envProperties);
This gets the property value that is set the first time.
When I change the property to something different than the previous one, it doesnt detect the change.
how do i get it to pick up any change being passed.
The way I am passing properties right now is by going into server run time configuration in eclipse and passing it
-DenvProperties="dev"
i tried following the post Passing JVM arguments to Tomcat when running as a service?, but i cant find anything matching Tomcat5w or ending with 5w. Please help
TomEE does not look into the Eclipse run time configuration. If you need to pass variable values to the running Java EE application, you have two options:
pull properties periodically from a resource (file, network...)
push properties from the outside using HTTP requests or other supported protocols (TCP, JMS, JMX, ...)
If a server is started with a property java.awt.headless=true
and if i set a system property in a web application with the context,say "/web_app1", like
System.setProperty("java.awt.headless","false");
and from another web app with the context "/web_app2", if i call
System.getProperty("java.awt.headless");
would it be true or false..?
The answer to your question is that if web_app2 is started while the system property of the JVM is set to true it will still be true after web_app1 has executed the setProperty method.
System properties are in the scope of the process and does not leave the boundary of the JVM. They are basically just a key-value mappings of the JVM and it's environment.
This article from the IBM Knowledge Center explains it very well.
Looking at the API for System.setProperties might be helpful.
how can i set a java_option - in my case java.util.logging.manager - per web application in weblogic ?
I cant set in globally, since weblogic logging also uses this same log manager.
I only need the logs from the web applications - to point to a different log manager.
thanks in advance. :)
You can set it in log4j for each application and have it written to different log file. You can specify the file path in log4j.appender.file.File variable