Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compilation error

 
sonali rao
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
I am trying to compile a Action class but it gives me a compiler error. The following are the compilation errors.

C:\jakarta-tomcat-4.1.29\webapps\myproject\WEB-INF\classes\coreservlets\RegisterAction1.java:15: cannot resolve symbol
symbol : class UserFormBean
location: class coreservlets.RegisterAction1
UserFormBean userBean=(UserFormBean)form;
^
C:\jakarta-tomcat-4.1.29\webapps\myproject\WEB-INF\classes\coreservlets\RegisterAction1.java:15: cannot resolve symbol
symbol : class UserFormBean
location: class coreservlets.RegisterAction1
UserFormBean userBean=(UserFormBean)form;

Following is my Action class.
package coreservlets;
import javax.servlet.http.*;
import org.apache.struts.action.*;
public class RegisterAction1 extends Action {
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {

UserFormBean userBean=(UserFormBean)form;
String email = userBean.getEmail();
String pw = userBean.getPassword();
if((email==null)||(pw==null)||(email.indexOf("@")==-1))
return(mapping.findForward("failure"));
else
return(mapping.findForward("success"));
}
}

Following is my struts-config.xml file.
<struts-config>
<form-beans>
<form-bean name="userFormBean"
type="coreservlets.UserFormBean"/>
</form-beans>

<action-mappings>
<action path="/register1"
type="coreservlets.RegisterAction1"
name="userFormBean"
scope="request">
<forward name="success"
path="/result1.jsp"/>
<forward name="failure"
path="/result2.jsp"/>
</action>
</action-mappings>
</struts-config>
I have placed UserFormBean under classes/coreservlets and it compiled successfully.
What must have gone wrong?
Please let me know.
^
 
poornima balagopal
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Just set the classpath to the classes and then try . It will work
 
sonali rao
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have set the classpath for the 2 classes in the following manner. Is this the correct way to set the classpath? I tried doing this but it dint solve my problem.
C:\jakarts-tomcat-4.1.29\common\lib\servlet.jar;C:\jakarta-struts-1.1\lib\struts.jar;C:\jakarta-struts-1.1\webapps\myproject\WEB-INF\classes\coreservlets\UserFormBean.java;C:\jakarta-struts-1.1\webapps\myproject\WEB-INF\classes\coreservlets\RegisterAction1.java;
 
Rajesh Subbannavar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No You have to set the classpath in the following way.
1. If you are settin it from command prompt:
SET classpath=%classpath%;C:\jakarts-tomcat-4.1.29\common\lib\servlet.jar;C:\jakarta-struts-1.1\lib\struts.jar;C:\jakarta-struts-1.1\webapps\myproject\WEB-INF\classes
2. If you are updating the enevironment varibale:
C:\jakarts-tomcat-4.1.29\common\lib\servlet.jar;C:\jakarta-struts-1.1\lib\struts.jar;C:\jakarta-struts-1.1\webapps\myproject\WEB-INF\classes
Please notice that classpath is till your classes directory(not till your java files).
Hope this helps,
Rajesh
 
sonali rao
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again
I corrected my classpath in environment variables(windows xp).
I have set the classpath to the classes as said but it dint help. I still get the same compilation errors. When i try to access any bean from the Action class i get the same kind of errors.
Any suggestion of how to over come it?
[ March 11, 2004: Message edited by: sonali rao ]
 
Rajesh Subbannavar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just wonder how is it not compiling...Could you post your UserFormBean also.
Just sounds silly but are you sure package definition is present in your UserFormBean? Just a wild guess :-)
 
sonali rao
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
I am trying to compile a Action class but it gives me a compiler error. The following are the compilation errors.
C:\jakarta-tomcat-4.1.29\webapps\myproject\WEB-INF\classes\coreservlets\RegisterAction1.java:15: cannot resolve symbol
symbol : class UserFormBean
location: class coreservlets.RegisterAction1
UserFormBean userBean=(UserFormBean)form;
^
C:\jakarta-tomcat-4.1.29\webapps\myproject\WEB-INF\classes\coreservlets\RegisterAction1.java:15: cannot resolve symbol
symbol : class UserFormBean
location: class coreservlets.RegisterAction1
UserFormBean userBean=(UserFormBean)form;
Following is my Action class.
package coreservlets;
import javax.servlet.http.*;
import org.apache.struts.action.*;
public class RegisterAction1 extends Action {
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {

UserFormBean userBean=(UserFormBean)form;
String email = userBean.getEmail();
String pw = userBean.getPassword();
if((email==null)||(pw==null)||(email.indexOf("@")==-1))
return(mapping.findForward("failure"));
else
return(mapping.findForward("success"));
}
}
Following is UserFormBean class.
package coreservlets;
import org.apache.struts.action.*;
public class UserFormBean extends ActionForm {
private String email = "Missing address";
private String password = "Missing password";
public String getEmail() {
return(email);
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return(password);
}
public void setPassword(String password) {
this.password = password;
}
}

Following is my struts-config.xml file.
<struts-config>
<form-beans>
<form-bean name="userFormBean"
type="coreservlets.UserFormBean"/>
</form-beans>

<action-mappings>
<action path="/register1"
type="coreservlets.RegisterAction1"
name="userFormBean"
scope="request">
<forward name="success"
path="/result1.jsp"/>
<forward name="failure"
path="/result2.jsp"/>
</action>
</action-mappings>
</struts-config>
I have placed UserFormBean under classes/coreservlets and it compiled successfully. I corrected my classpath in environment variables(windows xp). I am using TextPad for compiling java classes.
I still get the same compilation errors. When i try to access any bean from the Action class i get the same kind of errors.
What must have gone wrong?
Please let me know.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic