aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes chapter 3:package com.example.model does exist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "chapter 3:package com.example.model does exist" Watch "chapter 3:package com.example.model does exist" New topic
Author

chapter 3:package com.example.model does exist

srinivas.rao marasu
Greenhorn

Joined: Apr 04, 2006
Posts: 23
Hai,
In chapter3,HeadFirstServlets&jsp,i was trying to diploy the modified version of servlet2 code,while i was deploying i got this error can any body
help me out?

E:\HeadFirstEx\beerV1>javac -classpath \tomcat\common\lib\servlet-api.jar -d cla
sses src\com\example\web\BeerSelect.java
src\com\example\web\BeerSelect.java:3: package com.example.model does not exist
import com.example.model.*;
^
src\com\example\web\BeerSelect.java:19: cannot resolve symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
src\com\example\web\BeerSelect.java:19: cannot resolve symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
3 errors

E:\HeadFirstEx\beerV1>
Sital Kotamraju
Greenhorn

Joined: Mar 21, 2006
Posts: 13
Did you import BeerExpert?
srinivas.rao marasu
Greenhorn

Joined: Apr 04, 2006
Posts: 23
yes,in servlet code i added same as in text book chapter3 HeadFirst, import com.example.model.*; but still it is giving package com.example.model does not exist?any suggestion?By the way i am working on ms-windowsXp?

i have tried everything same as in text book,including compiling with javac -classpath command,when i issued the following javac -classpath command even it is not able to find servlet-api.jar?

E:\HeadFirstEx\beerV1>javac -classpath\tomcat\common\lib\servlet-api.jar:classes:. -d classes src\com\example\web\BeerSelect.java

But some how when i issue following javac -classpath command atleast it is taking servlet-api.jar file,but it is saying package com.example.model does not exist,infact it is existing in the same directory under classes?

E:\HeadFirstEx\beerV1>javac -classpath \tomcat\common\lib\servlet-api.jar -d cla
sses src\com\example\web\BeerSelect.java
src\com\example\web\BeerSelect.java:3: package com.example.model does not exist
import com.example.model.*;
^


Thanks in advance.
Abhinav Gogna
Greenhorn

Joined: Oct 23, 2005
Posts: 20
Srinivas,

This is typical classpath problem. I ran into the same problem while doing the struts version of this app.

The solution is while compiling include the folder in your classpath where the BeerExpert class is saved.

Try using this command
javac -cp /tomcat/apache-tomcat-5.5.12/common/lib/servlet-api.jar;classes src/com/example/web/BeerSelect.java

The difference between this is and the one in the book is ";" instead of ":".

":" is used for unix. Authors use the most advanced os called Mac OS X (UNIX underneath) but for windows you would have to use ";" for classpath.

Hope it helps.

Abhi
srinivas.rao marasu
Greenhorn

Joined: Apr 04, 2006
Posts: 23
Thank you abhinav,

Finally,it worked as you mentioned about the classPath Problem. Going forward i even compiled servlet3 modifide version and jsp in chapter HeadFirst Servlets and jsp,while deploying it on the tomcat i got the follwing exception regarding jsp.Being still in chapter3 i am not able to figure out what this exception is about?why it occured?Any suggestion?

Exception:
----------

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.example.web.BeerSelect.doPost(BeerSelect.java:24)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

java.lang.NullPointerException
org.apache.jsp.result_jsp._jspService(result_jsp.java:52)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.example.web.BeerSelect.doPost(BeerSelect.java:24)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
Apache Tomcat/5.0.28
srinivas.rao marasu
Greenhorn

Joined: Apr 04, 2006
Posts: 23
um..After a great frustation and moving one chapter 2chapters further and rechecking the code again and again finally i found the mistake myself,it's a just typing mistake about Style attribute.
muktesh tripathi
Ranch Hand

Joined: Nov 20, 2007
Posts: 30
thanks
sumedha rao
Ranch Hand

Joined: Nov 26, 2010
Posts: 115

muktesh tripathi wrote:thanks

Hi,will the classpath given on page 85 work if the deployment and the developement directory structures are in different drives??i am getting the same error as yours!


scjp1.6,scwcd1.5!!!
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1715
    
  25

Hi
Hi,will the classpath given on page 85 work

Could you please add your project setup and your code as not everybody has that book (near).

If you have a stacktrace with a line number like:
java.lang.NullPointerException
org.apache.jsp.result_jsp._jspService(result_jsp.java:52)


You can always check the generated code (result.jsp ->result_jsp.java) in the tomcat dir to see what statement caused the NullPointerException

Regards,
Frits
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: chapter 3:package com.example.model does exist