How to deploy an .aar file in Tomcat server? - apache

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.

Related

deploy .war file to tomcat8 ubuntu16.04

I followed this tutorial for setting the tomcat8 on ubuntu 16.04:
https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-ubuntu-16-04
I have configured tomcat/conf/tomcat-users.xml, added arsys.xml in tomcat/works/CATALINA/localhost/. I have updated .bashrc by setting CATALINA_HOME and JAVA_HOME.
It is now all set up and now when I click on Manager App, I get Tomcat Web Application Manager windows. Thereafter browsing the required .war file under the section WAR file to deploy, after clicking Deploy button I get that 'This site can't be reached'. (Google-Chrome)
What could be the possible reason for it? What shall I do to resolve it?

multiple webapp with Log4j log file on a single apache server

I'm deploying multiple WAR files in an apache tomcat server. each WAR file is containing their respective Log4j.properties file (Log4j located in WEB-INF/Log4j.properties).
If I'm deploying app1.WAR, having WEB-INF/classes/Log4j.properties to generate logs in CATALINA-HOME/logs/app1.log and another app2.WAR, having WEB-INF/classes/Log4j.properties to generate logs in CATALINA-HOME/logs/app2.log, but every logs from my both webapps are written into CATALINA-HOME/logs/app1.log.
how can I configure Log4j to create dedicated log file for each webapp loaded in apache ?
I finally found a solution.
we just need to copy Log4j and commons lib jar files in the WEB-INF/lib folder of each WAR file to get an independent instance of Log4j per webapp. Then, Log4J will get the Log4j.properties file of the webapp to create its own Logging instance.
Hope it will help.
The solution by #tiamat didn't worked for me. I have to configure a listener to initialize logger context along with providing configuration location explicitly to the context
URL configLocation = Class.forName("com.example.MyAppListener").getResource("/log4j2.xml");
LoggerContext context = (LoggerContext) LogManager.getContext(false);
context.setConfigLocation(configLocation.toURI());
if(!context.isInitialized()) {
context.initialize();
}else {
context.reconfigure();
}

Tomcat customization while starting server

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?

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

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