Tomcat customization while starting server - tomcat8

I am manually copying a war file to the web-apps folder of Tomcat and starting Tomcat using cmd ./catalina.sh start. I want to customize it in such a way that I can use a war name to start e.g ./catalina.sh start quickenweb (where 'quickenweb' is a war file name).
Please suggest how to achieve this.

If you have access to Windows and WinZip or the 7-Zip File Manager, you can open the war file with Zip Program. Or, if you have LINUX, PeaZip/File Roller would work too.
In the zip program, you can navigate to the folder - like log4j.properties for example and edit it. When closing TextPad/LeafPad for example, the Zip program should prompt you to update the war file. It is advisable to edit/update the war file outside of the tomcat folder structure and then delete the war under tomcat and then update.. Actually, probe is a great tool for managing/updating/compiling war files.
Hope this helps?

Related

Adding external Jar to Pentaho Kettle

I am working on Pentaho Kettle version 5.0.1. In one of my transformation I am using javascript component where I am calling a method located in the JAR which I have copied to the lib folder of data-integration and everything is working fine in my local. But in my dev environment(I run it using kitchen) I don't have permission to copy my Jar file to the lib folder due to the restrictions on the server. Is there any other way using which I can supply the path of my custom Jar during run time so that the Kettle Job/Transformation can use it while being executed. Is there a way Kettle can pick the Jar location other than data-integration/lib?. Any help will be appreciated.
Take a look into kitchen.sh (and pan.sh). At some point the script starts adding stuff to the classpath. You can add more folders to the classpath there.
You still need permissions to edit the kitchen.sh file, though. If you can't do that, I suggest creating a copy of kitchen.sh you can write, in a separate location, and change the $BASEDIR folder to the actual PDI installation, so that kitchen can be located elsewhere.
If you have permission you can put your jar in another directory and after you specify this directory in the launcher.properties which you find in data-integration\launcher.
For exemple: if you put your jar in this directory: /export/home.
In launcher.properties: you will add this path and precisely libraries=../test:../lib:../libswt:../export/home

How to deploy an .aar file in Tomcat server?

I am trying to build a sample apache axis 2 project in tomcat server. In most of them, in the readme file, it is said to deploy StockQuoteService.aar.
"Type "ant generate.service" from Axis2_HOME/samples/quickstartxmlbeans
directory. Then deploy the
AXIS2_HOME/samples/quickstartxmlbeans/build/service/build/lib/StockQuoteService.aar "
How to do this deploying thing?
For a simple, ad hoc deployment, you can do this:
Download the axis2 WAR distribution. It comes as a ZIP file.
Extract the file "axis2.war" from the ZIP.
Copy axis2.war into Tomcat's webapps folder. Tomcat unpack axis2.war into a folder named axis2, which will contain a folder named services.
Copy your AAR files into the services folder. Axis2 will autodeploy them the same way Tomcat autodeploys WARs placed into its webapps folder.
Access your service as http://example.com:8080/axis2/services/servicename.

How to change the path that jar files use in java Web Applications

I have written a java Servlet web application, using NetBeans 7.2.1. The program have some jar file libraries that I have attached to the project. The application runs fine using NetBeans and Apache Tomcat 7.0.27.
My problem is that some of the jar file libraries that I am using in the project, need to access to some folders and files. I put these folder and files on the same directory as the whole NetBeans project is. but I got this exception:
Exception: java.lang.RuntimeException: java.io.FileNotFoundException
So I used these codes to find out where should I put them:
out.println("current directory: " + new File(".").getAbsolutePath());
out.println("current directory: " + System.getProperty("user.dir"));
out.println("current directory: " + getServletContext().getRealPath(("/")));
So I figured out that the current working directory is:
C:\Program Files\Apache Software Foundation\Apache Tomcat 7.0.27\bin
My question is that how can I set different directory address for each web application? I have many web applications and some of them use the same resource file names. I can't just put all of them in one directory.
Please note that I don't have access to the source code of jar files to change the. I just need a way to set the absolute path that the jar files use.
I have the same problem when I put the WAR file on the unix server. The extracted WAR file is in this location on the server:
/data02/tools/Apache/Tomcat/apache-tomcat-6.0.37/webapps/BANNEROnline
But I figure I should put the resource folders and files in this path (moosavi3 is my username!):
/home/moosavi3
How can I change the path?
The working directory is the directory from which java.[exe,bin] is started. I assume the bin directory is where the tomcat start-up script is? If the jars are all using this working directory I don't believe there is a way to make different web-apps have different working directory, they're all loaded on the same jvm (java.exe) from the same working directory.
A working directory is the directory from which a binary is started, it is not some arbitrary value that you can change.
I suspect these jar files where meant to be run as standalone applications and expected the filesystem resources they are trying to access to be in the same location as themselves.
Any filesystem resources would have to be moved to the location of your java.exe so that the correct file path resolution can result from your jars.
Standard Servlet project requires external libraries to be placed in the 'WEB-INF/lib' directory under project root. You can search google for 'servlet directory structure' and do your own research for more information. Shared libraries between web applications can be placed in the 'lib' directory under tomcat root, they should be picked up by tomcat jvm. My recommendation would be to keep the dependencies project specific, because you may need different versions in different projects in the future.
Update:
Read this page on the tomcat documentation, it will explain exactly how the project should be structured, and how to add a library that will be shared across all web applications:
http://tomcat.apache.org/tomcat-7.0-doc/appdev/deployment.html
Update 2:
The following Stackoverflow link explains several options how to add a static file to your web application, that will available at runtime.
https://stackoverflow.com/a/2161583/940754
Update 3:
Add a path to the classpath using the project's manifest:
http://docs.oracle.com/javase/tutorial/deployment/jar/downman.html

intellij idea run configurations backup

I would like to create a script to modify my debug configuration in intellij. The path of tomcat changes, and i have to manually go into the run config and edit things. I have tried to find the place where intellij stores these settings to no avail.
question: does anyone know where IJ stores its run configuration
The location would depend on 2 factors, whether the configuration is local to the user or shared with the other developers and if you are using the file based (legacy) or the directory based project format.
File based project, local configuration: .iws file
Directory based project, local configuration: workspace.xml file under .idea directory
File based project, shared configuration: .ipr file
Directory based project, shared configuration: .xml file under runConfigurations subdirectory of .idea directory or files inside .run directory in the project root (you can customize the location of the shared configurations in the latest versions).
Its here .idea\runConfigurations (correct for Idea 11). Just copy this folder to new project.
EDIT: As per comment, if runConfigurations folder doesn't exist, check the 'Share' box inside the Run/Debug configuration

I want to know how to deploy the war file in apache tomcat and make it to run

I create a war file using apache ant and
i wanted to
deploy that .war file in tomcat and make it run
can u people help me with the steps..
i m not clear abt it
stop tomcat
move your war into [tomcat install dir]/webapps
start tomcat
tomcat will deploy the war on startup
for database connectivity copy the connector in the lib folder of project which is in WEB_INF folder
like point\war\WEB-INF\lib
create war File ...in war folder of the project
like c:/user/workspace/point/war/ there (point is project name)
...by command jar cvf point.war *
now type http://localhost/portnumber/ like mine is http://localhost/9090
press on tomcat manager and give user and password
go on the option deploy war file to upload ...browse and choice the war file create in war folder of project
upload the file
click on the /point which created by manager and their your file is uploaded