This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Servlets and the fly likes problem in deploying WAR files in server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "problem in deploying WAR files in server" Watch "problem in deploying WAR files in server" New topic
Author

problem in deploying WAR files in server

arpan bhattacharya
Greenhorn

Joined: Oct 05, 2009
Posts: 4
Hi,

I want to deploy my website in the server. When I create WAR file and deploy in the localhost it works fine. But the same WAR file does not run in Tomcat server.
I try to access it like

in local server:

http://localhost:8080/myApp/index.html

it works fine

but in webhosting server:

http://www.mysitename.com/myApp/index.html

it gives me 404 error.

I deployed the WAR file inside 'www' folder.

The Tomcat version in 5.5.28 in local system and 5.5.20 in the server. JVM version is same in both.
Please help me out.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Is the "www" folder where it's supposed to be put on the remote server to deploy it?
arpan bhattacharya
Greenhorn

Joined: Oct 05, 2009
Posts: 4
Yes, thats what the web-hosting providers mentioned. And they confirmed this later too.
pankaj vijay
Ranch Hand

Joined: Apr 01, 2008
Posts: 75
as i think if you will put war inside www folder then url will be
http://www.mysitename.com/www/myApp/index.html
your index.html file should be on default location.Try to put war on root ...


Pankaj Vijay (SCJP, SCBCD)
Learn Core Java,Learn Servlet Jsp, SCJP Questions,Struts Tutorial
arpan bhattacharya
Greenhorn

Joined: Oct 05, 2009
Posts: 4
'www' is the default package provided by the web-hosting where i should put all my files.
I tried putting my 'index.html' just inside the 'www'. And accessed it successfully with the url '...//mysitename.com/index.html' not '...//mysitename.com/www/index.html' (accessing it this way does not solve my problem). If i put my 'index.html' outside 'www' folder, server can't identify that.

So it proves that 'www' is the root folder for me.

but if i create a WAR i.e. myApp.war and put inside 'www' folder, then server expand in such a manner that a folder named 'myApp' gets created inside 'www' folder, and all my files inside 'myApp' folder.

Now

'...//mysitename.com/index.html'
'...//mysitename.com/myApp/index.html'
'...//mysitename.com/www/index.html'
'...//mysitename.com/www/myApp/index.html'

none of them works.

Now if i place the 'myApp.war' outside 'www' folder, then after expansion by the server 'myApp' folder gets created outside 'www' and there is nothing inside 'www'. So nothing can be accessed.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
If "www" is the physical directory name for you to deploy web applications, then it shouldn't
be a part of the URL.


I tried putting my 'index.html' just inside the 'www'. And accessed it successfully with the url '...//mysitename.com/index.html'


Ok, so this is working.

You should be able to see the "exploded" web application directories and files in the www folder, e.g. WEB-INF

but if i create a WAR i.e. myApp.war and put inside 'www' folder, then server expand in such a manner that a folder named 'myApp' gets created inside 'www' folder, and all my files inside 'myApp' folder.


Take the exploded contents of the WAR and put it directly in the www folder and delete the myApp folder.

arpan bhattacharya
Greenhorn

Joined: Oct 05, 2009
Posts: 4
Hi,

Thanks for the advise. I tried this way. and It worked. Thanks a lot.

After deploying in such way there was another problem. Though I found a solution of that, I thought I should put up both the problem and solution here.


The java classes were not readable from the jsp inside any folder structure.

inside root
i have /jsp/mypage.jsp

there i am using a page import to access a class like the way below:

<%@ page import ="myPackage.MyClass"%>

And MyClass.java was present inside /WEB-INF/classes/myPackage/MyClass.java

But while running the application the server was not able to identify this class from the jsp.
It was throwing error in the import line itself.

In localhost the same structure is running quite well. Only after deploying to the production server the problem arises.

So i put all my JSPs in the root directory of my application (took them out of the /jsp folder). Then it was able to recognize the class imports. and everything rest worked well.

I still don't understand why the previous structure didn't work in the server. If anyone has any idea, please let me know.



Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16158
    
  21

I think someone's confused here. "www" is the name that's commonly used for the Apache http server. That's NOT a Java appserver - it's the generic webserver known and loved the world over. And it has absolutely no idea how to run Java code, JSPs or anything java-related.

The Tomcat server comes with a directory named "webapps". The simplest way to deploy a WAR is to drop a copy of it into the "webapps" directory. If you do that, and don't have a META-INF/context.xml file in your WAR starting otherwise, the context name for the deployed app. So for a WAR named "myapp.war", the URL form would be http://hostname:8080/myapp.

It's possible that someone could have reconfigured Tomcat to use a "www" directory instead of $CATALINA_BASE/webapps, but I don't think it's likely. It's much more probably that they didn't realist the difference between Apache HTTP Server and Apache Tomcat.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in deploying WAR files in server