wood burning stoves 2.0*
The moose likes BEA/Weblogic and the fly likes Problem accessing a servlet in weblogic Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "Problem accessing a servlet in weblogic" Watch "Problem accessing a servlet in weblogic" New topic
Author

Problem accessing a servlet in weblogic

Tony Evans
Ranch Hand

Joined: Jun 29, 2002
Posts: 573
When I try to access a servlet via weblogic 8.1 I get the following error:


Found no context for "/servlet/brokearage.broker.co.servlet.broker.TestServlet". This request does not match the
context path for any installed Web applications, and there is no default Web application configured.>

These are the steps I took



1) Created a servlet

package brokearage.broker.co.servlet.broker;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class TestServlet
{

public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
PrintWriter out = response.getWriter();
out.println("Broker Up and Running");
}


}

2) Created a web.xml file

<?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">

<web-app>
<display-name>TestServlet</display-name>
<description>TestServlet</description>
<servlet>
<servlet-name>TestServlet</servlet-name>
<servlet-class>brokearage.broker.co.servlet.broker.TestServlet</servlet-class>
</servlet>
</web-app>


3) Jarred it into a war file : BrokerWAR.war

META-INF\MANIFEST.MF (Empty)
WEB-INF\web.xml
WEB-INF\classes\brokearage\broker\co\servlet\broker\TestServlet.class


4) Jarred the war file into a EAR file
BrokerWAR.war in the top directory

5)Edited the application.xml

<!DOCTYPE application PUBLIC '-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN' 'http://java.sun.com/dtd/application_1_3.dtd'>
<application>
<display-name/>
<module>
<ejb>BrokerEJB.jar</ejb>
</module>
<module>
<java>TradeJar.jar</java>
</module>
<module>
<web>
<web-uri>BrokerWAR.war</web-uri>
<context-root>BrokerWAR</context-root>
</web>
</module>
</application>


6) Called the servlet with the following url:

http://localhost:11001/servlet/brokearage.broker.co.servlet.broker.TestServlet

Thanks for any help

Tony
Tony Evans
Ranch Hand

Joined: Jun 29, 2002
Posts: 573
In weblogic console I get the following

This page allows you to view the general configuration of this Web Application module.
Name: BrokerWAR
The name of this Web application deployment.
Context Root: (No Value Assigned)
The URI prefix used in HTTP requests for resources that are part of this Web application module.
Path: C:\domain\brokerdomain\applications\BrokerEAR.ear\BrokerWAR.war
The path, located on the Administration Server, of the original source files for this Web application module.

So it can see my war file but states that no Context Root: (No Value Assigned)

Where can I assign the Context Root.

I thought it was the assigned in the ear : application:


<!DOCTYPE application PUBLIC '-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN'
'http://java.sun.com/dtd/application_1_3.dtd'>
<application>
<display-name></display-name>
<module>
<ejb>BrokerEJB.jar</ejb>
</module>
<module>
<java>TradeJar.jar</java>
</module>
<module>
<web>
<web-uri>BrokerWAR.war</web-uri>
<context-root>BrokerWAR</context-root>
</web>
</module>
</application>
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8836
    
    7

You can also create a weblogic.xml file to declare the context root:
weblogic.xml documentation


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
<!DOCTYPE application PUBLIC '-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN' 'http://java.sun.com/dtd/application_1_3.dtd'>
<application>
<display-name/>
<module>
<ejb>BrokerEJB.jar</ejb>
</module>
<module>
<java>TradeJar.jar</java>
</module>
<module>
<web>
<web-uri>BrokerWAR.war</web-uri>
<context-root>BrokerWAR</context-root>
</web>
</module>
</application>

6) Called the servlet with the following url:

http://localhost:11001/servlet/brokearage.broker.co.servlet.broker.TestServlet


Your application context root was declared as BrokerWAR, but you're using the servlet as your context root in your servlet call. Also, we access the servlet by the servlet-name in the web.xml rather than it's fully qualified name.


SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem accessing a servlet in weblogic
 
Similar Threads
Java Applets as Application Clients
Basic Servlet question
error delploying ear file on JBOSS 3.0.8
Problem making a class in another jar visiable to a ejb in its ejb jar
Learn to deploy EJBs on JBOSS