Go Back   SitePoint Forums > Forum Index > Program Your Site > Java and JSP
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Nov 5, 2009, 16:54   #1
Nick
masquerading
 
Nick's Avatar
 
Join Date: Jun 2003
Location: East Coast
Posts: 2,401
Trying to import a custom class

I've been searching through Google but can't seem to come across a solution to how to import a custom class in Java. I'm creating an application following the MVC pattern, having my servlets be the controllers, and beans be the models. I'm using Tomcat JDBC, and my directory looks like this:

Code:
src/
   bean/
      Listing.java
   servlet/
      Tester.java
web/
etc
My model, Listing.java, is inside bean/, and declared as "package bean". Now, in my servlet Tester.java, "package servlet", I am trying to create a new instance of a Listing, but I keep getting a "wrapper cannot find servlet class" exception. I've tried writing "import bean.Listing", "import src.bean.Listing", but don't know what else to do...
Nick is offline   Reply With Quote
Old Nov 6, 2009, 02:23   #2
rozner
SitePoint Wizard
 
rozner's Avatar
 
Join Date: Oct 2002
Location: Paris
Posts: 1,005
Are you getting this when when compiling or running the application?

How do you have your project set up? Is it a war?

Also can you post the full error message + stack trace.
rozner is online now   Reply With Quote
Old Nov 6, 2009, 09:37   #3
Nick
masquerading
 
Nick's Avatar
 
Join Date: Jun 2003
Location: East Coast
Posts: 2,401
Quote:
Originally Posted by rozner View Post
Are you getting this when when compiling or running the application?

How do you have your project set up? Is it a war?

Also can you post the full error message + stack trace.
While running it. Compiling works fine.

I'm not sure what a "war" is? It's set up through Tomcat/JDBC.

Code:
type Exception report
message 
description The server encountered an internal error () that prevented it from fulfilling this request.
exception 
javax.servlet.ServletException: Wrapper cannot find servlet class servlet.Listing or a class it depends on
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
    java.lang.Thread.run(Thread.java:619)
root cause 
java.lang.ClassNotFoundException: servlet.Listing
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
    java.lang.Thread.run(Thread.java:619)
Nick is offline   Reply With Quote
Old Nov 7, 2009, 06:51   #4
rozner
SitePoint Wizard
 
rozner's Avatar
 
Join Date: Oct 2002
Location: Paris
Posts: 1,005
I'm unfamiliar with "Tomcat JDBC". I'm very familiar with Tomcat and JDBC as separate entities however. JDBC is for database connectivity.

Anyway, maybe I should rephrase my question, how is the servlet running on Tomcat. Also are you running Tomcat yourself or is this some shared hosting? Somewhere you must have a directory structure that looks like this:

Code:
WEB-INF/
   classes/
      bean/
         Listing.class
      servlet/
         Tester.class
    web.xml
web/
etc
The error you're seeing suggests that Listener.class is not available at runtime, or can't be found. If you give me some more details of how you've set up the server I can probably tell you what's wrong.
rozner is online now   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
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
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 05:24.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved