• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

deploying servlet in WAS 4.0

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I've just upgraded to WAS v4 & deploying applications is very different to 3.5 so I thought I'd try deploying a simple servlet to get started. This is what I did:-
1. exported the class to a directory from VAJ to give my class file
2. created a directory in the installableapps dir on the server & put the class in there
3. used the Appication Assembly tool to build a .war file
4. used AAT to include the war file into a .ear file
5. used the seappinstall program (we just have the Advanced Single Server Edition) to install the .ear file
It all looks OK - there is a new ear directory created in the
installedapps dir.
I've stopped and started the server & I can see the application via the web console.
The server is running OK - I can run the WSsamples applications eg the snoop servlet but when I try to access my servlet I get 404 file not found. It suggests the servlet mapping is not right but I've tweaked it loads of times & nothing seems to have any effect.
Any advice you can give will be very gratefully received - I am really running out of ideas. If I can't get one simple servlet
to work then what chance will I have with a complex application!!
thanks
Steve
 
Steve McCain
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any help with this would be really appreciated!!
I can't help thinking I'm missing something obvious.
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Steve McCain:
any help with this would be really appreciated!!
I can't help thinking I'm missing something obvious.


Well, the steps are OK, although generally EARS and WARS aren't built in the installable apps directory. However, that shouldn't be a problem. Two things:
(1) Would you mind posting your web.xml and showing us what URL you are trying to invoke?
(2) When you start the app server admin console, do you see the application as being available?

Kyle Brown

------------------
Kyle Brown,
Editor of Enterprise Java (tm) Programming with IBM Websphere
 
Steve McCain
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kyle,
web.xml contains:-

< ?xml version="1.0" encoding="UTF-8"?>
< !DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">;
< web-app id="WebApp_ID">
< display-name>DecisionMakerApplication< /display-name>
< servlet id="Servlet_1">
< servlet-name>DecisionMaker< /servlet-name>
< servlet-class>DecisionMaker< /servlet-class>
< /servlet>
< servlet-mapping id="ServletMapping_1">
< servlet-name>DecisionMaker< /servlet-name>
< url-pattern>/DecMakerServlet< /url-pattern>
< /servlet-mapping>
< servlet-mapping id="ServletMapping_2">
< servlet-name>DecisionMaker< /servlet-name>
< url-pattern>/DecMakerServlet/*< /url-pattern>
< /servlet-mapping>
< /web-app>
[/CODE]
I'm using the following URL from a browser on the server machine:-
http://localhost/DMApp/DecMakerServlet/*
where /DMApp is the context root defined for the web application in the ear file.
Thanks
Steve McCain
University of Bradford, UK
--------------------------------------
Just Edited your Web.xml contents so that the tags are visible

[This message has been edited by Rahul Mahindrakar (edited September 25, 2001).]
 
Steve McCain
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I forgot to mention that yes I can see the application from the
admin console & I've tried explicity starting it -
I get a message saying its started but I still yet the 404 error
Steve
 
Steve McCain
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the url I'm using is actually
http://localhost/DMApp/DecMakerServlet
S
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Steve McCain:
Kyle,
web.xml contains:-
(removed)
Thanks
Steve McCain
University of Bradford, UK


Steve,
There are a few things about this that concern me:
(1) Did you declare a package name in your servlet? The servlet class tag must use the fully qualified class name.
(2) Try using load on startup (opening braces removed)
load-on-startup>1 /load-on-startup>
and then add a System.out.println() method in the init() method of your servlet -- then look in the standard output and see if you have an error (perhaps class not found) in your output. If you do, then that's the problem. If not, we have to look elsewhere...
Kyle Brown

------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
[This message has been edited by Kyle Brown (edited September 19, 2001).]
 
Author
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To help trace this, go to your <WAS install root>/bin directory and run startServerBasic
This launches the server directly from the command line and you can see all of the trace messages. Usually there will be an indication that the "WebGroup" couldn't be started, and why!
Good luck.
------------------
Gary Craig,
Author of Enterprise Java (tm) Programming with IBM Websphere
 
Steve McCain
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for tips. I've added some System.out.println calls
in a few methods. The init() method is being called when the server starts - I can see output in the stdout.log but I can't see anything printed from any other method so it does look like the servlet is never invoked from the url I'm using.
I've re-exported & re-installed the class so that the class is now qualified with the package.
I can't see any ClassNotFound errors - I've only looked in stdout.log and activity.log.
Any other ideas?
thanks
Steve
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Steve McCain:
Thanks for tips. I've added some System.out.println calls
in a few methods. The init() method is being called when the server starts - I can see output in the stdout.log but I can't see anything printed from any other method so it does look like the servlet is never invoked from the url I'm using.
I've re-exported & re-installed the class so that the class is now qualified with the package.
I can't see any ClassNotFound errors - I've only looked in stdout.log and activity.log.
Any other ideas?
thanks
Steve


Ok -- there are 2 places a 404 can be thrown; (1) is when the browser can't reach the servlet, and (2) is when the servlet can't find a JSP to forward to. Are you using a JSP in this servlet? Can you add a System.out.println() in the doGet() method to see if you make it that far?
Kyle Brown

------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do u have to create a war file evenfor one servlet to be deployed ??
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by deneb shah:
do u have to create a war file evenfor one servlet to be deployed ??


Yes. That's J2EE for you.
------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
 
Steve McCain
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kyle,
there is no JSP - its just a very simple servlet (actually one given as an example in one of IBM's VAJ courses). It just writes
to a PrintWriter of the reponse.
doGet() just calls processRequest() which has a debug system.out.println call the output of which I never see
when I try to access the servlet from the mapped URL so
I assume doGet() is not reached. Hence my assumption that the
URL to servlet mapping is not correct. The servlet works OK
in the VisulaAge WTE.

thanks
Steve
 
Ranch Hand
Posts: 1871
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please post your servlet code
Thanks
------------------

Mahindrakar
IBM Application Server & Developer Forum Moderator

Consultant - Zensar Technologies ,Pune India.
SCJP2, SCJD2 & SCJEA (Part I)
 
Rahul Mahindrakar
Ranch Hand
Posts: 1871
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Steve,
Could you please not write to my mail ID do the needful on the forum itself.
Thanks
Anyhow I am posting the code over here and am going through it to see what could be the problem.

 
Rahul Mahindrakar
Ranch Hand
Posts: 1871
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
< servlet-class>DecisionMaker< /servlet-class>
I find that there is no package name in your servlet class. It should be Package.className. Is something missing. I think it should be
web.DecisionMaker

Rahul.
 
Steve McCain
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rahul,
Kyle suggested this earlier & I did fix it to include
the package name (see earlier posting), I still get the
404 error
thanks
Steve
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've GOT IT!
Boy this one took me a while to chase down -- I ended up duplicating your code and had the same problem -- It took about an hour's worth of digging to figure out what was going on.
It appears that SEAppInstall does not update the plugin-configuration file for the web server. Therefore if you use "http://localhost/DMApp"; it won't find anything since the http server plugin doesn't know to route things under DMApp to the applciation server.
To fix, this run:
genplugincfg -configfile C:\YourPathTo\WebSphere\AppServer\config\server-cfg.xml
This is described in InfoCenter section 6.6.45.6: Regenerating the Web server plug-in configuration:
"Failure to regenerate the plug-in after introducing a new application will likely result in a "404 File Not Found" error when a user tries to access the new Web application."
Good luck! I think this should fix you up.
Kyle Brown
------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
 
Rahul Mahindrakar
Ranch Hand
Posts: 1871
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow Kyle that was a lot of work and great work too.

Rahul.
 
Steve McCain
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kyle,
many many thanks for cracking the problem - its working OK now.
I would not have got there myself thats for sure.
I chose to deploy a simple servlet as a 'learning exercise' and
it has certainly been that!
Now for a more complex example .....
cheers
Steve
 
deneb shah
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i am used to deploying in weblogic and now since have got the project on ibm websphere i have to start using websphere 4.0
i want to deploy servlet into this. is there any tutorials for me to deploy these in apps server
deneb
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic