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

compilation error

sonali rao
Ranch Hand

Joined: Nov 03, 2003
Posts: 64
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

Joined: Dec 02, 2003
Posts: 83
Hi,
Just set the classpath to the classes and then try . It will work
sonali rao
Ranch Hand

Joined: Nov 03, 2003
Posts: 64
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

Joined: Oct 28, 2002
Posts: 9
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

Joined: Nov 03, 2003
Posts: 64
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

Joined: Oct 28, 2002
Posts: 9
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

Joined: Nov 03, 2003
Posts: 64
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: compilation error
 
Similar Threads
Servlet action is not available
getting ClassNotFoundException
struts1.1 and tomcat 5.5.27
Error in deploying struts: Attribute name invalid according to the specified TLD
got stuck in running my first struts example. help