Hello, I have been using JavaRanch's tutorial regarding the Struts Framework for educational purposes... When I try to compile LoginAction.java (LoginBean & LoginForm have already been successfully compiled as interpreted byte code.) The error message reads: -------------------------------------------------- LoginAction.java:14: cannot resolve symbol symbol : class LoginBean location: class test.struts.LoginAction LoginBean lb = new LoginBean(); ^ LoginAction.java:14: cannont resolve symbol symbol : class LoginBean location: class test.struts.LoginAction LoginBean lb = new LoginBean(); ^ 2 errors -------------------------------------------------- If anyone has a clue to why this isn't working, I would be very grateful. I am using the tutorial listed at: http://www.javaranch.com/newsletter/Mar2002/newslettermar2002.jsp#struts Thank you for your time. -Unnsse
Hi, Unnsse. I encountered the same problem as you did. I first compiled LoginBean.java, no problem. I then tried to compile LoginAction.java and I got the same error messages as you did. Consequently, I did in another way: I put LoginBean.java, LoginAction.java, LoginForm.java in the same directory c:\example. At the command line prompt c:\example>javac *.java I was able to get all three files compiled. I then moved compiled class files to the c:\tomcat installation directory\webapps\struts\WEB-INF\classes\test\struts directory. Thomas, I do not know if I did it right. Do you think what I did leads to the HTTP Status 500 problem (posted as another thread in this Forum) when I ran the Login example?
Thomas Paul
mister krabs
Ranch Hand
Joined: May 05, 2000
Posts: 13974
posted
0
All three classes are in the same package: test.struts. This means that in order to compile them, they must all be in a directory structure of WEB-INF/classes/test/struts. The classpath must be configured in such a way that it points to the classes directory for compiling. If you are using an IDE like NetBeans then this isn't an issue. If you are doing this from the command line then you have to set the classpath by hand. To execute, the class files for all three must be in that directory. Make sure that the package statement is correct for all three. Check your Tomcat logs if you get an odd error.
Thomas Paul
mister krabs
Ranch Hand
Joined: May 05, 2000
Posts: 13974
posted
0
Maybe as an enhancement I should supply an ANT file to do the compile.
JiaPei Jen
Ranch Hand
Joined: Nov 19, 2000
Posts: 1309
posted
0
I followed Thomas' suggestion. LoginBean.java, LoginAction.java, and LoginForm.java are in the same package test.struts. I was able to compile each of the java file one by one. No error message any more.
Unnsse Khan
Ranch Hand
Joined: Nov 12, 2001
Posts: 511
posted
0
Here's what I did: I have all 3 source files in: c:\jakarta-tomcat-4.0.3\webapps\struts\web-inf\classes\test\struts\ At the command line, this is what I did: c:\jakarta-tomcat-4.0.3\webapps\struts\web-inf\classes\test\struts\ javac -classpath c:\jakarta-tomcat-4.0.3\webapps\struts\web-inf\classes\test\struts\;c:\jakarta-tomcat-4.0.3\common\lib\servlet.jar LoginBean.java Every thing went correctly and LoginBean.class was created... I did the same for LoginForm.java and it worked... However, with LoginAction.java, it still has the same 2 errors... Any suggestions and I will be very grateful... Sincerely yours, Unnsse
Thomas Paul
mister krabs
Ranch Hand
Joined: May 05, 2000
Posts: 13974
posted
0
The classpath has to point to the classes directory. Since test.struts is the package it is automatically appended to the directory in the classpath so leave that off of the classpath entry.
JiaPei Jen
Ranch Hand
Joined: Nov 19, 2000
Posts: 1309
posted
0
Hi, Unnsse:
Please try this:
Hi, Thomas, am I right? [ February 23, 2003: Message edited by: JiaPei Jen ]
C:\ApacheGroup\Tomcat\webapps\struts\WEB-INF\classes\test\struts>javac LoginActi on.java LoginAction.java:19: cannot find symbol symbol : variable ERROR_KEY location: class org.apache.struts.action.Action request.setAttribute(Action.ERROR_KEY, ae); ^
Simion Ursache
Greenhorn
Joined: Jan 17, 2006
Posts: 5
posted
0
Even Worse !
I have restarted the computer and i have MORE errors:
C:\ApacheGroup\Tomcat\webapps\struts\WEB-INF\classes\test\struts>javac loginacti on.java loginaction.java:4: package org.apache.struts.action does not exist import org.apache.struts.action.*; ^ loginaction.java:7: cannot find symbol symbol: class Action public class LoginAction extends Action { ^ loginaction.java:11: cannot find symbol symbol : class ActionMapping location: class test.struts.LoginAction public ActionForward perform(ActionMapping mapping, ActionForm form, ^ loginaction.java:11: cannot find symbol symbol : class ActionForm location: class test.struts.LoginAction public ActionForward perform(ActionMapping mapping, ActionForm form, ^ loginaction.java:11: cannot find symbol symbol : class ActionForward location: class test.struts.LoginAction public ActionForward perform(ActionMapping mapping, ActionForm form, ^ loginaction.java:18: cannot find symbol symbol : class ActionErrors location: class test.struts.LoginAction ActionErrors ae = lb.validate(); ^ loginaction.java:19: cannot find symbol symbol : variable Action location: class test.struts.LoginAction request.setAttribute(Action.ERROR_KEY, ae); ^ 7 errors
All of these errors are due to struts.jar not being in your classpath when you run javac. Read the previous entries in this thread for ideas on how to set it.