Have multiple alias for Webapp - apache

I have deployed a application in Apache tomcat. Suppose name of project is abc (or deployed from abc.war).
I access it using url :=> http://localhost:8080/abc/
But I want to redirect or have aliases for web app. like
http://localhost:8080/abc/
http://localhost:8080/abc1/
http://localhost:8080/abc2/
http://localhost:8080/abc3/
All the above reference to same Web-app. How can I do it and I do not want to copy paste the folder as many times and renaming it.
~Thanks

The best solution is not using a warfile.
Copy all the content into a specified directory (i.e. \user\abc) and then you can either configure all the contexts in two ways.
one xml for every context to map, by putting it into your: %CATALINA_HOME%\conf\Catalina\localhost. Keep in mind that the name of the xml file will be the mapping of your webapp, but you can redefine it with the path attribute inside the xml. In your case you have to produce abc.xml, abc1.xml, abc2.xml and their content should be something like:
abc.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="\user\abc" path="abc" reloadable="false"/>
abc1.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="\user\abc" path="abc1" reloadable="false"/>
you can edit directly the %CATALINA_HOME%\conf\server.xml by inserting, inside the <Host ...> tag, the contexts definitions, something like this:
<Host ...>
<Context docBase="\user\abc" path="abc" reloadable="false"/>
<Context docBase="\user\abc" path="abc1" reloadable="false"/>
</Host>
If you need to provide database datasource information to a context, just add the tag Resource to the context definition itself (either in an xml file or in server.xml),here you go with a sample:
<Context docBase="\user\abc" path="abc" reloadable="false">
<Resource auth="Container" description="DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
maxActive="4"
maxIdle="2"
maxWait="5000"
name="jdbc/myJNDIname"
password="mypass"
type="javax.sql.DataSource"
url="jdbc:oracle:thin:#host:port:SID"
username="myuser"/>
</Context>
If you need this last part, just use it, obviously, for every context you like to duplicate.
Hope it helps.

the easiest way is create soft link directory of the app, like this
ln -s $PWD/abc $PWD/abc1
ln -s $PWD/abc $PWD/abc2
ln -s $PWD/abc $PWD/abc3

Related

Openfire setup page

I'm trying to install Openfire 4.0.2 . My problem is that after restarting Openfire and pressing Admin Console I always see Setup Page. What should I do to fix it?
This is my openfire.xml file
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file stores bootstrap properties needed by Openfire.
Property names must be in the format: "prop.name.is.blah=value"
That will be stored as:
<prop>
<name>
<is>
<blah>value</blah>
</is>
</name>
</prop>
Most properties are stored in the Openfire database. A
property viewer and editor is included in the admin console.
-->
<!-- root element, all properties must be under this element -->
<jive>
<adminConsole>
<!-- Disable either port by setting the value to -1 -->
<port>7090</port>
<securePort>7091</securePort>
</adminConsole>
<locale>en</locale>
<!-- Network settings. By default, Openfire will bind to all network interfaces.
Alternatively, you can specify a specific network interfaces that the server
will listen on. For example, 127.0.0.1. This setting is generally only useful
on multi-homed servers. -->
<!--
<network>
<interface>127.0.0.1</interface>
</network>
-->
<!-- SPDY Protocol is npn.
(note: npn does not work with Java 8)
add -Xbootclasspath/p:/OPENFIRE_HOME/lib/npn-boot.jar to .vmoptions file -->
<!--
<spdy>
<protocol>npn</protocol>
</spdy>
-->
<!-- XEP-0198 properties -->
<stream>
<management>
<!-- Whether stream management is offered to clients by server. -->
<active>true</active>
<!-- Number of stanzas sent to client before a stream management
acknowledgement request is made. -->
<requestFrequency>5</requestFrequency>
</management>
</stream>
</jive>
Thank you.
In a file like this you miss the database part, so probably you never finished the setup really.
However there are 2 flags you must add:
in openfire.xml <setup>true</setup>
as child of <jive> tag
and in ofProperty table of database
INSERT INTO OFPROPERTY (NAME,PROPVALUE) VALUES ('setup','true');
The answer is, you have to uninstall Openfire and after delete Openfire folder which is situated in C:/ProgramFiles(x86)/ and reinstall Openfire.
The setup procedure of Openfire will, if it runs successfully, modify the content of the openfire.xml file. The most typical reason for this to fail is a file permission problem. Make sure that the user that is executing Openfire is allowed to read & write all files under the Openfire home folder.

is there a environment variable for tomee-home that I can use in context.xml

I've a webapp that is being deployed to a tomee server. This webapp has a META-INF/context.xml file and its content is as of below:
<Context>
<Loader className="org.apache.catalina.loader.VirtualWebappLoader" virtualClasspath="/apache-tomee-plus-1.7.2/someProperties;" />
<JarScanner scanAllDirectories="true" />
</Context>
Notice that the Loader element's virtualClasspath attr has a value of /apache-tomee-plus-1.7.2/someProperties;, where /apache-tomee-plus-1.7.2 is ready the tomcat home. Do you know if there a way to refer to the tomcat-home without hard code the actual path name?
It looks like I can use ${catalina.home} to refer to tomcat-home directory.

What is the expected contents of Web.config if appSettings entry is parameterized?

I'm trying to parameterize an appSettings entry in my Web.config. Since this is a part of a quite long build process, I'd like to verify that my parameterization actually works before trying it out on our CI server (i.e. trial and error is not a good idea).
So, if I run MSBuild with /T:Package to create my package, I expect that the .zip file created would contain a Web.config with my appSetting entry tokenized, just like a connection string is tokenized.
But, so far I do not get my expected result. Is my assumption wrong?
Is it maybe that the tokenization/replacing happens first in the actually deploy-step?
Here's the tokenized web.config. Notice how my appSetting isn't tokenized:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<lots of stuff here...>
<connectionStrings>
<add name="DefaultConnection" connectionString="$(ReplacableToken_DefaultConnection-Web.config Connection String_0)" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="mySetting" value="monkey"/> <!-- Shouldn't monkey this be tokenized? -->
</appSettings>
<rest of web config here ...>
The con string tokenization is taken care of in the web publishing MSBuild targets. It's not a part of Web Deploy itself. In your scenario I'd expect that the package was created and app settings are not modified.
When the package is created there are two ways you can see the parameters:
Use msdeploy.exe and pass GetParamters - http://technet.microsoft.com/en-us/library/dd569044(v=ws.10).aspx
You can crack open the .zip file and look at the parameters file inside of it

can you use a variable in the message logging policy for host and port?

can you use a variable in the message logging policy for host and port? for example
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<MessageLogging async="false" continueOnError="false" enabled="true" name="splunk">
<Syslog>
<Message>Message. id = {request.header.id}</Message>
<Host>{variable}</Host>
<Port>{variable}</Port>
</Syslog>
</MessageLogging>
At this time, the Host and Port entries cannot be variables.
An alternative to using variables at runtime is to set those attributes at build time using a build tool like maven.

NLog in WCF Service

Can I use NLog in a WCF Service? I am trying to but cannot get it to work.
First I set up a simple configuration in a Windows Forms application to check that I was setting up correctly and this wrote the log file fine (I am writing to a network location using name and not IP address).
I then did exactly the same thing in the WCF Service. It did not work.
To check permissions I then added some code to use a TextWriter.
TextWriter tw = new StreamWriter(fileName);
tw.WriteLine(DateTime.Now);
tw.Close();
This worked OK so I know I can write to the location.
Check that your NLog.config file is in the same directory as your .svc file and NOT the Bin directory.
If you've just added the config file to the WCF project, then published it you will probably find your config file has been copied to the bin directory which is why NLog can't find it. Move it to up a level then restart the website hosting the service (to make sure the change is picked up).
This had me stumped for a while this morning!
Put your NLog config in the web.config file. Like so:
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
</configSections>
. . . (lots of web stuff)
<nlog>
<targets>
<target name="file" xsi:type="File" fileName="${basedir}/logs/nlog.log"/>
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="file" />
</rules>
</nlog>
</configuration>
See my comment to your original question for how to turn on NLog's internal logging.
To turn on NLog's internal logging, modify the top of you NLog config to look like this:
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.mono2.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="Trace"
internalLogFile="nlog_log.log"
>
The key parts are internalLogLevel and internalLogFile.
You can also set internalLogToConsole to true or false to direct the internal logging to the console.
There is another setting, throwExceptions, that tells NLog whether or not to throw exceptions. Ordinarily, this is set to false once logging is successfully configured and working. You can set it to true to help determine if your problem is due to an NLog error.
So, if you had all of those options enabled, the top of your NLog configuration might look like this:
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.mono2.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="Trace"
internalLogFile="nlog_log.log"
internalLogToConsole="true"
throwExceptions="true"
>
My first guess is that NLog is not finding the config information. Are you using an external config file (NLog.config) or "inline" configuration (in your app.config or web.config)? In your project, is(are) your config file(s) marked (in Properties) as Copy Always?