JSB Beans and Tomcat problem
I'm trying to use a Bean in my JSP page(running on tomcat), but everytime I try to run it says the package doesn't exist, I've placed my package in web-inf/classes/packageName and my class inside of that... The error I get is:
C:\Programmer\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\index_jsp.java:47: package m does not exist
m.Person person = null;
^
Does anyone have any idea what might be wrong? I've been googling for 30 minutes now without luck - and I've tried reinstalling tomcat... my JSP code for calling the bean is:
<jsp:useBean id="person" class="m.Person" scope="session" />
<jsp:setProperty name="person" property="*" />
<Moderator added green checkmark in the first thread>
Re: JSB Beans and Tomcat problem
Looks like you have the beans path for the class attribute wrong in your useBean tag.
Re: JSB Beans and Tomcat problem
Nope it looks like you have it right. I was thrown off by web-inf/classes/packageName
Re: JSB Beans and Tomcat problem
tomcat keeps telling me "The value for the useBean class attribute is invalid."
No matter if the bean is stored in directly within the classes directory itself C:\Jakarta\jakarta-tomcat-5.0.28\webapps\ora\WEB-INF\classes and i use
<jsp:useBean id = "Test" class = "TestBean"/>
or another directory off of the classes dir.
C:\Jakarta\jakarta-tomcat-5.0.28\webapps\ora\WEB-INF\classes\com\MyCompany\Beans
<jsp:useBean id = "Test" class = "com.MyCompany.Beans.TestBean"/>
But what i noticed was that the web container was not compiling my .java file because there was no .class file being generated. It was only when i took the bean out of it's directory and put it into the C:\ dir and compiled it using javac and saw i didnt add in (import java.io*;) and some other stuff then moved it back into the C:\Jakarta\jakarta-tomcat-5.0.28\webapps\ora\WEB-INF\classes\com\MyCompany\Beans
that everything worked fine. :confused:
Re: JSB Beans and Tomcat problem
Didn't we have an extremely similar problem in the past?
Re: JSB Beans and Tomcat problem
Quote:
Originally Posted by CornedBee
Didn't we have an extremely similar problem in the past?
I wouldn't know :).
So, you're saying I should try compiling my classes with javac before moving them to the class directory?
Re: JSB Beans and Tomcat problem
In fact, I would move only the .class files to the classes directory.
My current setup is like this:
Code:
<appdir>
-> WEB-INF
-> src
-> backend -> at/getdesigned/sciencemapper/*.java
-> webservice -> at/getdesigned/sciencemapper/ws/*.java
-> tests ...
-> classes -> at/getdesigned/.../*.class
-> build.xml
And I simply type
ant
in the WEB-INF directory. The build.xml is written so that it correctly locates and compiles all files to the classes directory.
Re: JSB Beans and Tomcat problem
Ant? I'm not using ant... I mean... I don't even know what ant is, besides the insect... What does it do? And do I have to run it before tomcat's capable of finding my beans ?
Re: JSB Beans and Tomcat problem
http://ant.apache.org/
It's the build tool for all things Java.
In other words, it's a far more comfortable way of compiling everything than calling javac manually.
Re: JSB Beans and Tomcat problem
Quote:
Originally Posted by CornedBee
http://ant.apache.org/
It's
the build tool for all things Java.
In other words, it's a far more comfortable way of compiling everything than calling javac manually.
Okay then :) Thanks!
Re: JSB Beans and Tomcat problem
CornedBee the .xml that you showed where would i find it at? Im looking at a build.xml file generated by NetBeans and it's structure isn't the same.
Re: JSB Beans and Tomcat problem
I wrote it myself.
Here's mine:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<project name="ScienceMapper" default="all">
<description>
ScienceMapper is a literature organizing system.
</description>
<property name="path.rootsrc" location="src"/>
<property name="path.dest" location="classes"/>
<property name="build.version" value="1.4"/>
<property name="build.debug" value="true"/>
<property name="project.version" value="0.0"/>
<!-- Apparently 1.5.x doesn't support condition. -->
<!--
<condition property="build.optimize">
<isfalse value="${build.debug}"/>
</condition>
-->
<property name="build.debug" value="true"/>
<target name="all" depends="webservice,backend,tests">
</target>
<target name="backend" depends="utils">
<javac srcdir="${path.rootsrc}/backend" destdir="${path.dest}"
encoding="UTF-8" debug="${build.debug}" deprecation="on"
optimize="${build.optimize}" target="${build.version}"
source="${build.version}">
</javac>
</target>
<target name="webservice" depends="backend">
<javac srcdir="${path.rootsrc}/webservice" destdir="${path.dest}"
encoding="UTF-8" debug="${build.debug}" deprecation="on"
optimize="${build.optimize}" target="${build.version}"
source="${build.version}">
</javac>
</target>
<target name="tests" depends="backend,webservice,utils">
<javac srcdir="${path.rootsrc}/tests" destdir="${path.dest}"
encoding="UTF-8" debug="${build.debug}" deprecation="on"
optimize="${build.optimize}" target="${build.version}"
source="${build.version}">
</javac>
</target>
<target name="utils">
<javac srcdir="${path.rootsrc}/utils" destdir="${path.dest}"
encoding="UTF-8" debug="${build.debug}" deprecation="on"
optimize="${build.optimize}" target="${build.version}"
source="${build.version}">
</javac>
</target>
</project>
Re: JSB Beans and Tomcat problem
Id have to a read an xml book because i don't understand a word of it. :lol:
Re: JSB Beans and Tomcat problem
You'd mainly have to read the Ant documentation.
Re: JSB Beans and Tomcat problem
With JSP, JSF, SQL, then all of the other crap i have to take at uni i think ill just wait. :lol: