• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

chapter 3:package com.example.model does exist

 
srinivas.rao marasu
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you import BeerExpert?
 
srinivas.rao marasu
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
 
sumedha rao
Ranch Hand
Posts: 115
Firefox Browser Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2420
95
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic