• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts - Cannot compile class

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi:

I�m trying to run my first struts application, but... I have a problem with class compilation. Code is:

/**SubmitAction.java**/
package hansen.playground;

import javax.servlet.http.*;
import org.apache.struts.action.*;

public final class SubmitAction extends Action {

public ActionForward perform(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {

SubmitForm f = (SubmitForm) form; // get the form bean
// and take the last name value
String lastName = f.getLastName();
// Translate the name to upper case
//and save it in the request object
request.setAttribute("lastName", lastName.toUpperCase());

// Forward control to the specified success target
return (mapping.findForward("success"));
}
}
/**End SubmitAction.java**/

The error message:

C:\Tomcat4112\webapps\struts2\WEB-INF\classes\hansen\playground>javac SubmitAction.java
SubmitAction.java:13: cannot resolve symbol
symbol : class SubmitForm
location: class hansen.playground.SubmitAction
SubmitForm f = (SubmitForm) form; // get the form bean
^
SubmitAction.java:13: cannot resolve symbol
symbol : class SubmitForm
location: class hansen.playground.SubmitAction
SubmitForm f = (SubmitForm) form; // get the form bean
^
2 errors

My CLASSPATH:
CLASSPATH=C:\Tomcat4112\common\lib\servlet.jar;
C:\struts-1.2.4\lib\struts.jar;
C:\struts-1.2.4\lib\commons-beanutils.jar;C:\struts-1.2.4\lib\commons-collections.jar;
C:\struts-1.2.4\lib\commons-logging.jar;
C:\struts-1.2.4\lib\antlr.jar;
C:\struts-1.2.4\lib\commons-digester.jar;
C:\struts-1.2.4\lib\commons-validator.jar;
C:\struts-1.2.4\lib\jakarta-oro.jar;
C:\Tomcat4112\webapps\struts2\WEB-INF\classes\hansen\playground\SubmitAction.java;

I will appreciate your help, thanks in advance!
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ramphery,
Welcome to Javaranch!

SubmitForm is a class that you wrote. Assuming it exists, you need to add it to your classpath.
 
Ramphery Negrete
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there:
I modified the CLASSPATH, but the problem persist. I am obtainig the same error message from java sdk.

The class SubmitForm:
package hansen.playground;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.*;

public final class SubmitForm extends ActionForm {

/* Last Name */
private String lastName = "Morales"; // default value
public String getLastName() {
return (this.lastName);
}
public void setLastName(String lastName) {
this.lastName = lastName;
}

/* Address */
private String address = null;
public String getAddress() {
return (this.address);
}
public void setAddress(String address) {
this.address = address;
}

/* Sex */
private String sex = null;
public String getSex() {
return (this.sex);
}
public void setSex(String sex) {
this.sex = sex;
}

/* Married status */
private String married = null;
public String getMarried() {
return (this.married);
}
public void setMarried(String married) {
this.married = married;
}

/* Age */
private String age = null;
public String getAge() {
return (this.age);
}
public void setAge(String age) {
this.age = age;
}
}


CLASSPATH=C:\Tomcat4112\common\lib\servlet.jar;C:\struts-1.2.4\lib\struts.jar;
C:\struts-1.2.4\lib\commons-beanutils.jar;C:\struts-1.2.4\lib\commons-collections.jar;
C:\struts-1.2.4\lib\commons-logging.jar;
C:\struts-1.2.4\lib\antlr.jar;
C:\struts-1.2.4\lib\commons-digester.jar;
C:\struts-1.2.4\lib\commons-validator.jar;
C:\struts-1.2.4\lib\jakarta-oro.jar;
C:\Tomcat4112\webapps\struts2\WEB-INF\classes\hansen\playground\SubmitForm.class;
C:\Tomcat4112\webapps\struts2\WEB-INF\classes\hansen\playground\SubmitForm.java;
C:\Tomcat4112\webapps\struts2\WEB-INF\classes\hansen\playground\SubmitAction.java;

Thanks in advance!!
 
Ramphery Negrete
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Finally I fix the compilation problem setting the CLASSPATH variable with the path to the classes's container folder.

CLASSPATH=C:\Tomcat4112\common\lib\servlet.jar;
C:\struts-1.2.4\lib\struts.jar;
C:\struts-1.2.4\lib\commons-beanutils.jar;C:\struts-1.2.4\lib\commons-collections.jar;
C:\struts-1.2.4\lib\commons-logging.jar;
C:\struts-1.2.4lib\antlr.jar;
C:\struts-1.2.4\lib\commons-digester.jar;
C:\struts-1.2.4\lib\commons-validator.jar;
C:\struts-1.2.4\lib\jakarta-oro.jar;
C:\Tomcat4112\webapps\struts2\WEB-INF\classes;

Have a nice day!!
 
reply
    Bookmark Topic Watch Topic
  • New Topic