473,405 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Deploying web application in Tomcat using Ant

Hi

I have created a web application. I am using ant to build the war and deploy in tomcat.

The war file is deployed under "TOMCATE_HOME/work/standalone/localhost/onlineres.war".

I have my source files in "D:\Sadiq\Projects\Onlineres". The folder structure is as follows.

1) D:\Sadiq\Projects\Onlineres:
This folder is having the context.xml, web.xml, build.xml and build.properties files.

2) D:\Sadiq\Projects\Onlineres\src:
This folder is having the java files

3) D:\Sadiq\Projects\Onlineres\web:
This folder is having the jsp pages, css and java scripts.

After executing the build target in build.xml file, the following folders have been included in D:\Sadiq\Projects\Onlineres.

1) D:\Sadiq\Projects\Onlineres\war\onlineres
This folder is having the jsp pages, css and java scripts etc.

2) D:\Sadiq\Projects\Onlineres\war\onlineres\WEB-INF
This folder is having web.xml and all class files.

3) D:\Sadiq\Projects\Onlineres\war\onlineres\META-INF
This folder is having the context.xml file

I have copied the D:\Sadiq\Projects\Onlineres\war\onlineres folder into "TOMCATE_HOME\webapps".

Now after restarting the server, I try to access the application by the URL "http://localhost:8888/onlineres/index.jsp". Now I got the page not found error. (Note: I have configured the port as 8888 while installing the tomcat)

But I deploy the application using ant, I am able to access the application by the above said URL

Also I have tried using the install target. In this case the "onlineres.war" file is created within the D:\Sadiq\Projects\Onlineres\war\onlineres. In this case the war file is not copied to "TOMCATE_HOME/work/standalone/localhost/onlineres.war". Instead the application is running from the path "D:\Sadiq\Projects\Onlineres\war\onlineres.war ". But once I restarted the application the I am unable to access the application.

What I want to do is as follows.

I would like to run the application without creating the file "onlineres.war". I have the folder "D:\Sadiq\Projects\Onlineres\war\onlineres" after the build target in build.xml is executed using ant. I would like to run the application from this folder.

Whether this is possible? If so what I have to change? Please help.

Thanks in advance.
M. Jahabar Sadiq.
Dec 6 '08 #1
11 7079
Dököll
2,364 Expert 2GB
Hey there!

I feel your pain; for I have had similar problems with Tomcat... After deployment though, you would no longer need localhost. I believe you would need your production application server name.

I would try to not package into a war file and using you computer name, as test to see if your web app interacts properly with your files:

(1) Right-Click My Computer
(2) Go to properties
(3) Find computer name
(4) Replace localhost in your app with that name
(5) Open a new web browser
(6) Paste the entire address in

Thus:

http://YourComputerName:YourPortNumb...ppName.jsp(jsf)

This would give you an idea what errors, if any, exist upon deploying to Production App Server.

Note: you may need to disable your firewall for this to work...

Give that a whirl, see what happens.

Do stay tuned if this does not do it:-)

In a bit!
Dec 6 '08 #2
Hi,

Here I am giving my problem in another view.

I am using ant to deploy the application in Tomcat 4.1 (Though this is the older version, I am using it).

I have installed the tomcat in the following path
Expand|Select|Wrap|Line Numbers
  1. C:\Tomcat\Apache Group\Tomcat 4.1\
I am having my web application in the following path
Expand|Select|Wrap|Line Numbers
  1. D:\sadiq\Projects\jsp_web\OnlineRes
I have attached the
OnlineRes.zip
file of the above said web application folder.

When I called the deploy target in the build.xml file I got the following as the output.

1) The application is getting deployed into the following directory.
Expand|Select|Wrap|Line Numbers
  1. C:\Tomcat\Apache Group\Tomcat 4.1\work\Standalone\localhost\manager\onlineres.war

2) Also the context entries have been added in the server.xml file in the following directory
Expand|Select|Wrap|Line Numbers
  1. C:\Tomcat\Apache Group\Tomcat 4.1\conf
In the above case the war is not getting unpacked. The application is running from that ".war" file. We can see this by calling the "list" target. But other applications like "tomcat-docs" and "web-adv" are running from the following "directories".
Expand|Select|Wrap|Line Numbers
  1.     C:\Tomcat\Apache Group\Tomcat 4.1\webapps\tomcat-docs
  2.     C:\Tomcat\Apache Group\Tomcat 4.1\webapps\webadv

I have tried the following also without using the deploy task.

1) Copied the war file into the following directory manually.
Expand|Select|Wrap|Line Numbers
  1. C:\Tomcat\Apache Group\Tomcat 4.1\webapps
2) Restarted the servers.
Now the war file is getting unpacked. But the context entries are not getting added to the server.xml file in the following directory
Expand|Select|Wrap|Line Numbers
  1. C:\Tomcat\Apache Group\Tomcat 4.1\conf
I have to manually do this before restarting the server.



Please help me to get the following.

1) When I trigger the deploy target, the war file should get copied into the following directory.
Expand|Select|Wrap|Line Numbers
  1. C:\Tomcat\Apache Group\Tomcat 4.1\webapps
2) The context entry should get added in the server.xml file in the following path after the deploy target is called.
Expand|Select|Wrap|Line Numbers
  1. C:\Tomcat\Apache Group\Tomcat 4.1\conf
If I got the above said results, the war file will get unpacked when restarting the servers. Why I would like to unpack is, I will copy some files into the data directory within the application directory. That is in the following directory if the war is unpacked

Expand|Select|Wrap|Line Numbers
  1. C:\Tomcat\Apache Group\Tomcat 4.1\webapps\onlineres\data
The files inside this folder will be accesed via the jsp or servlet files and the data can be processed. [Source code for this has not been written yet]

Thanks in advance,
M. Jahabar Sadiq
Attached Files
File Type: zip OnlineRes.zip (9.0 KB, 171 views)
Dec 13 '08 #3
Is any one having solution for this problem?????


by

M. Jahabar Sadiq
Dec 15 '08 #4
r035198x
13,262 8TB
Why not include the files in that data folder inside the .war file itself.
Dec 15 '08 #5
The data in the files inside the data folder are the inputs to be processed and as the result some records will be created in the database whenever user wants to do so.

I would like to change the data in those files dynamically. So that we can create, update records. For this we need to write code separately. I hope I can do those coding, if I am able to modify the data in the files.

To do so, I need the war to be unpacked and so we can able to modify the data of the files within the data directory
Dec 15 '08 #6
r035198x
13,262 8TB
You can read and write to that directory from your servlets fine. You reference it relative to the application path using the getServletContext() method. war files are automatically unpacked by tomcat on every deploy anyway. Just include that folder as part of the war. It will be made available when the application is deployed.
Dec 15 '08 #7
Thanks for your ideas..

I agree that we can read/write files in the data folder using servlet.

Why I would like to do so is as follows.

I would like to have some classes that will be run using some ant targets (we can call these classes as Loaders; because these classes are going to load the data from the files to the DB).

We can also run these classes from the UI. In this case I have no problem. As because I would like to run from ant, I would like to unpack the war.
Dec 15 '08 #8
Hi,

I have tried in the following way.

1) Copied the "onlineres.war" file in the following path
Expand|Select|Wrap|Line Numbers
  1. C:\Tomcat\Apache Group\Tomcat 4.1\webapps
2) I have also copied the "onlineres.xml" file in the above said path. This file is having the context entries.
3) Restarted the servers.
But I didn't get the war unpacked. But if I omit the Step-2, I got the following result.

1) The "onlineres.war" file get unpacked into the directory "onlineres" while starting the servers.
2) The startup servlets are getting loaded successfully.
3) I tried accessing the "index.jsp" using the following URL.
Expand|Select|Wrap|Line Numbers
  1. http://localhost:8888/onlineres/index.jsp
By doing so I got the following errors in the log

Expand|Select|Wrap|Line Numbers
  1. 2008-12-15 22:56:31 StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
  2. org.apache.jasper.JasperException
  3.     at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
  4.     at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
  5.     at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
  6.     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
  7.     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
  8.     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
  9.     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
  10.     at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
  11.     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
  12.     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
  13.     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
  14.     at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
  15.     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
  16.     at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
  17.     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
  18.     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
  19.     at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
  20.     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
  21.     at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
  22.     at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
  23.     at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
  24.     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
  25.     at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
  26.     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
  27.     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
  28.     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
  29.     at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
  30.     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
  31.     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
  32.     at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
  33.     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
  34.     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
  35.     at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
  36.     at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
  37.     at java.lang.Thread.run(Thread.java:534)
  38. ----- Root Cause -----
  39. java.lang.NullPointerException
  40.     at org.apache.jsp.index_jsp._jspService(index_jsp.java:85)
  41.     at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
  42.     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
  43.     at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:204)
  44.     at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
  45.     at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
  46.     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
  47.     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
  48.     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
  49.     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
  50.     at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
  51.     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
  52.     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
  53.     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
  54.     at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
  55.     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
  56.     at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
  57.     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
  58.     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
  59.     at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
  60.     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
  61.     at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
  62.     at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
  63.     at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
  64.     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
  65.     at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
  66.     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
  67.     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
  68.     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
  69.     at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
  70.     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
  71.     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
  72.     at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
  73.     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
  74.     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
  75.     at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
  76.     at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
  77.     at java.lang.Thread.run(Thread.java:534)
  78.  
I suspect this error is due to the use of the following line in "index.jsp"
Expand|Select|Wrap|Line Numbers
  1.     InitialContext ctx = new InitialContext();
  2.  
I have also tried by putting this in a try-catch block. Again I got the same result.

After I got this error now I copied the "onlineres.xml" file into the the following directory.

Expand|Select|Wrap|Line Numbers
  1. C:\Tomcat\Apache Group\Tomcat 4.1\webapps
Now I restarted the servers, the start up servlets are getting loaded.

Again I accessed the index.jsp file using the following URL.

Expand|Select|Wrap|Line Numbers
  1. http://localhost:8888/onlineres/index.jsp
I got the result as expected. The page is getting displayed correctly.

I have the problem if I put the "onlineres.xml" file before restarting the server once after dropping the "onlineres.war" file. Why this is happening.

I think it is not good to restart the servers two times, one for unpacking the wars, and one after placing the "onlineres.xml" - the context file.

Please give me a solution.


Thanks in advance.

M. Jahabar Sadiq.
Dec 15 '08 #9
r035198x
13,262 8TB
That line is not the cause of the exception. If you read your exception trace, you'll see that a NullpointerException was thrown. That line doesn't throw a NullpointerException. Post your JSP code.
Dec 17 '08 #10
All codes are available in the zip file attached...
Dec 17 '08 #11
r035198x
13,262 8TB
I don't like downloading zip attachments form the forums. Like I said the nullpointer is in your index.jsp. Somewhere there (probably in the first few lines that use use Java code) you are dereferencing a null variable.
Dec 17 '08 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: N.K. | last post by:
Hi, I'm using Tomcat 7.2 and I'm trying to deploy an aplication that uses JSP and servlets. I'm actually trying to duplicate a production server but can't get it right. In the directory...
1
by: dansan | last post by:
We have a webservice that we have been deploying using the deployment project in Visual Studio. Now we are trying to deploy this service to a server that has multiple sites. I have looked...
9
by: Guy | last post by:
I have extended the datetimepicker control to incorporate a ReadOnly property. I have used the new keyword to implement my own version of the value property, so that if readonly == true then it...
2
by: Greg W. | last post by:
In our setup project, we have the standard web application folder, but we also have 4 web custom folders (virtual directories) that are created at the same level as the web application folder...
9
by: Steve Buster | last post by:
All right, I have read every forum, newsgroup etc about this issue and no one seems to know how to fix it. I am getting a "Server Application Unavailable" exception running my .NET 1.1...
3
by: Chris Dunaway | last post by:
A quick scan of the group did not immediately reveal an answer to my questions so here goes. First let me describe my app and then I'll ask the questions. I am writing a Windows Forms App (not...
9
by: Graham | last post by:
I have been having some fun learning and using the new Controls and methods in .Net 2.0 which will make my life in the future easier and faster. Specifically the new databinding practises and...
6
by: Sebastian Santacroce | last post by:
Is it posible to package MSDE with VB .net so that its part of the installation? If so, is there documentation somewhere? What about packaging the .net framework with the application as well? ...
1
by: Duncan | last post by:
Guys a little please, I'm creating a windows application that uses a webservice and WSE1.0 to talk to a database, currently this works fine when using localhost, I now want to test the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.