• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe my useful batch file compile.bat might point you in the right direction.

Steven

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this: (file separator is "\" instead of "/")
D:\MyProjects\beerV1>javac -d classes src\com\example\web\BeerSelect.java

Regards
 
Vengan Krish
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess some mistach with your directory structure. if you haven't figured it yet, paste your development directory structure here.

regards
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
I will open the floodgates of his own worst nightmare! All in a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic