How to add META-INF/context.xml in Warbler - warbler

How can I add META-INF/context.xml into the war? I didn't find any config entry in config/warble.rb.

Unfortunately Nick's method doesn't work. The file is actually copied to WEB-INF/META-INF/context.xml.
I finally figure out a way to copy context.xml to META-INF:
create META-INF/context.xml under your rails app root folder
uncomment and change the following line in config/warble.rb
config.public_html = FileList["public/**/*", "doc/**/*", "META-INF/context.xml" ]
Basically treat META-INF as public_html, and it will be copied to webapps/youapp/META-INF.

You'll have to add one yourself. You can either create a META-INF/context.xml directory and file in your project and add META-INF to config.dirs in config/warble.rb or you can add a "pathmap" to rename the context.xml file into the META-INF directory in the war file.
config.pathmaps.application += ["%{context.xml,META-INF/context.xml}p"]

A better way of tackling this might be to use the following in your warble.rb file.
config.script_files << 'path_to_file/context.xml'
See documentation towards bottom of https://github.com/jruby/warbler/blob/master/lib/warbler/config.rb
# These file will be placed in the META-INF directory of the jar or war that warbler
# produces. They are primarily used as launchers by the runnable feature.
attr_accessor :script_files

Related

projects_default.yml file in thorntail

Thorntail generator does not generate any project_defaults.yml file in project structure. No resources folder also seen.Should we manually place this file to configure project properties?
Note : I am new to thorntail.
Yes, you need to create a file project-defaults.yml inside src/main/resources.

Spring Boot how to add another resources folder in test folder

Is it possible to add another resources folder in test folder, which will also be on the classpath?
I need it because I don't want to add application-test.properties file in default resources folder because it belongs in test folder.
I tried to add folder manually but it does not work.
I soloved this problem, in Intellij IDEA by:
Right clicking on the project -> Projectu structure,
and I marked newlycreated folder as Resources file.
It is gradle project or maven? If you have gradle just add the line below to the build.gradle file:
ext {
resourcesDir = projectDir.path + "/other/resources"
}
where the /other/resources is your dedicated resource folder

Maven war has META-INF folder in two places

I'm working on a project which uses JAAS and unfortunately for me Tomcat requires a file to be put in a META-INF folder in the root of the war
app.war
|__META-INF
| |___context.xml
...
I think that it's already weird since the default META-INF location for WAR's is in the classes folders.
app.war
|__WEB-INF
| |__classes
| |__META-INF
...
So I'm using Maven, which states that anything in src/main/resources/META-INF will be copied to the appropriate place, which it does. The weird thing is that it is also creating a META-INF folder in the root of the file structure leaving me with 2 META-INF folders.
Project Structure
app
|__src/main/java
|__src/main/resources
| |__META-INF
| |__context.xml
...
After mvn package
app
|__META-INF [1]
|__WEB-INF
| |__classes
| |__META-INF [2]
| |__context.xml
...
So, if the war standard states that META-INF should be under classes folder, as in #2, why maven war creates the #1 folder. And is there a way to make it copy files into that folder instead of #2?
Regards
So I found this:
Two Meta-Inf folders - normal structure?
which states that having 2 META-INF folders is not a problem. Digging a little I found:
JAR File Specification
which states about the META-INF folder:
A JAR file is essentially a zip file that contains an optional META-INF directory. ...The META-INF directory, if it exists, is used to store package and extension configuration data, including security, versioning, extension and services.
and this:
JSR-000315 JavaTM Servlet 3.0
which, on section 10.6, states about the WAR file structure:
When packaged into such a form, a META-INF directory will be present which
contains information useful to Java archive tools. This directory must not be directly
served as content by the container in response to a Web client’s request, though its
contents are visible to servlet code via the getResource and getResourceAsStream
calls on the ServletContext. Also, any requests to access the resources in META-INF
directory must be returned with a SC_NOT_FOUND(404) response.
So from the WAR spec the right place is WEB-INF/classes/META-INF. Yet, since war is a special jar file, it makes sense to have /META-INF as a point for extensions. One can see such different uses in JPA persistence.xml vs. Tomcat context.xml files: the former should be placed in WEB-INF/classes/META-INF while the latter in /META-INF.

How can I make gradle include *.ftl files in war file

I have the following structure:
src/main/java/com/company/SomeJavaFile.java
src/main/java/com/company/template_file.ftl
When I create a build using gradle, the *.ftl files dont get included in the war file.
How can I make gradle include them in the war file?
Another solution would be to put your *.ftl files into src/main/resources directory instead.
Ok, found it. You simply add the following line to your build file:
gradle.build file (add the following line):
sourceSets.main.resources.srcDir 'src/main/java'
Got the answer from the following discussion thread:
http://gradle.1045684.n5.nabble.com/Copy-non-java-files-into-the-target-directory-td1432058.html
Why not put them in src/main/webapp where, if you used them, *.jsp files would go?

relative path of resource files?

when i deploy a project to servicemix i do a "mvn install" then inside servicemix i simply do: "osgi:install -s mvn:my.package.x/proj".
now when i want to reference a file inside the package i get a "file not found exception"
in my .m2 directory the package structure inside the jar looks like this (if i unpack to look):
servicemixTest-0.0.1-SNAPSHOT
--my
----package
------processingFile.class
--resources
------xsl
---------fileForTransformation.xsl
now in the processing Class i need to reference the xsl file with camel like this:
.from(url) .to("xslt:file:./data/xsl/transformation.xsl") .process()
i already tried:
../../
./
nothing ("xslt:file:data/xsl/tr...")
my question is now: "how do I find resource files inside a deployed container?"
If your XSL file is packaged in the JAR file, you don't need the file: part in the URI. You can just refer to the location inside the JAR directly, like this:
from("direct:start").to("xsl:resources/xsl/fileForTransformation.xsl").process()

Resources