aspose file tools*
The moose likes Struts and the fly likes Problem with LoginAction.java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem with LoginAction.java" Watch "Problem with LoginAction.java" New topic
Author

Problem with LoginAction.java

Unnsse Khan
Ranch Hand

Joined: Nov 12, 2001
Posts: 511
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
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Did you code and compile the LoginBean?
http://www.javaranch.com/newsletter/Mar2002/listing6.html


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Unnsse Khan
Ranch Hand

Joined: Nov 12, 2001
Posts: 511
No, I didn't. I just copied it from that URL and pasted it (using vim)...
Unnsse Khan
Ranch Hand

Joined: Nov 12, 2001
Posts: 511
I am sorry, that I didn't understand your question... Yes... the LoginBean is already in its .class (interpreted byte code) format.
JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
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
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
Maybe as an enhancement I should supply an ANT file to do the compile.
JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
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
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
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
Hi, Unnsse:

Please try this:

Hi, Thomas, am I right?
[ February 23, 2003: Message edited by: JiaPei Jen ]
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Yes, that is perfect.
Unnsse Khan
Ranch Hand

Joined: Nov 12, 2001
Posts: 511
It worked! Thanks guys!
Simion Ursache
Greenhorn

Joined: Jan 17, 2006
Posts: 5
i am getting this error:


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
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

Can someone help me please ?!
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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.


Merrill
Consultant, Sima Solutions
Simion Ursache
Greenhorn

Joined: Jan 17, 2006
Posts: 5
ok...i think i removed it by mistake. But i still have the error with ERROR_KEY
Simion Ursache
Greenhorn

Joined: Jan 17, 2006
Posts: 5
ok...i found that there was an update for the first tutorial posted and followed every new step.

when i enter in the browser LoginView.jsp and MainMenu.jsp i get this errors:

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:370)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

java.lang.NullPointerException
org.apache.struts.taglib.TagUtils.retrieveMessageResources(TagUtils.java:1174)
org.apache.struts.taglib.TagUtils.message(TagUtils.java:1037)
org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java:224)
org.apache.jsp.jsp.LoginView_jsp._jspx_meth_bean_message_0(org.apache.jsp.jsp.LoginView_jsp:126)
org.apache.jsp.jsp.LoginView_jsp._jspService(org.apache.jsp.jsp.LoginView_jsp:84)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.12 logs.

i am using version 1.2.8 of struts...
Simion Ursache
Greenhorn

Joined: Jan 17, 2006
Posts: 5
the more i get into this the more errors i have:

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Cannot find message resources under key org.apache.struts.action.MESSAGE
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
org.apache.jsp.jsp.LoginView_jsp._jspService(org.apache.jsp.jsp.LoginView_jsp:110)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

javax.servlet.jsp.JspException: Cannot find message resources under key org.apache.struts.action.MESSAGE
org.apache.struts.util.RequestUtils.retrieveMessageResources(RequestUtils.java:1103)
org.apache.struts.util.RequestUtils.message(RequestUtils.java:1043)
org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java:294)
org.apache.jsp.jsp.LoginView_jsp._jspx_meth_bean_message_0(org.apache.jsp.jsp.LoginView_jsp:126)
org.apache.jsp.jsp.LoginView_jsp._jspService(org.apache.jsp.jsp.LoginView_jsp:84)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.12 logs.


???
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
This error is telling you that Struts can't find your message resources file.

Make sure the following entry is in your struts-config.xml file.

<message-resources parameter="ApplicationResources"/>

Then make sure the file ApplicationResources.properties exists in WEB-INF/classes and that it contains any message keys you're using.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem with LoginAction.java