Managing CATALINA_BASE with Maven - maven

I am responsible for multiple Tomcat instances serving different applications.
My installation paradigm is that CATALINA_HOME is an unmodified version of Tomcat.
Within CATALINA_BASE are the customizations for our environment, bin/service.bat, conf/server.xml, lib/*.jars.
I would like to be able to manage these customizations through Maven under source control. I've set up Git for the source control but can any guide me toward this goal, a project structure like so:
MyTomcats
/src
/AppServer1
/bin
service.bat
README.TXT
/conf
server.xml
/pom.xml
/target
/AppServer1.zip
/AppServer1
/bin
service.bat
README.TXT
/conf
server.xml
...
/lib
*.jars
/webapps
*.war
/(other dirs)
The output of a mvn package would be a the CATALINA_BASE with the lib/*jars populated. I'm not too concerned about populating the webapp folder with the correct wars but I would like the necessary folder structure so that I could deliver a zipped CATALINA_BASE to operations when there are server updates.
I know that server updates aren't as frequent as application updates, but we are migrating from an embarassingly old JSP server to Tomcat and I can see myself quickly losing track of the situation if I don't manage the changes to CATALINA_BASE properly.

Related

Where m2 file is stored when installing apache maven on a unix box

I downloaded maven gz file, unzipped same, but i dont know where the m2 is stored. I imagine im missing a step but i cant see what one?
Is there aninstall script etc?
[root#atddpvm5 apache-maven-3.5.4]# cd /var/tmp/apache-maven-3.5.4/
[root#atddpvm5 apache-maven-3.5.4]# ls
apache-maven DEPENDENCIES doap_Maven.rdf LICENSE maven-builder-
support maven-core maven-model maven-plugin-api
maven-resolver-provider maven-settings-builder NOTICE README.md
CONTRIBUTING.md deploySite.sh Jenkinsfile maven-artifact maven-compat
maven-embedder maven-model-builder maven-repository-metadata maven-
settings maven-slf4j-provider pom.xml src
By default the .m2 folder is stored in the home folder of the user. In this case since you are using root, the path is most likely /root/.m2. You also have to use the -a switch with ls to see that folder, since it's a hidden folder (it starts with a .). Note that the folder will only be created on the first usage of Maven, i.e. when you call a maven command on a maven project, like mvn clean install.
Additionally it looks like you have downloaded the source distribution of Maven, which only makes sense if you want to work on Maven itself. You might want to download the binary distribution, if you just want to use it.

Handling resources across local vs sandboxed maven test environments

The standard maven directory structure includes resources as follows:
src/main/resources
src/test/resources
When a maven build is initiated on a sandboxed environment - e.g. jenkins then all of the artifacts in those directories become available at the sandboxed "current" directory - and without resorting to any paths - either relative or absolute.
But when running mvn test locally the sandboxed environment is not in play: instead it is just the root directory of the project. In this case those resources would seem to need to be accessed via src/main[test]/resources.
Specifically: in a sandboxed environment all of the classes to be run are unpacked into a temporary directory *along with the resources under src/[test|main]/resources*. Therefore: the files/artifacts undersrc/[test|main]/resources` are present in the current directory. The "relative" path to those resources is thus
./
But in the local environment - e.g. running mvn test at the root directory of a local git clone - then the current directory is the git repo root dir. The "relative" path to the artifacts is thus
./src/[test|main]/resources
While I realize the artifacts can also be accessed via classLoader.getResourceAsStream I have apis' that require File access. We use api's like listFiles() and there is also the need to generate files in the given directories using file:// uri as well as literal paths. so we do need file paths.
What can be done here to normalize the paths across these different use cases/environments?

Maven - erroneous weblogic classpath

On my Oracle weblogic 12 installation I have deployed an .ear (built with maven). All is OK except when I go to wls-cat and check Classloader Tree I get entries such as:
D:\Oracle\Middleware\Oracle_Home\user_projects\domains\liferayportal\servers\AdminServer\tmp\_WL_user\mywebapp\nsio4q\APP-INF\lib\lib\antlr-2.7.6.jar
and
D:\Oracle\Middleware\Oracle_Home\user_projects\domains\liferayportal\servers\AdminServer\tmp\_WL_user\mywebapp\5ohvco\war\WEB-INF\lib\..\..\lib\
I have no \lib\lib folder and neither do \lib...\...\lib
What can be the cause? What should I check in my POMs? Thank you.
This is not related to your pom.xml
WLS expands the war file, but copy the files in different places, therefor It doesn't recreate a directory structure (ie: OC4J does it).
Therefore, WLS-CAT is telling where (psychically) is retrieving a particular class (from antlr jar file in your case).

jboss-as-maven-plugin: which directory does command "jboss-as:deploy" deploy an .ear to?

I am running jboss 7.1, maven 3, and a java ee6 application that generates an .ear
I am doing a mvn clean package jboss:as-deployand Jboss-as-maven-plugin 1.5 does its thing--I can view my app using http://localhost:8080...
just fine, but I want to know where the actual .ear is being put.
It is not in my jboss7.../standalone/deployments folder. So where is it? My app is obviously running in jboss 7.1 just fine, but I can't find the .ear file. I know that there is an .ear in Eclipse's 'target' directory, but that wasn't produced by jboss-as-maven-plugin is it? I hope you can understand my confusion--don't all .ear files need to be in the deployments directory? I also do see my .ear file inside my hidden .m2/repository directory, but does this have any interaction with jboss-as-maven-plugin? Maybe there is some hidden sym-linking between my Eclipse project's 'target' directory and the jboss7.1 standalone/deployment directory?
p.s. I am used to using a hard-deploy option with the other plugin jboss-maven that requires you to say jboss:hard-deploy which just copies the .ear to your deployments folder. Then jboss would pick up the new .ear and redeploy automatically. I get the sense that jboss-as-maven-plugin is the preferred plugin so that's why I am bothering.
The jboss-as-maven-plugin uses the deployment API so it doesn't copy the file to the deployments directory for the scanner to pick it up. It deploys just as if you deployed it from the web console or via CLI. The files should be located somewhere in the $JBOSS_HOME/standalone/data/ directory.
You're welcome to open an issue, for a discussion around it at least. I'm not sure how I feel about adding a goal for it, but here isn't the place to discuss that :)

Managing external JARs build paths in git controlled eclipse project created in Ubuntu and cloned in Windows

I am having an eclipse project created on Ubuntu, in which all the JARs that I am using, are located in a folder /home/xyz/AllJARs. Here the /home is the system home folder. The project as well as the AllJARs folder is git version controlled on a central git server.
So, all the paths to these JARs in the project's build path are /home/xyz/AllJARs. When I'm cloning the project repo and the AllJARs repo on a Windows machine, I'm shown errors related to build path since it can't find the path /home/xyz/AllJARs.
How can I manage this situation where I can have external JAR files in build paths which can work on Ubuntu as well as on a Windows machine? Thanks in advance.
You have two easy options:
use relative paths: for example, put the JAR folder in the folder above your project, then you can set the JARs' paths to ../AllJARs/
put JARs into project: you can also just put the JARs into the project folder; if you've set them up as "External JARs" in project settings, you'll have to remove them from that list, and re-add them with "Add JARs". Eclipse will then look for them locally in the project folder. If you don't want to commit the JARs to the git repo (size and/or permission being a problem), you can just copy them into the Project folder after cloning. While they're not there, you'll be shown a warning, but once Eclipse can find them, everything's fine.

Resources