Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Problem invoking servlet

Reply
Thread Tools

Problem invoking servlet

 
 
dinesh
Guest
Posts: n/a
 
      08-03-2003
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\Bible App;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.prepareS ervlet
----------
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@COMPAQSERVE R</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("dbUs erName"));
dbBean.setDbPassword(config.getInitParameter("dbPa ssword"));

// 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);

}
}


 
Reply With Quote
 
 
 
 
John C. Bollinger
Guest
Posts: n/a
 
      08-04-2003
dinesh wrote:
> 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\Bible App;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.prepareS ervlet
> ----------
> 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
http://www.velocityreviews.com/forums/(E-Mail Removed)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Advice for invoking external binary from a servlet Kira Yamato Java 1 07-27-2007 10:54 AM
Offending class: javax/servlet/Servlet.class chamikara Java 1 06-19-2004 05:42 AM
Servlet question(Tomcat, web.xml, servlet-class, servlet-name) circuit_breaker Java 2 04-04-2004 03:26 AM
Tomcat: POST from one servlet or internal class to another servlet Sean Clarke Java 1 01-07-2004 02:22 PM
how to get my servlet configuration before the servlet is initialised Andy Fish Java 4 12-17-2003 09:47 PM



Advertisments