Context.xml not recognized and not executed by Tomcat - java

after setting $CATALINA_HOME in this path /usr/local/cellar/tomcat/9.0.68/libexec, i put the file Context.xml with the same name as my war "warName.xml" in this path : /usr/local/Cellar/tomcat/9.0.68/libexec/work/Catalina/localhost.
here is the content of my file :
<Context>
<Resources className="org.apache.catalina.webresources.StandardRoot">
<PreResources className="org.apache.catalina.webresources.DirResourceSet"
base="/Users/user.name/Desktop/workspace/projectName/dev-resources/config" webAppMount="/WEB-INF/classes/"/>
</Resources>
</Context>
and when i deploy and launch the server i have not my dev-resources/config folder inside /WEB-INF/classes/ in my unzipped project.
the unzipped project has the following permissions :
drwxr-x---
i'am wondering if the process can not inject the configuration because of permissions problems
thanks

Related

How to separate application config from AP in container on Kuberetes?

I want to deploy a application which use an extenal config on Kubernetes. I built a spring boot application to a war file and put it into websphere liberty. Then put application.properties in /config/config ( /config is shortcut of /opt/ibm/wlp/usr/servers/defaultServer) which I want my application to use.
I write a Dockerfile as below:
FROM websphere-liberty:19.0.0.6-javaee8
USER root
RUN mkdir -p /ibank-pv && chown -R 1001:0 /ibank-pv
RUN mkdir -p /config/config/ && chown -R 1001:0 /config/config
COPY --chown=1001:0 ibank.war /config/apps/
COPY --chown=1001:0 server.xml /config
COPY --chown=1001:0 application.properties /config/config/
USER 1001
CMD ["/opt/ibm/wlp/bin/server","run","defaultServer"]
Here is my server.xml. I set ${server.config.dir}/config as a config resource folder.
<?xml version="1.0" encoding="UTF-8"?>
<server description="new server">
<featureManager>
<feature>javaee-8.0</feature>
</featureManager>
<basicRegistry id="basic" realm="BasicRealm">
<!-- <user name="yourUserName" password="" /> -->
</basicRegistry>
<httpEndpoint id="defaultHttpEndpoint"
httpPort="9080"
httpsPort="9443" />
<applicationManager autoExpand="true"/>
<library id="configResources">
<folder dir="${server.config.dir}/config" />
</library>
<application location="ibank.war">
<classloader privateLibraryRef="configResources" />
</application>
</server>
And I add these code to read the application.properties in ${server.config.dir}/config.
public class IbankServlet extends HttpServlet {
private static final long serialVersionUID = 7526471155622776147L;
private final Properties config;
public IbankServlet() throws Exception {
InputStream is = getClass().getResourceAsStream("application.properties");
config = new Properties();
config.load(is);
}
}
However, when I start the server my application, it still read the application.properties which is in war file. What I have to do let my application use application.properties in ${server.config.dir}/config.
Is the issue that getClass().getResourceAsStream("relative-path") looks in the Java package of that specified class? That is, whatever subdirectory corresponds to the Java package of IbankServlet. In other words, is your application.properties within the WAR file buried down in a package subdirectory?
If so, you'll need to either change to getClass().getResourceAsStream("/application.properties") (with the leading slash), and move it to the classpath root in your WAR file, or have your Docker file copy it down into the correct subdirectory.
However, if your IbankServlet is actually not in a Java package at all, this probably isn't the issue.)
(But also, I admit, I'm not certain of the precedence if a file exists in both your WAR and in a "shared library".)

Logback include configuration not working with relative path

I am trying to place logback configuration outside war file and for this i hhave placed the logback file in the webapps folder to tomcat 7.
Project name : AnalyticsAPI
Path of logback.xml(the file inside the war) : /webserv/apache-tomcat-7.0.55_1/webapps/AnalyticsAPI/WEB-INF/classes/logback.xml
Path of external logback with actual configuration : /webserv/apache-tomcat-7.0.55_1/webapps/logback/logback-new.xml
The logback.xml in war is :
<configuration scan="true" scanPeriod="30 seconds">
<include file="../logback/logback-new.xml" />
</configuration>
I have given above path since i read the article that path should be relative to current working directory and current working directory in this case should be the context root of project(if i am right)
The error i am getting in the logs is :
12:41:09,834 |-INFO in
ch.qos.logback.core.joran.util.ConfigurationWatchListUtil#65b17009 - Adding
[file:/home/users/roshnig/../logback/logback-new.xml] to configuration watch list.
12:41:09,835 |-WARN in ch.qos.logback.core.joran.action.IncludeAction -
Failed to open [file:/home/users/roshnig/../logback/logback-
new.xml]

How to use custom module.xml and deploy after custom module of JBOSS EAP6.4 with Spring Boot Application

We are using artesia 3rd party product for our project and it is deployed in JBOSS EAP6.4, I want to use spring boot in our project and when I write sample REST webservices I am able to access the REST web service via URL.
As per the documentation of our product if we need to customize the project we need to write our custom war by specifying below two JBOSS files inside META-INF folder
jboss-all.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss umlns="urn:jboss:1.0">
<jboss-deployment-dependencies xmlns="urn:jboss:deployment-dependencies:1.0">
<dependency name="artesia.ear" />
</jboss-deployment-dependencies>
</jboss>
so our custom logic should begin after successful start of artesia.ear.
our jboss-deployment-structure.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<sub-deployment>
<dependencies>
<module name="deploy" />
</dependencies>
</sub-deployment>
</jboss-deployment-structure>
Above deploy module contains all jars necessary for the project to run.
When I follow the same and created the war without spring in it, it was successful and there are no issues, we are able to use to customize war.
Now I want to do the same in Spring-boot 1.4.1 application, where my spring boot app should start after artesia.ear starts successfully and apart from spring jars my spring-boot app should use jars from module.xml.
I have placed the above two xml's inside META-INF of spring boot application but it is failing when deployed in JBOSS EAP6.4
Below is the error that I get
jboss-server.log
What I need to do to use same for my spring-boot app
EDIT 1:
I tried by placing both jboss files under WEB-INF folder of spring-boot application but still the facing the same issue
We need to make sure that META-INF and WEB-INF folders are lying side by side instead of keeping META-INF folder inside classes folder of WEB-INF which is where default spring-boot META-INF folder resides.

HTTP Status 404 when packaging WAR in EAR file

I'm using JBoss AS 7.1.1.Final and have been having problems getting my deployment to work. I have a couple of EJB jar files and a WAR file that I'm packaging into a single EAR. If I deploy the WAR file separately, I'm able to access it by the context-root specified in the jboss-web.xml file. However, when I package it up into an EAR file, I keep getting a "HTTP Status 404 - /pacbridge-web/" error for the same URL.
Here is what I have
EAR File:
|---pacbridge-app-6.0.0.jar
|---pacbridge-dom-6.0.0.jar
|---pacbridge-ejb-6.0.0.jar
|---pacbridge-web-6.0.0.war
|---META-INF
|---application.xml
|---MANIFEST.MF
|---lib
|----bunch of jar files
My application.xml looks like this:
<application ...>
<display-name>pacbridge-ear</display-name>
<module>
<web>
<web-uri>pacbridge-web-6.0.0.war</web-uri>
<context-root>/pacbridge-web</context-root>
</web>
</module>
<module>
<ejb>pacbridge-ejb-6.0.0.jar</ejb>
</module>
<module>
<ejb>pacbridge-app-6.0.0.jar</ejb>
</module>
<module>
<ejb>pacbridge-dom-6.0.0.jar</ejb>
</module>
<library-directory>lib</library-directory>
</application>
I'm not sure that it's applicable but there is my jboss-web.xml file:
<jboss-web>
<context-root>pacbridge-web</context-root>
</jboss-web>
Could someone give me some hints as to what I might be doing wrong?
Thanks

Requested resource not found for sub-context in case of JSF

My JSF application is deployed under tomcat and server.xml is configured as follows for my application
<Host name="myapp.com" appBase="/home/myapp/public_html">
<Alias>www.myapp.com</Alias>
<Context path="" reloadable="true" docBase="/home/myapp/public_html" debug="1"/>
<Context path="/manager" debug="0" privileged="true" docBase="/usr/local/jakarta/tomcat/server/webapps/manager">
</Context>
</Host>
With these settings I can access all the pages under 'web' folder. I have 'app' folder under 'web' and I have couple of jsp pages under 'app', when I try to access some pages available under 'app' with the following URL: www.myapp.com/app/test_page.jsf, I get 'requested resource cannot be found'
What are the changes I need to do in Tomcat`s Server.xml to get this working.
Do I need to add context path for the 'app' subcontext like this mentioned below in Server.xml:
<Context path="/myapp/app" reloadable="true" docBase="/home/myapp/public_html/app" debug="1"/>
Assuming that /web folder is placed in /public_html folder, you need to include the /web folder in either appBase and docBase, or in URL.

Categories

Resources