aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Getting package and class exceptions with the BeerAcvice web app!!! Pls Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Getting package and class exceptions with the BeerAcvice web app!!! Pls Help" Watch "Getting package and class exceptions with the BeerAcvice web app!!! Pls Help" New topic
Author

Getting package and class exceptions with the BeerAcvice web app!!! Pls Help

vishwak rajgopalan
Greenhorn

Joined: Nov 19, 2003
Posts: 8
Hello,
I am not sure whether this is the appropriate forum to post this. Please excuse me if I have made an error. I have been using HeadFirst Servlets and JSP and I compiled the BeerSelect.java code (the second version of the controller servlet).
I get the following error message saying that the package com.example.model does not exist. Please help me as I am unsure how to proceed with debugging this issue. I have pasted the error message below


D:\MyProjects\beerV1>javac -d classes src/com/example/web/BeerSelect.java
src/com/example/web/BeerSelect.java:20: cannot access src.com.example.model.BeerExpert
bad class file: .\src\com\example\model\BeerExpert.java
file does not contain class src.com.example.model.BeerExpert
Please remove or make sure it appears in the correct subdirectory of the classpath.
BeerExpert be = new BeerExpert();

Thanks,
Vishwak
Steven Hoodless
Ranch Hand

Joined: Mar 23, 2004
Posts: 64
Maybe my useful batch file compile.bat might point you in the right direction.

Steven



SCJP, SCJD, SCWCD.
Vengan Krish
Ranch Hand

Joined: Mar 05, 2005
Posts: 32
Try this: (file separator is "\" instead of "/")
D:\MyProjects\beerV1>javac -d classes src\com\example\web\BeerSelect.java

Regards


SCJP 1.4<br />SCJD 1.4<br />SCWCD 1.4<br />SWBCD (Preparing)
Vengan Krish
Ranch Hand

Joined: Mar 05, 2005
Posts: 32
I guess some mistach with your directory structure. if you haven't figured it yet, paste your development directory structure here.

regards
Mo Dulloo
Greenhorn

Joined: May 13, 2005
Posts: 3
Had the same problem and Steven's bat file does hold a hint to the problem.
I had coded it char for char out of the book on a windows system and the main problem I had was the underlined bit below:

javac -classpath .... servlet-api.jar:classes:. -d classes ...
----------

It's the colons either side - I initially resorted to ermoving the section from the compile instruction but ran into trouble when trying to compile the second servlet.
From Steven's bat file - I tried semi-colons and with a little reading up that was the trick!

Maybe one for the errata - anyone else had this issue?

I hope this solves it for you.

Mo

SCJP 1.4
Mo Dulloo
Greenhorn

Joined: May 13, 2005
Posts: 3
Hmmm, underlined bit does not come out too well above, it's the:

:classes:.

bit that was supposed to be underlined.

Cheers

Mo

SCJP 1.4
sergio mendez-rueda
Ranch Hand

Joined: May 12, 2005
Posts: 37
hi,
this is my AntFile for the beer app.(Tomcat and Resin app-Servers)
<?xml version="1.0"?>
<!-- Author S mendez-rueda -->
<project name="beerApp development" default="compileSrc" basedir=".">

<!-- the name of the wep application -->
<property name="app.name" value="beerApp"/>
<!-- =================================================================== -->
<!-- properties reflecting the directory structur of the web application-->
<!-- development -->
<!-- =================================================================== -->

<property file="${basedir}/build.properties"/>
<property name="src" location="${basedir}/src"/>
<property name="src.web" location="${src}/com/example/web"/>
<property name="src.model" location="${src}/com/example/model"/>
<property name="etc" location="${basedir}/etc"/>
<property name="lib" location="${basedir}/lib"/>
<property name="web" location="${basedir}/web"/>
<property name="classes" location="${basedir}/classes"/>

<!-- =================================================================== -->
<!-- properties reflecting the directory structur of the web application-->
<!-- tomcat deployement -->
<!-- =================================================================== -->

<property name="tomDeployDir" location="${tomcat.server}/${app.name}"/>
<property name="tomLibDir" location="${tomcat.server}/${app.name}/lib"/>
<property name="tomClassDir" location="${tomcat.server}/${app.name}/WEB-INF/classes"/>

<!-- =================================================================== -->
<!-- properties reflecting the directory structur of the web application-->
<!-- Resin deployement -->
<!-- =================================================================== -->

<property name="resinDeployDir" location="${resin.server}/${app.name}"/>
<property name="resinLibDir" location="${resin.server}/${app.name}/lib"/>
<property name="resinClassDir" location="${resin.server}/${app.name}/WEB-INF/classes"/>

<!-- =================================================================== -->
<!-- Set class path for the build -->
<!-- =================================================================== -->

<path id="build.classpath">
<!-- <path refid="client.classpath"/> -->

<fileset dir="${tomcat.home}/common/lib/">
<include name="servlet-api.jar"/>
<include name="jsp-api.jar"/>
</fileset>
<fileset dir="${tomcat.home}/webapps/coreServlets/WEB-INF/lib/">
<include name="commons-beanutils-bean-collections.jar"/>
<include name="commons-beanutils-core.jar"/>
<include name="commons-beanutils.jar"/>
</fileset>
</path>

<!-- =================================================================== -->
<!-- Create the file and directory structure of the web app -->
<!-- =================================================================== -->

<target name="init">
<mkdir dir="${src}"/>
<mkdir dir="${src.web}"/>
<mkdir dir="${src.model}"/>
<mkdir dir="${etc}"/>
<mkdir dir="${lib}"/>
<mkdir dir="${web}"/>
<mkdir dir="${classes}"/>
<mkdir dir="${tomDeployDir}"/>
<mkdir dir="${tomLibDir}"/>
<mkdir dir="${tomClassDir}"/>
<mkdir dir="${resinDeployDir}"/>
<mkdir dir="${resinLibDir}"/>
<mkdir dir="${resinClassDir}"/>
</target>
<!-- =================================================================== -->
<!-- OInformation about the file and directory structure of the web app -->
<!-- =================================================================== -->

<target name="about">
<echo> src: ${src} </echo>
<echo> srcWeb: ${src.web} </echo>
<echo> srcModel: ${src.model} </echo>
<echo> etc: ${etc} </echo>
<echo> lib: ${lib} </echo>
<echo> web: ${web} </echo>
<echo> classes: ${classes} </echo>
<echo> tomcatDeployDir: ${tomDeployDir} </echo>
<echo> tomcatLibDir: ${tomLibDir} </echo>
<echo> tomcatLibDir: ${tomClassDir} </echo>
<echo> resinDeployDir: ${resinDeployDir} </echo>
<echo> resinLibDir: ${resinLibDir} </echo>
<echo> resinClassDir: ${resinClassDir} </echo>
</target>

<!-- ================================================================ -->
<!-- Compiles the source code -->
<!-- ================================================================ -->
<target name="compileSrc" depends="init">
<javac srcdir="${src}" destdir="${classes}"
classpathref="build.classpath" debug="off">
</javac>
</target>

<!-- ================================================================ -->
<!-- Deploys the application by copying the class files to the -->
<!-- Tomcat servlet and JPD deploy directory. -->
<!-- ================================================================ -->

<target name="tomcat" description="deployement to tomcat" depends="compileSrc">
<copy todir="${tomDeployDir}">
<fileset dir="${web}">
<include name="**/*.html"/>
<include name="**/*.jsp"/>
</fileset>
</copy>
<copy todir="${tomDeployDir}/WEB-INF">
<fileset dir="${etc}">
<include name="web.xml"/>
</fileset>
</copy>
<copy todir="${tomClassDir}">
<fileset dir="${classes}">
<include name="**/*"/>
</fileset>
</copy>
<copy todir="${tomLibDir}">
<fileset dir="${lib}">
<include name="*.jar"/>
</fileset>
</copy>
</target>

<!-- ================================================================ -->
<!-- Deploys the application by copying the class files to the -->
<!-- Resin servlet and JPD deploy directory. -->
<!-- ================================================================ -->

<target name="resin" description="deployement to resin" depends="compileSrc">
<copy todir="${resinDeployDir}">
<fileset dir="${web}">
<include name="**/*.html"/>
<include name="**/*.jsp"/>
</fileset>
</copy>
<copy todir="${resinDeployDir}/WEB-INF">
<fileset dir="${etc}">
<include name="web.xml"/>
</fileset>
</copy>
<copy todir="${resinClassDir}">
<fileset dir="${classes}">
<include name="**/*"/>
</fileset>
</copy>
<copy todir="${resinLibDir}">
<fileset dir="${lib}">
<include name="*.jar"/>
</fileset>
</copy>
</target>
</project>
the structure of the application is in the file.
if you want, i can you email all the app-source.
cheers,
sergio
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Getting package and class exceptions with the BeerAcvice web app!!! Pls Help