How to edit web.xml context param in Websphere console - websphere

I have made a web application to be deployed in the Websphere server but i came up with a problem.
I have 20 servlets that use a common parameter so i have this declared on web.xml:
<context-param>
<param-name>filePath</param-name>
<param-value>C:\logs.txt</param-value>
</context-param>
I want this parameter to be easily edited in the Websphere console but doesn't work. I know this works on Tomcat but is there anything equivalent on websphere?
Thanks

You should edit web.xml only on the server, there is know interface for it in the Console, as I remember.
You can find this file here:{WAS_ROOT}/profiles/profilename/config/cells/cellname/applications/enterpriseappname/deployments/deployedname/webmodulename
Link to the documentation:
http://www-01.ibm.com/support/knowledgecenter/SSEQTP_8.5.5/com.ibm.websphere.base.doc/ae/tweb_jsfengine.html

Related

How to configure logback context-param using jHipster?

Fact 1: in this answer it is mentioned that the web.xml file has been replaced by the (generated) WebConfigurer class.
Fact 2: in the logback documentation it is explained that, in order to avoid the logback facility shutting down before the application shutdown is completed, which would cause loss of logging messages, the web.xml file should be edited by adding the following stanza:
<web-app>
<context-param>
<param-name>logbackDisableServletContainerInitializer</param-name>
<param-value>true</param-value>
</context-param>
</web-app>
Putting it all together, how can I set this configuration parameter while using jHipster?
Bonus question(s): how are the contents of the web.xml file mapped to the WebConfigurer class's contents? Can the WebConfigurer be customized during the generation phase, or should it be edited manually after generation?
As reported in the answer to this question, the web.xml file can be found (and edited) in the "src/main/webapp/WEB-INF" folder, although it is discouraged to use it. However, there does not seem to be another way to operate in this case.

How do I find out where the page loading fails in my jsf page?

I'm trying to migrate an application from wildfly 9.0.1 to wildfly 10.1 and when I try to access the page I get this error.
The only component I could think of in my page related to it is a selectManyCheckbox maybe but I can't find anything that tries to render an "enable" string.
As it turns out it was a property set in my web.xml to blame:
<context-param>
<param-name>org.richfaces.enableControlSkinning</param-name>
<param-value>enable</param-value>
</context-param>

Jetty spring profile programmatically

I'm looking for a way to set spring profile in jetty programmatically so that the application that the war file on the server used the given profile, this is my code:
final WebAppContext context = new WebAppContext();
context.setLogUrlOnStart(true);
context.setWar("target/deployables/myapp-rest/myapp-rest.war");
context.setContextPath("/" + TEST_APP_CONTEXT);
context.setParentLoaderPriority(true);
server.setHandler(context);
server.start();
I tried a couple of things but none of them seem to work... I need to pass -Dspring.profiles.active=myProfile
This is tested with Jetty 9.3 but webdefault.xml seem to also be available for lower versions (it's placement might be different though).
Go to $JETTY_HOME/etc and open webdefault.xml. Search for context-param in the file. Add this code somewhere below:
<context-param>
<param-name>spring.profiles.default</param-name>
<param-value>prod</param-value>
</context-param>
This will work if your web.xml (in the your-app.war file) doesn't contain this context-param.
Otherwise you could also use override-web.xml (docs) but you would need to configure it in jetty-web.xml and jetty-web.xml must be bundled inside the war... So YMMV, but I didn't want to change my war and webdefault.xml is an easier solution for me.

Setup bootstrup file in java web application

I read about bootstrapping here. How can I setup bootstrup file in my web application written with jsf,spring and hibernate.Is it necessary to setup bootstrup file in my application?
Java web applications are "bootstrapped" by the web container in which they are run (e.g. Tomcat) and you don't have to do it yourself.
However, if you want to add additional operations to be executed when the application is started up (and/or clean-up operations to be executed when the application is shut down), the servlet API provides the "context listener" mechanism.
Basically, you have to create a class that implements javax.servlet.ServletContextListener which has 2 methods, contextInitialized and contextDestroyed, that are executed when the application is started up, respectively shut down.
You must then add configure this class in web.xml, with something like that :
<listener>
<description>My Context listener</description>
<display-name>My Context listener</display-name>
<listener-class>
com.acme.myapp.MyContextListener
</listener-class>
</listener>
(Or in JEE6 you could use the javax.servlet.annotation.WebListener annotation instead of XML)
Google is you friend for the details, but here are some links to start with :
http://www.roseindia.net/servlets/ServletContextListener-example.shtml
http://docs.oracle.com/javaee/5/tutorial/doc/bnafi.html

Set log4j file path param in execution time

In Spring I have slf4j with log4j to resolve logging.
I put relative path in log4j.xml configuration, but when i execute app in Netbeans Tomcat and independent Apache Tomcat, relative path is different, and I must change manually.
My idea is obtain context realpath from Spring Controller and set it in log4j configuration in execution time. But I dont know...
How can I change file path param of log4j from Spring Controller?
Two suggestions for you to try:
Add a WebAppRootListener to your web.xml - this will configure a system property pointing (default to webapp.root, but you can customize using a context-param - see the Javadocs link) to the root of your web application, which you can then use in the log4j.properties/xml file:
<listener>
<listener-class>org.springframework.web.util.WebAppRootListener<listener-class>
<listener>
<!-- log4.appender.File=${webapp.root}/logs/web-app.log -->
Or use the Log4jConfigListener in your web.xml (which ultimately delegates to a Log4jConfigurer) - this is similar to the above, but allows you to define a custom log4j configu file and also allows for your web application to monitor the log4j config file for changes made at runtime and automatically update your loggers:
<context-param>
<!-- Configure Log4J from the following config file location -->
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener<listener-class>
<listener>
I would also recommend you read the Javadocs for the above in detail - there are some gotchas with regards to deploying multiple webapps in Tomcat and sharing of system properties, but this can all be worked around (providing a custom key for each webapp, rather than the default ${webapp.root}

Resources