aspose file tools*
The moose likes BEA/Weblogic and the fly likes problems with servlets on Weblogic 6.1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "problems with servlets on Weblogic 6.1" Watch "problems with servlets on Weblogic 6.1" New topic
Author

problems with servlets on Weblogic 6.1

sanj singh
Ranch Hand

Joined: Jun 30, 2001
Posts: 129
Hi All
I have just downloaded the trial version of Weblogic 6.1 and started playing around with it.I am getting errors while accessing my servlet.
Here's my login.html file
<HTML>
<HEAD>
<TITLE>Document Title</TITLE>
</HEAD>
<BODY>
THIS IS THE LOGIN FORM
<FORM ACTION="/servlet/loginServlet" METHOD="GET">
ENTER NAME:
<INPUT TYPE="TEXT" NAME="loginName">
<br>
ENTER AGE:
<INPUT TYPE="TEXT" NAME="loginAge">
<br>
<INPUT TYPE="SUBMIT">
</FORM>
</BODY>
</HTML>
Here's the code for my servlet
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class LoginServlet extends HttpServlet{
public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
out.println("your name is"+req.getParameter("loginName"));
out.println("your age is "+req.getParameter("loginAge"));


}
}
Here's the web.xml file
<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>loginServlet</servlet-name>
<servlet-class>LoginServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>loginServlet</servlet-name>
<url-pattern>/loginServlet/*</url-pattern>
</servlet-mapping>
</web-app>

I have created the appropriate file structure and packaged all the files in login.war.
Can anybody tell me why I am getting errors.
Here's the error
Error 404--Not Found
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.4.5 404 Not Found
The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent.
If the server does not wish to make this information available to the client, the status code 403 (Forbidden) can be used instead. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address.

regards
sanj
SAFROLE YUTANI
Ranch Hand

Joined: Jul 06, 2001
Posts: 257
Did you deploy the .war file?
SAF
sanj singh
Ranch Hand

Joined: Jun 30, 2001
Posts: 129
Hi Safrole
Yes I have deployed the .WAR file
regards
sanj
SAFROLE YUTANI
Ranch Hand

Joined: Jul 06, 2001
Posts: 257
sanj,
The action URL should be ACTION="/loginServlet", NOT ACTION="/servlet/loginServlet"
SAF
sanj singh
Ranch Hand

Joined: Jun 30, 2001
Posts: 129
Hi Safrole
I tried that but still its not working
regards
sanj
SAFROLE YUTANI
Ranch Hand

Joined: Jul 06, 2001
Posts: 257
Ok, try this. Open the config.xml file for your app server in which you deployed the .war file. Check the <WebServer> element and make sure the DefaultWebApp attribute is assigned a value that point to the name of your .war file without the extenstion, of course. If the name of your .war file is "employee.war", the you should have DefaultWebApp="employee"
try that
SAF
sanj singh
Ranch Hand

Joined: Jun 30, 2001
Posts: 129
Hi Safrole
Here's my config.xml file

<?xml version="1.0" encoding="UTF-8"?>
<!--If your domain is active, please do not edit the config.xml file. Any changes made to that file while the domain is active will not have any effect on the domain's configuration and are likely to be lost. If your domain is inactive, you may edit this file with an XML editor. If you do so, please refer to the BEA Weblogic Server Configuration Reference documentation available from http://edocs.bea.com/wls/docs61/reference.html. In general, we recommend that changes to your configuration file be made through the Administration Console.-->
<Domain Name="mydomain">
<CustomRealm
ConfigurationData="server.host=ldapserver.example.com;membership.scope.depth=1;microsoft.membership.scope=sub;membership.filter=(|(&(memberobject=%M)(objectclass=memberof))(&am p;(groupobject=%M)(objectclass=groupmemberof)));group.dn=ou=Groups, o=ExampleMembershipDir;group.filter=(&(cn=%g)(objectclass=mgroup));server.principal=cn=Administrator, ou=Members, o=ExampleMembershipDir;user.dn=ou=Members, o=ExampleMembershipDir;user.filter=(&(cn=%u)(objectclass=member))"
Name="defaultLDAPRealmForMicrosoftSiteServer"
Notes="This is provided as an example. Before enabling this Realm, you must edit the configuration parameters as appropriate for your environment."
Password="{3DES}J6IyC6JImgXrI40KKS66sQ==" RealmClassName="weblogic.security.ldaprealmv2.LDAPRealm"/>
<PasswordPolicy Name="wl_default_password_policy"/>
<Log FileName="config/mydomain/logs/wl-domain.log" Name="mydomain"/>
<CustomRealm
ConfigurationData="user.filter=(&(uid=%u)(objectclass=person));user.dn=ou=people, dc=example, dc=com;server.principal=cn=Manager, dc=example, dc=com;membership.filter=(&(uniquemember=%M)(objectclass=groupofuniquenames));group.filter=(&(cn=%g)(objectclass=groupofuniquenames));server.host=ldapserver.example.com;gro up.dn=ou=groups, dc=example, c=com"
Name="defaultLDAPRealmForOpenLDAPDirectoryServices"
Notes="This is provided as an example. Before enabling this Realm, you must edit the configuration parameters as appropriate for your environment."
Password="{3DES}J6IyC6JImgXrI40KKS66sQ==" RealmClassName="weblogic.security.ldaprealmv2.LDAPRealm"/>
<Security GuestDisabled="false" Name="mydomain"
PasswordPolicy="wl_default_password_policy" Realm="wl_default_realm"/>
<CustomRealm
ConfigurationData="user.filter=(&(uid=%u)(objectclass=person));user.dn=ou=people, o=beasys.com;server.principal=uid=admin, ou=Administrators, ou=TopologyManagement, o=NetscapeRoot;membership.filter=(&(uniquemember=%M)(objectclass=groupofuniquenames));group.filter=(&(cn=%g)(objectclass=groupofuniquenames));server.host=ldapserver.example .com;group.dn=ou=groups, o=beasys.com"
Name="defaultLDAPRealmForNetscapeDirectoryServer"
Notes="This is provided as an example. Before enabling this Realm, you must edit the configuration parameters as appropriate for your environment."
Password="{3DES}J6IyC6JImgXrI40KKS66sQ==" RealmClassName="weblogic.security.ldaprealmv2.LDAPRealm"/>
<FileRealm Name="wl_default_file_realm"/>
<Application Deployed="true" Name="login" Path=".\config\mydomain\applications">
<WebAppComponent Name="login" Targets="myserver" URI="login.war"/>
</Application>
<Application Deployed="true" Name="certificate" Path=".\config\mydomain\applications">
<WebAppComponent Name="certificate" Targets="myserver" URI="certificate.war"/>
</Application>
<Application Deployed="true" Name="DefaultWebApp" Path=".\config\mydomain\applications">
<WebAppComponent Name="DefaultWebApp" Targets="myserver" URI="DefaultWebApp"/>
</Application>
<CustomRealm
ConfigurationData="user.filter=(&(cn=%u)(objectclass=person));user.dn=ou=people, o=example.com;server.principal=cn=admin, o=example.com;membership.filter=(&(member=%M)(objectclass=groupofuniquenames));group.filter=(&(cn=%g)(objectclass=groupofuniquenames));server.host=ldapserver.example.com;se rver.ssl=true;group.dn=ou=groups, o=example.com"
Name="defaultLDAPRealmForNovellDirectoryServices"
Notes="This is provided as an example. Before enabling this Realm, you must edit the configuration parameters as appropriate for your environment."
Password="{3DES}J6IyC6JImgXrI40KKS66sQ==" RealmClassName="weblogic.security.ldaprealmv2.LDAPRealm"/>
<Server ListenPort="7001" Name="myserver" NativeIOEnabled="true" TransactionLogFilePrefix="config/mydomain/logs/">
<Log FileName="config/mydomain/logs/weblogic.log" Name="myserver"/>
<SSL Enabled="true" ListenPort="7002" Name="myserver"
ServerCertificateChainFileName="config/mydomain/ca.pem"
ServerCertificateFileName="config/mydomain/democert.pem" ServerKeyFileName="config/mydomain/demokey.pem"/>
<WebServer DefaultWebApp="DefaultWebApp"
LogFileName="./config/mydomain/logs/access.log"
LoggingEnabled="true" Name="myserver"/>
<ServerDebug Name="myserver"/>
<ExecuteQueue Name="default" ThreadCount="15"/>
<KernelDebug Name="myserver"/>
<ServerStart Name="myserver"/>
</Server>
<SNMPAgent Name="mydomain"/>
<Realm FileRealm="wl_default_file_realm" Name="wl_default_realm"/>
<ApplicationManager Name="mydomain"/>
<JTA Name="mydomain"/>
</Domain>
SAFROLE YUTANI
Ranch Hand

Joined: Jul 06, 2001
Posts: 257
Yes, the value of DefaultWebApp is incorrect according to your config.xml file. Shut down your server, edit the config.xml file and make sure DefaultWebApp contains the correct value as I specified in my last message. Save and restart.
SAF
sanj singh
Ranch Hand

Joined: Jun 30, 2001
Posts: 129
Hi Safrole
But I can see that
<Application Deployed="true" Name="login" Path=".\config\mydomain\applications">
<WebAppComponent Name="login" Targets="myserver" URI="login.war"/>
</Application>

is present.
Regards
sanj
SAFROLE YUTANI
Ranch Hand

Joined: Jul 06, 2001
Posts: 257
Yes, it is deployed, but...
<WebServer DefaultWebApp="DefaultWebApp"
LogFileName="./config/mydomain/logs/access.log"
LoggingEnabled="true" Name="myserver"/>
..is obviously pointing to the wrong app. You need to change the value of DefaultWebApp in <WebServer>
SAF
sanj singh
Ranch Hand

Joined: Jun 30, 2001
Posts: 129
Hi Safrole
Thanks a lot for your help.Its working now.But could you please explain whats going on.I have alredy got this bit of xml code
<Application Deployed="true" Name="login" Path=".\config\mydomain\applications">
<WebAppComponent Name="login" Targets="myserver" URI="login.war"/>
</Application>
Does this work like <Contect path="" blah....blah>
in Tomcat?
Regards
sanj
SAFROLE YUTANI
Ranch Hand

Joined: Jul 06, 2001
Posts: 257
I have no idea how it works in Tomcat. I just started learning all this Weblogic Server stuff myself, so just keep exploring and learn more. I'm glad it's working for you.
SAF
Tualha Khan
Ranch Hand

Joined: Nov 22, 2000
Posts: 287
I started deploying servlets in weblogic a few days ago, in starting, I faced some glitches, but now, I am a bit confident. A Few tips:
First, I do not anymore deploy my web-apps in production mode. I suggest you switch to "Development mode" and then go ahead, doing so automatically redeploys your app when any changes are made to it. For doing this, you edit your <domain>\startweblogic.cmd file and search for "set STARTMODE=true". Set it's value to false and then start your server. You should in the end see "blahblahblah............started in Development Mode".
Secondly, I don't know whether I am right or wrong, but I never had to change the "DefaultWebApp" setting. It works for me like that only. Anybody, please clarify this, if I am wrong.


SCJP2, BEA WLS 6.0, DB2 UDB 7.1
sanj singh
Ranch Hand

Joined: Jun 30, 2001
Posts: 129
Hi Tualha
I tried your way but still I am having problems.
regards
sanj
Tualha Khan
Ranch Hand

Joined: Nov 22, 2000
Posts: 287
OK, I will try your code on my machine, and see what could be the problem. Meanwhile, one more tip which does a lot of help to my development environment:
Firstly, Whenever you start your weblogic server, then remove the old log files from <domain>\logs directory.
Secondly, in case of any doubt, whether why your application did not kickstart, do check the server log. This can be done by right-Clicking the <server-name> from the left panel and then selecting "View Server Log".

Bye,
Tualha Khan
Tualha Khan
Ranch Hand

Joined: Nov 22, 2000
Posts: 287
Hey,
I made very minor changes in your code. Just have a look at the source code files below:
========== Sanj.jsp ==================
<HTML>
<HEAD>
<TITLE>Document Title</TITLE>
</HEAD>
<BODY>
THIS IS THE LOGIN FORM
<FORM ACTION="LoginServlet" METHOD="GET"> //Changes done here
ENTER NAME:
<INPUT TYPE="TEXT" NAME="loginName">
<br>
ENTER AGE:
<INPUT TYPE="TEXT" NAME="loginAge">
<br>
<INPUT TYPE="SUBMIT">
</FORM>
</BODY>
</HTML>

==============================================
============ LoginServlet.java ===============
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class LoginServlet extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,IOException
{
PrintWriter out=new PrintWriter(res.getWriter()); //Changes done Here
res.setContentType("text/html");
out.println("your name is"+req.getParameter("loginName"));
out.println("your age is "+req.getParameter("loginAge"));
out.flush();//Changes done here
}
}
=======================================
============ web.xml ==================
<?xml version="1.0" ?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<webapp>
<servlet>
<servlet-name>LoginServlet</servlet-name>
<servlet-class>LoginServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/LoginServlet</url-pattern>
</servlet-mapping>
</webapp>
===========================================

This is a very basic servlet app to starting with. One more thing, make sure that your deployment descriptors, DTD declaration part is ALWAYS in one line. It should not be broken in 2 lines. What you can do is after going through it, make your custom changes to the code and try to run it once more.

Bye,
Tualha Khan
Tualha Khan
Ranch Hand

Joined: Nov 22, 2000
Posts: 287
And one more thing, I hope you are aware of the directory structure for your web-app/ejb's
Goodluck & Bye,
Tualha Khan
sanj singh
Ranch Hand

Joined: Jun 30, 2001
Posts: 129
Hi Tualha
Is it necessary to define
<servlet-mapping>
..........
</servlet-mapping>
As far as I know its not necessary...but then I might be wrong.
regards
sanj
Tualha Khan
Ranch Hand

Joined: Nov 22, 2000
Posts: 287
I really don't know this. But I will look for this in the specifications and let you know. BTW, did it work or not??
Bye,
Tualha Khan
Tualha Khan
Ranch Hand

Joined: Nov 22, 2000
Posts: 287
Yes, the <servlet-mapping> tag is mandatory. Look at this link for more info:
Servlet Mapping
Bye,
Tualha Khan
ananthakrishnan krishnan
Greenhorn

Joined: Jun 10, 2002
Posts: 9
Hi,
I got the 6.1 free download version of web logic too and I played around with it.
There is one tutorial, called deployment.pdf where we deploy an exploded banking application. The code (in banking.zip) and the pdf was all procured from the bea site as a part of the download of the documentation for web logic. This application is not deployed via a TAR file as Sanj had tried nor via an EAR file. It is directly deploying an exploded application, but its got the servlet bit and all that.
After fully executing the tutorial, I get the smae error as Sanj got (that Safrole solved with the Default Web App setting). The error is
Error 404--Not Found
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.4.5 404 Not Found
The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent.
If the server does not wish to make this information available to the client, the status code 403 (Forbidden) can be used instead. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address.
If anyone has tried this deployment.pdf and got it working, can you let me know what is it that I am missing in this? I am not sure if the html itself is right but I am not too comfortable with HTML to debug that. Can some one please help me out with this?
Thanks,
Ananth
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problems with servlets on Weblogic 6.1