Problem invoking servlet

D

dinesh

Hello.
I'm trying to invoke a servlet. I get the following error:
javax.servlet.ServletException:
[HTTP:101250][ServletContext(id=371807,name=BibleApp,context-path=/BibleApp)
]: Servlet class /com/brainysoftware/burnaby/ControllerServlet for servlet
ControllerServlet could not be loaded because a class on which it depends
was not found in the classpath
C:\bea\user_projects\infologic1\applications\BibleApp;C:\bea\user_projects\i
nfologic1\applications\BibleApp\WEB-INF\classes.
java.lang.NoClassDefFoundError:
/com/brainysoftware/burnaby/ControllerServlet (wrong name:
ControllerServlet).
at weblogic.servlet.internal.ServletStubImpl.prepareServlet
----------
web.xml
<!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>simple</servlet-name>
<jsp-file>simplePage.jsp</jsp-file>

</servlet>

<servlet>
<servlet-name>ControllerServlet</servlet-name>
<servlet-class>com.brainysoftware.burnaby.ControllerServlet</servlet-class>
<!-- Define initial parameters that will be loaded into
the ServletContext object in the controller servlet -->
<init-param>
<param-name>base</param-name>
<param-value>http://localhost:7001/BibleApp/ControllerServlet</param-value>
</init-param>
<init-param>
<param-name>jdbcDriver</param-name>
<param-value>weblogic.jdbc.mssqlserver4.Driver</param-value>
</init-param>
<init-param>
<param-name>imageUrl</param-name>
<param-value>http://localhost:7001/BibleApp/images/</param-value>
</init-param>
<init-param>
<param-name>dbUrl</param-name>
<param-value>jdbc:weblogic:mssqlserver4:users@COMPAQSERVER</param-value>
</init-param>
<init-param>
<param-name>dbUserName</param-name>
<param-value>dinesh</param-value>
</init-param>
<init-param>
<param-name>dbPassword</param-name>
<param-value>werty69</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>test</servlet-name>
<jsp-file>menu_1.jsp</jsp-file>
</servlet>

<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>HelloServlet</servlet-class>
</servlet>

<servlet>
<servlet-name>ShowEmployees</servlet-name>
<servlet-class>ShowEmployees</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/helloservlet</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>test</servlet-name>
<url-pattern>/test</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>simple</servlet-name>
<url-pattern>/simple</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ShowEmployees</servlet-name>
<url-pattern>/ShowEmployees</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>ControllerServlet</servlet-name>
<url-pattern>/controlIt</url-pattern>
</servlet-mapping>

</web-app>
--------------
ControllerServlet.class

import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import com.brainysoftware.burnaby.DbBean;

public class ControllerServlet extends HttpServlet {

/**Initialize global variables*/
public void init(ServletConfig config) throws ServletException {

System.out.println("initializing controller servlet.");

ServletContext context = config.getServletContext();
context.setAttribute("base", config.getInitParameter("base"));
context.setAttribute("imageUrl", config.getInitParameter("imageUrl"));

// instantiating the DbBean
DbBean dbBean = new DbBean();
// initialize the DbBean's fields
dbBean.setDbUrl(config.getInitParameter("dbUrl"));
dbBean.setDbUserName(config.getInitParameter("dbUserName"));
dbBean.setDbPassword(config.getInitParameter("dbPassword"));

// put the bean in the servlet context
// the bean will be accessed from JSP pages
context.setAttribute("dbBean", dbBean);

try {
// loading the database JDBC driver
Class.forName(config.getInitParameter("jdbcDriver"));
}
catch (ClassNotFoundException e) {
System.out.println(e.toString());
}
super.init(config);
}


/**Process the HTTP Get request*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}

/**Process the HTTP Post request*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

String base = "/jsp/";
String url = base + "Default.jsp";
String action = request.getParameter("action");

if (action!=null) {
if (action.equals("search"))
url = base + "SearchResults.jsp";
else if (action.equals("browseCatalog"))
url = base + "BrowseCatalog.jsp";
else if (action.equals("productDetails"))
url = base + "ProductDetails.jsp";
else if (action.equals("productDetails"))
url = base + "ProductDetails.jsp";
else if (action.equals("addShoppingItem") ||
action.equals("updateShoppingItem") ||
action.equals("deleteShoppingItem") ||
action.equals("displayShoppingCart"))
url = base + "ShoppingCart.jsp";
else if (action.equals("checkOut"))
url = base + "CheckOut.jsp";
else if (action.equals("order"))
url = base + "Order.jsp";
}
RequestDispatcher requestDispatcher =
getServletContext().getRequestDispatcher(url);
requestDispatcher.forward(request, response);

}
}
 
J

John C. Bollinger

dinesh said:
I'm trying to invoke a servlet. I get the following error:
javax.servlet.ServletException:
[HTTP:101250][ServletContext(id=371807,name=BibleApp,context-path=/BibleApp)
]: Servlet class /com/brainysoftware/burnaby/ControllerServlet for servlet
ControllerServlet could not be loaded because a class on which it depends
was not found in the classpath
C:\bea\user_projects\infologic1\applications\BibleApp;C:\bea\user_projects\i
nfologic1\applications\BibleApp\WEB-INF\classes.
java.lang.NoClassDefFoundError:
/com/brainysoftware/burnaby/ControllerServlet (wrong name:
ControllerServlet).
at weblogic.servlet.internal.ServletStubImpl.prepareServlet
----------
web.xml
<!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>simple</servlet-name>
<jsp-file>simplePage.jsp</jsp-file>

</servlet>

<servlet>
<servlet-name>ControllerServlet</servlet-name>
<servlet-class>com.brainysoftware.burnaby.ControllerServlet</servlet-class>
[...]

--------------
ControllerServlet.class

import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import com.brainysoftware.burnaby.DbBean;

public class ControllerServlet extends HttpServlet {

[...]

The source for the ControllerServlet class needs an appropriate package
statement.


John Bollinger
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top