cancel
Showing results for 
Search instead for 
Did you mean: 

Error: Requested resource does not exist

Murali_Shanmu
Active Contributor
0 Kudos

Hi

I am using a J2EE application to connect to R/3. I am receiving the above mentioned error. I created a Web Module project. In that i created a package com.training.examples.servlet.GetSalesPage.java . This is going to be my controller.

I also created a JSP page with a submit button. Once i click on the button, i get the following message " The requested resource does not exist."

In the JSP page i used the follwing Tag :

<form action="<%= request.getContextPath() %>/servlet/GetSalesPage" method="POST">

I know this is will be tough to understand with me just giving me a bigger picture. I am ready to give the code if anyone wishes to check it out also.

Any help would be rewarded.

Murali.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Murali,

I think you are trying to call a servlet that you would have created in the source directry of the web module. And the path to that servlet has not been defined properly in the web.xml file.

Please check that you have a proper descriptor of the serlet in the web.xml file.

You can post the web.xml file, that will help me to see the error, also tell the complete path to the servlet you are calling.

best regards,

Guru.

PS : Give points for usefull answers.

Murali_Shanmu
Active Contributor
0 Kudos

Hi

Thanks Vyara and Guru. I am actually trying to replicate the example of "Creating first J2EE application - flight bookings". So i am getting stuck with the basic things.

Ur inputs were valuable.

I added the Servlet in the Web.xml

Here is my Web.XML

<?xml version="1.0" encoding="UTF-8"?>

<!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>

<display-name>WEB APP</display-name>

<description>WEB APP description</description>

<servlet>

<servlet-name>GetSalesPage</servlet-name>

<servlet-class>com.training.examples.servlet.GetSalesPage</servlet-class>

</servlet>

<servlet>

<servlet-name>GetSalesList.jsp</servlet-name>

<jsp-file>/GetSalesList.jsp</jsp-file>

</servlet>

<ejb-ref>

<ejb-ref-name>ejb/SalesEJBBean</ejb-ref-name>

<ejb-ref-type>Session</ejb-ref-type>

<home>com.training.examples.SalesEJBHome</home>

<remote>com.training.examples.SalesEJB</remote>

<ejb-link>SalesBean</ejb-link>

</ejb-ref>

</web-app>

Here is ejb-jar.xml in my EJB Project

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

<ejb-jar>

<description>EJB JAR description</description>

<display-name>EJB JAR</display-name>

<enterprise-beans>

<session>

<ejb-name>SalesEJBBean</ejb-name>

<home>com.training.examples.SalesEJBHome</home>

<remote>com.training.examples.SalesEJB</remote>

<local-home>com.training.examples.SalesEJBLocalHome</local-home>

<local>com.training.examples.SalesEJBLocal</local>

<ejb-class>com.training.examples.SalesEJBBean</ejb-class>

<session-type>Stateless</session-type>

<transaction-type>Bean</transaction-type>

<resource-ref>

<res-ref-name>eis/SAPJRADemoFactory</res-ref-name>

<res-type>javax.resource.cci.ConnectionFactory</res-type>

<res-auth>Container</res-auth>

<res-sharing-scope>Shareable</res-sharing-scope>

</resource-ref>

</session>

</enterprise-beans>

</ejb-jar>

Now i am able to get the JSP page. When i key in data and click on submit button, i get the following error:

<b>

"Couldn't access bean salesEJB: Path to object does not exist at java:comp, the whole lookup name is java:comp/env/ejb/SalesEJB"</b>

I have setup eis/SAPJRADemoFactory for my Flight Application and it is working fine. I am trying to use the same setting for my application also.

Here is my GetSalesPage SERVLET Page :

/*

  • Created on May 9, 2006

*

  • To change the template for this generated file go to

  • Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments

*/

package com.training.examples.servlet;

import java.io.IOException;

import java.rmi.RemoteException;

import java.util.List;

import javax.ejb.CreateException;

import javax.naming.InitialContext;

import javax.naming.NamingException;

import javax.servlet.RequestDispatcher;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import javax.servlet.http.HttpSession;

import com.training.examples.SalesEJB;

import com.training.examples.SalesEJBHome;

import com.training.examples.SalesSelection;

/**

  • @author MShanmugham

*

  • To change the template for this generated type comment go to

  • Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments

*/

public class GetSalesPage extends HttpServlet {

/* names of jsp pages */

private static final String SELECT_SALES_ORDER= "/GetSalesList.jsp";

// JNDI names

private static final String PREFIX = "java:comp/env/ejb/";

private static final String SALES_BEAN = "SalesEJB";

public static final String BYF_SALES_SELECTION = "byf_sales_selection";

public static final String BYF_SALES_LIST = "byf_sales_list";

public static final String BYF_ERROR_MESSAGE = "byf_error_message";

// class members

private RequestDispatcher dispatcher = null;

protected void doGet(

HttpServletRequest request,

HttpServletResponse response)

throws ServletException, IOException {

doPost(request, response);

}

protected void doPost(

HttpServletRequest request,

HttpServletResponse response)

throws ServletException, IOException {

HttpSession session = request.getSession(true);

if(request.getParameter("select") != null) {

// select or GET_SALES event -> retrieve sales list, display 1. page

getSalesList( request, session);

dispatcher = request.getRequestDispatcher(SELECT_SALES_ORDER);

dispatcher.forward(request, response);

}

}

private void getSalesList( HttpServletRequest request, HttpSession session) {

try {

// get bean SalesEJB

InitialContext initialcontext = new InitialContext();

SalesEJBHome salesHome = (SalesEJBHome) initialcontext.lookup( PREFIX + SALES_BEAN);

SalesEJB sales = salesHome.create();

// get flight list

String salesOrg = (String) request.getParameter("salesOrg");

String customerNo = (String) request.getParameter("customerNo");

SalesSelection salesSelection = null;

if( (salesOrg != null) && (customerNo != null)) {

salesSelection = new SalesSelection( salesOrg, customerNo);

session.setAttribute( BYF_SALES_SELECTION,salesSelection);

} else {

salesSelection = (SalesSelection) session.getAttribute( BYF_SALES_SELECTION);

}

List salesList = sales.getSalesList(salesSelection);

if( salesList == null) {

request.setAttribute(BYF_ERROR_MESSAGE,"No records found!");

}

// set session and request attribute

session.setAttribute( BYF_SALES_SELECTION, salesSelection);

session.setAttribute( BYF_SALES_LIST, salesList);

}catch(NamingException exc) {

request.setAttribute(BYF_ERROR_MESSAGE, "Couldn't access bean salesEJB: " + exc.getMessage());

}catch(CreateException exc) {

request.setAttribute(BYF_ERROR_MESSAGE, "Couldn't create bean salesEJB: " + exc.getMessage());

}catch(RemoteException exc) {

request.setAttribute(BYF_ERROR_MESSAGE, "Bean salesEJB returned error message: " + exc.detail.getMessage());

}

}

}

Here is the only JSP I am using GetSalesList.jsp

<%@ page language="java" %>

<%@ page import="com.training.examples.servlet.GetSalesPage"%>

<%@ page import="com.training.examples.SalesSelection"%>

<%@ page import="com.training.examples.salesData"%>

<%

// get the sales order selection data and the list of selected Orders

SalesSelection salesSelection = (SalesSelection) session.getAttribute( GetSalesPage.BYF_SALES_SELECTION);

List salesList = (List) session.getAttribute( GetSalesPage.BYF_SALES_LIST);

// get the error message

String errorMessage = (String) request.getAttribute( GetSalesPage.BYF_ERROR_MESSAGE);

%>

<html>

<head>

<title> Fetch Orders </title>

</head>

<body>

<fieldset>

<legend>

<b> Give the Sales Org and Customer Number </b>

</legend>

<form action="<%= request.getContextPath() %>/servlet/GetSalesPage" method="POST">

Sales Organization:

<% if(salesSelection == null) { %>

<input type="text" size="16" name="salesOrg" value="">

<% } else { %>

<input type="text" size="16" name="salesOrg" value="<%= salesSelection.getSalesOrg() %>">

<% } %>

Customer Number:

<% if(salesSelection == null) { %>

<input type="text" size="16" name="customerNo" value="">

<% } else { %>

<input type="text" size="16" name="customerNo" value="<%= salesSelection.getCustomer() %>">

<% } %>

<br>

<br>

<input type="submit" name="select" value="Select">

<br>

<% if(salesList != null) { %>

<table border="1" box="all">

<tr>

<th rowspan="2">&nbsp</th>

<th rowspan="2">Sales Doc</th>

<th rowspan="2">Item No</th>

<th colspan="2">Material</th>

</tr>

<% for(int i = 0; i < salesList.size(); i++) { %>

<tr>

<td>

<input type="radio" name="saleslist">

</td>

<td><%= ((salesData)salesList.get(i)).getSd_doc() %></td>

<td><%= ((salesData)salesList.get(i)).getItm_number() %></td>

<td><%= ((salesData)salesList.get(i)).getMaterial() %></td>

</tr>

<br>

<% } %>

</table>

<br><br>

<input type="submit" name="continue" value="Continue">

</form>

<% } %>

<% if (errorMessage != null) { %>

<br>

<tr>

<td colspan="3">

<font color="#D00000"><b><%= errorMessage %></b></font>

</td>

</tr>

<% } %>

</fieldset>

<p>

</body>

</html>

Can you please help me out.

Murali.

Murali_Shanmu
Active Contributor
0 Kudos

Hi

I also checked up Visual Admin to see if the Bean is properly deployed.

I went to Cluster &#8594; <Server Node> &#8594; Services &#8594; Deploy.

Clicked on the Runtime tab and choose Server * &#8594; EJBContainer. Under that i found a tick mark aginst my EAR file. I also found the same under Runtime tab and Server * &#8594; servlet_jsp for my corresponding Web Application.

I am still wondering why i am getting the error.

Murali.

Former Member
0 Kudos

Hi Murali,

Lets try to solve the problems one by one.

First since you are not able to access your stateless session bean, i think you are accessing it through wrong name, try the name "SalesEJBBean" instead of "SalesEJB".

Best regards,

Guru.

Murali_Shanmu
Active Contributor
0 Kudos

Hi

It was my mistake. I changed the Bean name to SalesEJBBean.

Now i get this error:

Couldn't access bean salesEJB: Exception during lookup operation of object with name webContainer/applications/sap.com/SalesWAR/SalesOrder/java:comp/env/ejb/SalesEJBBean, cannot resolve object reference.

Murali

Murali_Shanmu
Active Contributor
0 Kudos

Hi

If you wish i can send you across the source code. You can mail me your emailID at murlionline@gmail.com

Murali

Former Member
0 Kudos

Hi,

Please send across the sorce code to me at gurvinderd@hexaware.com. I will look into the project, correct and send acroos the correct files.

Thanks,

Guru.

PS: Points please

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Murali,

Are you able to access your servlet directly without requesting the jsp? I suspect that you have made a mistake in the definition of the servlet in the web.xml. You may check this as well.

What is the requested resource that is not found - is it the servlet or something else?

Regards

Vyara