IntelliJ Java IDE
The moose likes Struts and the fly likes Struts - Cannot compile class Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Application Frameworks » Struts
Reply Bookmark "Struts - Cannot compile class" Watch "Struts - Cannot compile class" New topic
Author

Struts - Cannot compile class

Ramphery Negrete
Greenhorn

Joined: Sep 28, 2004
Posts: 4
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!
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 23635

Ramphery,
Welcome to Javaranch!

SubmitForm is a class that you wrote. Assuming it exists, you need to add it to your classpath.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Certs: SCEA Part 1, Part 2 & 3 & Core Spring 3, OCAJP
Ramphery Negrete
Greenhorn

Joined: Sep 28, 2004
Posts: 4
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

Joined: Sep 28, 2004
Posts: 4
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!!
 
IntelliJ Java IDE
 
subject: Struts - Cannot compile class
 
Threads others viewed
Exception in Running Struts in Tomcat
can not be able to compile Action Class
Difficulty in re- rendering form data, eventhough no exception is thrown up
HI Friends
compilation fails
IntelliJ Java IDE