krithika_v
I'm new here

How to bundle META-INF and context.xml inside Firstspirit application war file to deploy in Tomcat server?

Hello,

We are moving out Firstspirit Application from IBM Websphere 6.0 to Tomcat 6.0.32 App server.

We have a problem in deploying the war file in Tomcat because Tomcat expects context.xml file inside the META-INF folder.

However for websphere, we have the xmls under WEB-INF.

Is there any way to bundle the META-INF and all the web components xml files inside the war file itself, so that it can be deployed directly on Tomcat server?

Thank you in advance.

Regards,

Krithika

0 Kudos
12 Replies
isenberg
I'm new here

With FirstSpirit 5.0 you don't need to create WAR-files manually. The new web server type "Tomcat" next to the existing ones "InternalJetty", "Generic" and "External", allows for automatic deployment of complete Web Applications as .war file from FirstSpirit to the built in admin webservice of Tomcat via our Java based Admin-Client (Server and Project Configuration on FirstSpirit start page).

The documenation is available in the FirstSpirit Release Notes 5.0 (RELN50EN_FirstSpirit_Releasenotes.pdf), chapter 8.8. Expanded support for Apache Tomcat web server. This chapter will be later moved to the Manual for Administrators (ADMI50DE_FirstSpirit_AdminDocumentation.pdf).

0 Kudos

Hello,

Thank you for the reply.

But we are still using the Firstspirit old version 4.2. So we have to deploy the war file manually.

0 Kudos

Hello,

which web application do you need to deploy? One of the builtin fs4preview, fs4staging? I'm asking as those applications don't need a context.xml within the web application on Tomcat. If it is a custom application, then just add the context.xml later in the manual process: jar uvf myapp.war META-INF/context.xml

0 Kudos

Hello,

I download the war file from Production(LIVE).

The idea is to avoid the manual process of adding context.xml via Tomcat manager.

Presently, when the WAR is downloaded, there is only WEB-INF folder.

Is there any way i can configure the WebApp component inside Module.xml to add the META-INF folder through some code.

Does Firstspirit provide an API like the de.espirit.firstspirit.module.Configuration to allow modification of the war file? 

Or to override the createWar() method in de.espirit.firstspirit.module.AbstractWebApp

to create the META-INF folder and Context.xml file inside it?

Is there any way to achieve this goal?

0 Kudos

Dear FirstSpirit Community,

the goal to achieve is just what Krithika mentioned:

- generating a WAR within the FirstSpirit AdminConsole that owns a META-INF folder having a "context.xml" descriptor file inside

- package things together that belong together without manually modifying the WAR file itsself

Krithika, might it be possible to be more precise, especially regarind the "module.xml" configuration file? Please, show exactly what you try to configure within the "module.xml" to integrate the custom file in "META-INF".

0 Kudos

Thanks Holger.

Please find below the snippet from Module.xml,

I have included a web component called Tomcat Attributes

<web-app>

            <name>Tomcat Attributes</name>

            <description>Web component of HR SSC KM to read out Tomcat attributes.</description>

             <class>de.espirit.ps.bosch.hrssckm.web.tomcat.configuration.TOMCATWebApp</class>                       <configurable>de.espirit.ps.bosch.hrssckm.web.tomcat.configuration.TOMCATConfiguration</configurable>

            <web-xml>META-INF/context.xml</web-xml>

            <resources>

                <resource>lib/hrs.jar</resource>

                <resource>META-INF/context.xml</resource>

            </resources>

            <web-resources>

            <resource>META-INF/context.xml</resource>

            </web-resources>

        </web-app>

The class TOMCATConfiguration implements Configuration<WebEnvironment>

Below is the code snippet to load the context.xml inside TOMCATConfiguration:

/** name of the configuration file */

        public static final String CONFIGURATION_FILE = "META-INF/context.xml";

public void init(final String moduleName, final String componentName, final WebEnvironment env) {

_env = env;

try

{

FileHandle configurationFile = getEnvironment().getConfDir().obtain(CONFIGURATION_FILE);

if (configurationFile.isFile()) {

_config.setProperty(CONFIGURATION_FILE, FileUtilities.inputStreamToString(configurationFile.load(), "UTF-8"));

}

Logging.logInfo("Config loaded :" + CONFIGURATION_FILE , TOMCATConfiguration.class);

} catch (IOException e)

{               

e.printStackTrace();

}

}

After deploying the module, I added the Tomcat attributes in web components and tried to download the war file, but the context.xml resides inside the WEB-INF folder. Also, the META-INF folder is not created!

May be this is not the right way to do it??

0 Kudos

Hello Krithika,

there are two possible solutions to your problem.

You could use the following syntax in the module.xml to include all files within the META-INF folder (META-INF/*):

<resource>META-INF/</resource>

The second possibility is to use the target parameter that specifies the target folder within the webapp root, so that you can add a single file:

<resource target=".">META-INF/context.xml</resource>

or

<resource target="META-INF">context.xml</resource>


Best regards

Jörg

0 Kudos

Hello Joerg,

Thank you very much for the answer.

It works perfectly!! 🙂

Regards,

Krithika

0 Kudos

Hello Joerg,

I have another problem while trying to configure the context.xml in Firstspirit Project configurations.

I have included a web component called Tomcat Attributes and have defined the path to META-INF/context.xml.  The folder is now generated correctly  in the war file ,while downloading from WEB components (Live).

But our requirement is to be able to configure the context.xml in Tomcat Attributes in Firstspirit Project configurations window.

If i enter some text and save in the configure WebComponents window, the changes are visible in this project configuration window, however when i generate the war file, the file is there, but the changes i made are missing. What should i do to configure the context.xml? Please find the screenshot below;

2.png

However If i put the file inside WEB-INF, it is working..

Snippet from Module.xml :-

<web-app>

            <name>Tomcat Attributes</name>

            <description>Web component of HR SSC KM to read out Tomcat attributes.</description>

            <class>de.espirit.ps.bosch.hrssckm.web.tomcat.configuration.TOMCATWebApp</class>

            <configurable>de.espirit.ps.bosch.hrssckm.web.tomcat.configuration.TOMCATConfiguration</configurable>

            <web-xml>WEB-INF/web.xml</web-xml>

            <resources>

                <resource>lib/hrs.jar</resource>

            </resources>

            <web-resources>

                <resource>META-INF/</resource>

                  <resource>META-INF/context.xml</resource>

            </web-resources>

        </web-app>

Also have attached the TomcatConfiguration class file for your reference.

Thank You in advance.

Krithika

0 Kudos