• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem in deploying WAR files in server

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is the "www" folder where it's supposed to be put on the remote server to deploy it?
 
arpan bhattacharya
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, thats what the web-hosting providers mentioned. And they confirmed this later too.
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ...
 
arpan bhattacharya
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
'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.
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.



 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic