You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by jonathan porterfield <a0...@hotmail.com> on 2001/09/11 23:21:07 UTC
persistent errer:java.lang.NoClassDefFoundError
I made a posting a couple weeks ago asking for help since I couldn't get
even the HelloWorld.class to function in Velocity. It's sad but true that I
still can't get it to work.
I know that I must be missing something serious here, but have obviously not
been able to pin it down.
??????????
Do I need to re-run "ant init" after adding a class to the screens
directory?
??????????
What am I missing?
??????????
Some background:
1)Compiled class and deposited it at:
C:\web\tdk\webapps\[myApp]\WEB-INF\src\java\com\[myCompany]\[myApp]\modules\screens\HelloWorld.class
------------------------------------
HelloWorld.java
I compiled it with option -verbose and saw no errors or warnings.
I snipped it directly from VelocitySite-Howto
------------------------------------
------------------------------------
// Velocity Stuff
import org.apache.velocity.context.Context;
// Turbine Stuff
import org.apache.turbine.util.RunData;
import org.apache.turbine.modules.screens.VelocityScreen;
public class HelloWorld extends VelocityScreen
{
public void doBuildTemplate( RunData data, Context context )
throws Exception
{
// the context object has already been setup for you!
context.put ("hello", "this is a test...");
}
}
------------------------------------
2) Added to classpath:
C:\web\tdk\webapps\[myApp]\WEB-INF\src\java\com\[myCo]\[myApp]\modules\screens\HelloWorld.class
------------------------------------
3) I also tried to add the following class to the
TurbineResources.properties file as:
module.packages=com.[myCo].[myApp].modules,org.apache.turbine.flux.modules,HelloWorld.class
------------------------------------
Which throws the following error in the turbine.log
------------------------------------
[Wed Sep 05 22:21:52 PDT 2001] -- ERROR -- Cannot find tool class
HelloWorld.class, please check the name of the class.
-Of course I did also check the name of the class. In fact I copied the path
from the windows explorer location bar, and made sure that the
------------------------------------
------------------------------------
HelloWorld.vm
Snipped directly from VelocitySite-Howto
------------------------------------
<p>
<font color="red">
$hello of the emergency broadcast station.
</font>
</p>
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
Re: persistent errer:java.lang.NoClassDefFoundError
Posted by "Jeffrey B. Woodward" <Je...@Dartmouth.EDU>.
Wow...it sounds like you are making things far harder than they really are.
I didn't bother to follow closely to *ALL* of the changes that you made, but
out of the box, things work something like this:
1) I assume that you ran "ant init" and followed all of the installation
directions, and got that working. Generally speaking, you won't need to run
"ant init" again.
2) Take a close look at the options in
webapps/[app-name]/WEB-INF/conf/TurbineResources.properties. It is hard to
understand what everything in there is right out of the gates, but 50% of
general questions can be answered by understanding TR props (the other 50%
can be answered in the API documentation, and of course, the source code
answers 100% of all questions :-). In your particular instance, you are
interested namely in the following line in TR props "module.packages=" which
in the default installation of 2.1 is something like
"module.packages=org.mycompany.newapp.modules,org.apache.turbine.flux.module
s". Keeping that default setting, your source code *MUST* be in the base
directory:
"webapps/[app-name]/WEB-INF/src/java/org/mycompany/newapp/modules/" In the
modules directory, you will want two "standard" directories: "screens" and
"actions".
3) Given the above, create your HelloWorld.java in the screens subdirectory:
"webapps/[app-name]/WEB-INF/src/java/org/mycompany/newapp/modules/screens/He
lloWorld.java". NOW HERE IS ANOTHER GOTCHA: your source code *MUST* contain
the appropriate "package" directive which in this case is "package
org.mycompany.newapp.modules.screens;". Thus your resulting HelloWorld.java
program is:
package org.mycompany.newapp.modules.screens;
// Velocity Stuff
import org.apache.velocity.context.Context;
// Turbine Stuff
import org.apache.turbine.util.RunData;
import org.apache.turbine.modules.screens.VelocityScreen;
import org.apache.turbine.services.resources.TurbineResources;
public class HelloWorld extends VelocityScreen
{
public void doBuildTemplate( RunData data, Context context )
throws Exception
{
context.put ("hello", "this is a test...");
}
}
4) Now with that out of the way, it is time to build your "project". If you
have followed the above directions, you should be able to go to your
"webapps/[app-name]/WEB-INF/build/" directory, and issue the "ant" command
(no arguments!). With any luck, ant will build your sources and deposit the
class files in the appropriate directory in
"webapps/[app-name]/WEB-INF/classes/org/mycompany/newapp/modules/screens/".
5) Next, depending on your servlet container and how it is configured, you
will need to restart your servlet container (i.e. catalina/tomcat).
6) You should now have a working HelloWorld demo.
Note: There is no need to mess around with your CLASSPATH. If you find
yourself doing that, you are probably doing something very wrong!
Good luck and don't give up,
-Jeff Woodward
Project Manager - Systems and Systems Integration
The fMRI Data Center
Dartmouth College
6162 Moore Hall
Jeffrey.B.Woodward@Dartmouth.EDU
----- Original Message -----
From: "jonathan porterfield" <a0...@hotmail.com>
To: <tu...@jakarta.apache.org>
Sent: Tuesday, September 11, 2001 5:21 PM
Subject: persistent errer:java.lang.NoClassDefFoundError
> I made a posting a couple weeks ago asking for help since I couldn't get
> even the HelloWorld.class to function in Velocity. It's sad but true that
I
> still can't get it to work.
> I know that I must be missing something serious here, but have obviously
not
> been able to pin it down.
>
> ??????????
> Do I need to re-run "ant init" after adding a class to the screens
> directory?
>
> ??????????
> What am I missing?
> ??????????
>
> Some background:
> 1)Compiled class and deposited it at:
>
C:\web\tdk\webapps\[myApp]\WEB-INF\src\java\com\[myCompany]\[myApp]\modules\
screens\HelloWorld.class
> ------------------------------------
> HelloWorld.java
> I compiled it with option -verbose and saw no errors or warnings.
> I snipped it directly from VelocitySite-Howto
> ------------------------------------
> ------------------------------------
> // Velocity Stuff
> import org.apache.velocity.context.Context;
>
> // Turbine Stuff
> import org.apache.turbine.util.RunData;
> import org.apache.turbine.modules.screens.VelocityScreen;
>
> public class HelloWorld extends VelocityScreen
> {
> public void doBuildTemplate( RunData data, Context context )
> throws Exception
> {
> // the context object has already been setup for you!
> context.put ("hello", "this is a test...");
> }
> }
>
> ------------------------------------
> 2) Added to classpath:
>
C:\web\tdk\webapps\[myApp]\WEB-INF\src\java\com\[myCo]\[myApp]\modules\scree
ns\HelloWorld.class
>
> ------------------------------------
> 3) I also tried to add the following class to the
> TurbineResources.properties file as:
>
module.packages=com.[myCo].[myApp].modules,org.apache.turbine.flux.modules,H
elloWorld.class
> ------------------------------------
> Which throws the following error in the turbine.log
> ------------------------------------
> [Wed Sep 05 22:21:52 PDT 2001] -- ERROR -- Cannot find tool class
> HelloWorld.class, please check the name of the class.
>
> -Of course I did also check the name of the class. In fact I copied the
path
> from the windows explorer location bar, and made sure that the
> ------------------------------------
> ------------------------------------
> HelloWorld.vm
> Snipped directly from VelocitySite-Howto
> ------------------------------------
> <p>
> <font color="red">
> $hello of the emergency broadcast station.
> </font>
> </p>
>
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
Re: persistent errer:java.lang.NoClassDefFoundError
Posted by J Kary <jk...@yahoo.com>.
Jonathan,
Try putting the class file in WEB-INF/classes directory.
Take Care.
Jason Kary
--- jonathan porterfield <a0...@hotmail.com> wrote:
> I made a posting a couple weeks ago asking for help since I couldn't
> get
> even the HelloWorld.class to function in Velocity. It's sad but true
> that I
> still can't get it to work.
> I know that I must be missing something serious here, but have
> obviously not
> been able to pin it down.
>
> ??????????
> Do I need to re-run "ant init" after adding a class to the screens
> directory?
>
> ??????????
> What am I missing?
> ??????????
>
> Some background:
> 1)Compiled class and deposited it at:
>
C:\web\tdk\webapps\[myApp]\WEB-INF\src\java\com\[myCompany]\[myApp]\modules\screens\HelloWorld.class
> ------------------------------------
> HelloWorld.java
> I compiled it with option -verbose and saw no errors or warnings.
> I snipped it directly from VelocitySite-Howto
> ------------------------------------
> ------------------------------------
> // Velocity Stuff
> import org.apache.velocity.context.Context;
>
> // Turbine Stuff
> import org.apache.turbine.util.RunData;
> import org.apache.turbine.modules.screens.VelocityScreen;
>
> public class HelloWorld extends VelocityScreen
> {
> public void doBuildTemplate( RunData data, Context context )
> throws Exception
> {
> // the context object has already been setup for you!
> context.put ("hello", "this is a test...");
> }
> }
>
> ------------------------------------
> 2) Added to classpath:
>
C:\web\tdk\webapps\[myApp]\WEB-INF\src\java\com\[myCo]\[myApp]\modules\screens\HelloWorld.class
>
> ------------------------------------
> 3) I also tried to add the following class to the
> TurbineResources.properties file as:
>
module.packages=com.[myCo].[myApp].modules,org.apache.turbine.flux.modules,HelloWorld.class
> ------------------------------------
> Which throws the following error in the turbine.log
> ------------------------------------
> [Wed Sep 05 22:21:52 PDT 2001] -- ERROR -- Cannot find tool class
> HelloWorld.class, please check the name of the class.
>
> -Of course I did also check the name of the class. In fact I copied
> the path
> from the windows explorer location bar, and made sure that the
> ------------------------------------
> ------------------------------------
> HelloWorld.vm
> Snipped directly from VelocitySite-Howto
> ------------------------------------
> <p>
> <font color="red">
> $hello of the emergency broadcast station.
> </font>
> </p>
>
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at
> http://explorer.msn.com/intl.asp
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org