custom submenu won't react on click - oracle-sqldeveloper

I am trying to implement an extension in JDeveloper. It creats a submenu when you click on a DB package.
THe issue comes when I click on an element of my custom submenu, it returns a null pointer Exception.
I can't figure out where I did wrong.
Would you please help me?
Here is how a I created the submenu:
submenu.xml File:
<?xml version="1.0" encoding="windows-1252" ?>
<!-- usage of a name space?-->
<items id="my.contextMenu">
<folder type="PACKAGE">
<name>User Defined Context Menu</name>
<item reloadparent="true"
action-ref="utilitytools.customSave">
<title>saveThisPackage</title>
</folder>
</items>
extension.xml file:
<?xml version="1.0" encoding="UTF-8" ?>
<extension id="utilitytools" version="1.0" esdk-version="1.0"
rsbundle-class="utilitytools.Res"
xmlns="http://jcp.org/jsr/198/extension-manifest">
<name>Utility Tools</name>
<owner>A name</owner>
<dependencies>
<import>oracle.sqldeveloper</import>
<import>oracle.ide</import>
</dependencies>
<hooks>
<jdeveloper-hook xmlns="http://xmlns.oracle.com/jdeveloper/1013/extension">
<addins>
<addin>utilitytools.UtilityToolsAddin</addin>
</addins>
<actions xmlns="http://xmlns.oracle.com/jdeveloper/1013/extension">
<action id="utilitytools.customSave">
<properties>
<property name="Name">saveThisPackage</property>
<property name="SmallIcon"></property>
<property name="LongDescription"></property>
</properties>
<controller-class>utilitytools.savePackageController</controller-class>
<command-class>utilitytools.savePackageCommand</command-class>
</action>
</actions>
</jdeveloper-hook>
<sqldev-navigator-hook xmlns="http://xmlns.oracle.com/sqldeveloper/sqldev-navigator">
<descriptor>submenu.xml</descriptor>
</sqldev-navigator-hook>
</hooks>
</extension>
SubmenuListener file:
public final class SubMenuListener implements ContextMenuListener {
public SubMenuListener() {
super();
}
public void menuWillShow(ContextMenu contextMenu) {
contextMenu.add( contextMenu.createMenuItem(
IdeAction.find( savePackageCommand.actionId() )
));
}
public void menuWillHide(ContextMenu contextMenu) {
//Nothing
}
public boolean handleDefaultAction(Context context) {
return false;
}
}
And the command file:
/**
* Command handler for utilitytools.customSave.
*/
#RegisteredByExtension("utilitytools")
public final class sauvegardePackageCommand extends Command {
public savePackageCommand() {
super(actionId());
}
public int doit() {
SwingUtilities.invokeLater(new Runnable(){
public void run(){
showSaveWindow();
}
});
return OK;
}
/**
* Returns the id of the action this command is associated with.
*
* #return the id of the action this command is associated with.
* #throws IllegalStateException if the action this command is associated
* with is not registered.
*/
public static int actionId() {
final Integer cmdId = Ide.findCmdID(".utilitytools.customSave");
if (cmdId == null)
throw new IllegalStateException("Action esdksample.showElementClass not found.");
return cmdId;
}
private static void showSaveWindow(){
JFrame frame = new JFrame("SAVE");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new JPanelSavePackage());//Or any window you want to popup
frame.pack();
frame.setVisible(true);
}
}

Related

My action cant get data from a struts2 select tag

I'm developing a web app using struts 2 framework and i'm facing a problem with select tag in a jsp.
The select tag seems to work fine, but as soon as i press the submit button, my action cannot get the data from the select.
I have looked for problems about select, but all of them seem to be related with the list.
In my case, the list is shown fine. So, I'm quite lost and I dont know what should I do.
Here are my jsp code and my action code. When I press the submit, it suppose that the form will be sent to my action, and I shoud get the data from the form, but when I print the data is always null.
JSP Code:
<s:form action="borrarCita" method="post">
<s:select id="idCita" name="idCita" list="pendings" listKey="idCita" listValue="fecha" label="Elija una cita a anular"></s:select>
<s:submit value="Aceptar"/>
</s:form>
The action code:
public class CitasAction extends ActionSupport implements SessionAware{
private static final long serialVersionUID = 1L;
private Map session = ActionContext.getContext().getSession();
private List pendings= new ArrayList<Cita>();
private String idCita;
private String desplegarCitasPendientes;
private String pedirCita;
private String consultarCitas;
private String citaAnulada;
public String execute(){
return SUCCESS;
}
public String pedirCita(){
setCitaAnulada("");
setDesplegarCitasPendientes("");
setConsultarCitas("");
DbService db = (DbService)session.get("db");
Paciente paciente = (Paciente)session.get("Paciente");
List listaMedicos = db.getListaMedicos();
session.remove("listaCitas");
session.put("listaMedicos", listaMedicos);
setPedirCita("ok");
return SUCCESS;
}
public String desplegarCitasPendientes(){
setCitaAnulada("");
setPedirCita("");
setConsultarCitas("");
Paciente pac = (Paciente)session.get("user");
Iterator<Cita> nombreIterator = pac.getCitas().iterator();
while(nombreIterator.hasNext()){
Cita primera = nombreIterator.next();
if(primera.getStatus().equals("Pending")){
getPendings().add(primera);
}
}
setDesplegarCitasPendientes("ok");
return SUCCESS;
}
public String borrarCita(){
setConsultarCitas("");
setPedirCita("");
setDesplegarCitasPendientes("");
System.out.println(getIdCita());
System.out.println(ActionContext.getContext().getParameters().toString());
Paciente pac = (Paciente)session.get("user");
/*
Iterator<Cita> iterator = pac.getCitas().iterator();
while(iterator.hasNext()){
Cita primera = iterator.next();
if(primera.getFecha().equals(getFecha())){
iterator.remove();
break;
}
}
pac.setCitas(getPendings());
pac.getCitas().remove(getCitaSeleccionada());
session.put("user", pac);
DbService db = (DbService)session.get("db");
db.uploadPaciente(pac);*/
setCitaAnulada("ok");
return SUCCESS;
}
public String consultarCitas(){
setPedirCita("");
setDesplegarCitasPendientes("");
setCitaAnulada("");
setConsultarCitas("ok");
return SUCCESS;
}
public Map getSession() {
return session;
}
public void setSession(Map session) {
this.session = session;
}
public List getPendings() {
return pendings;
}
public void setPendings(List pendings) {
this.pendings = pendings;
}
public static long getSerialversionuid() {
return serialVersionUID;
}
public String getDesplegarCitasPendientes() {
return desplegarCitasPendientes;
}
public void setDesplegarCitasPendientes(String desplegarCitasPendientes) {
this.desplegarCitasPendientes = desplegarCitasPendientes;
}
public String getPedirCita() {
return pedirCita;
}
public void setPedirCita(String pedirCita) {
this.pedirCita = pedirCita;
}
public String getConsultarCitas() {
return consultarCitas;
}
public void setConsultarCitas(String consultarCitas) {
this.consultarCitas = consultarCitas;
}
public String getCitaAnulada() {
return citaAnulada;
}
public void setCitaAnulada(String citaAnulada) {
this.citaAnulada = citaAnulada;
}
public String getIdCita() {
return idCita;
}
public void setIdCita(String idCita) {
this.idCita = idCita;
}
}
So, to sum up, I have that select tag in a jsp and when a press the submit, the action doesn't get any data from the select.
I hope someone can help me with this because it's driving me crazy.
If you need more information, please let me know and I will try to post it as soon as posible.
Thanks in advance.
Edit:
Here is a part of the Cita.class code. Also it has the setters and the getters for every attribute.
public class Cita implements Serializable{
#Id #GeneratedValue
#Column(name="CITA_ID")
private int idCita;
#Column(name="FECHA")
#Temporal(TemporalType.DATE)
private Date fecha;
#Column(name="HORA")
#Temporal(TemporalType.TIME)
private Date hora;
#Column(name="ESTADO")
private String status;
#Column(name="ESPECIALIDAD")
private String especialidad;
#ManyToOne
#JoinColumn(name="MEDICO_ID")
private Medico medico;
#ManyToOne
#JoinColumn(name="PACIENTE_ID")
private Paciente paciente;
And here is the struts.xml:
<interceptors>
<interceptor name="logger" class="interceptor.LoginInterceptor"/>
<interceptor-stack name="myStack">
<interceptor-ref name="logger"/>
</interceptor-stack>
</interceptors>
<action name="desplegarCitasPendientes" class="action.CitasAction" method="desplegarCitasPendientes">
<interceptor-ref name="myStack"/>
<result name="success">/citas.jsp</result>
<result name="login" type="redirect">/index.jsp</result>
<result name="input">/index.jsp</result>
</action>
<action name="borrarCita" class="action.CitasAction" method="borrarCita">
<interceptor-ref name="myStack"/>
<result name="success">/citas.jsp</result>
<result name="login" type="redirect">/index.jsp</result>
<result name="input">/index.jsp</result>
</action>
#Jeroen, sorry for the huge wall of code. It was my first post here.
#Roman, I hope this helps you to help me :-)
Thanks for your replies guys.
Edit 2:
Here is my LoginInterceptor:
public class LoginInterceptor extends AbstractInterceptor {
/**
*
*/
private static final long serialVersionUID = 1L;
#Override
public String intercept(final ActionInvocation invocation) throws Exception {
Map<String, Object> session = invocation.getInvocationContext().getSession();
// sb: if the user is already signed-in, then let the request through.
if (session.get("user") != null) {
return invocation.invoke();
}else{
System.out.println("redirect");
return "login";
}
}
}
If you need something else, let me know :-)
Looks like a Interceptor issue.
What is myStack ?
Here's a sample stack I use in my projects (with Login Interceptor)
<package name="test" extends="struts-default">
<interceptors>
<interceptor name="nlogin" class="interceptors.LoginInterceptor"/>
<interceptor-stack name="loginStack">
<interceptor-ref name="nlogin"/>
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="loginStack"/>
<action name="test-list" class="actions.InboxAction">
<result>/pages/inbox/list.jsp</result>
</action>
</package>
loginStack is being used as the defaultStack for all actions in that package, because of <default-interceptor-ref name="loginStack"/>
ok guys, It seems that I fixed it. Thanks to the coding_idiot's answer, I was able to figure out what was wrong. It seems that lack of defaultStack in my own stack was the problem. I just added the defaultStack and it looks like working fine now.
So, thank you very much to everyone and specially to coding_idiot.
The code finally looks like:
<interceptors>
<interceptor name="logger" class="interceptor.LoginInterceptor"/>
<interceptor-stack name="myStack">
<interceptor-ref name="logger"/>
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
</interceptors>

Eclipse WebService client generation from WSDL not working properly

I've got a wsdl with the following code (just a part):
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:sch="http://www.test.com/App" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.test.com/App" targetNamespace="http://www.test.com/App">
<wsdl:types>
<xs:schema xmlns:process="http://www.test.com/App" xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.test.com/App" version="1.0" xdb:mapStringToNCHAR="true" xdb:mapUnboundedStringToLob="true" xdb:schemaURL="ddd" xdb:storeVarrayAsTable="true">
<xs:simpleType name="ClientCountry">
<xs:restriction base="xs:string">
<xs:enumeration value="CLCO1">
<xs:annotation>
<xs:documentation>Spain</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="CLCO2">
<xs:annotation>
<xs:documentation>Portugal</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
</xs:schema>
</wsdl:types>
</wsdl:definitions>
I've used this wsdl to generate the Java source files using Eclipse (File->New->Other->Web Services->Web Service Client).
It has generated all classes from the wsdl. However, when generating the enumeration types has made just this:
public class ClientCountry implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = -2280793720095616022L;
private java.lang.String _value_;
private static java.util.HashMap _table_ = new java.util.HashMap();
// Constructor
protected ClientCountry(java.lang.String value) {
_value_ = value;
_table_.put(_value_,this);
}
public static final java.lang.String _CLCO1 = "CLCO1";
public static final java.lang.String _CLCO2 = "CLCO2";
public static final ClientCountry CLCO1 = new ClientCountry(_CLCO1);
public static final ClientCountry CLCO2 = new ClientCountry(_CLCO2);
public java.lang.String getValue() { return _value_;}
public static ClientCountry fromValue(java.lang.String value)
throws java.lang.IllegalArgumentException {
ClientCountry enumeration = (ClientCountry)
_table_.get(value);
if (enumeration==null) throw new java.lang.IllegalArgumentException();
return enumeration;
}
public static ClientCountry fromString(java.lang.String value)
throws java.lang.IllegalArgumentException {
return fromValue(value);
}
public boolean equals(java.lang.Object obj) {return (obj == this);}
public int hashCode() { return toString().hashCode();}
public java.lang.String toString() { return _value_;}
public java.lang.Object readResolve() throws java.io.ObjectStreamException { return fromValue(_value_);}
}
I was wondering if there could be any option to make it generates a simple enumeration class using the xs:documentation description as keys for the enum.
Ok. Using jaxws with maven, the generated class now is:
#XmlType(name = "ClientCountry")
#XmlEnum
public enum ClientCountry {
/**
* Spain
*
*/
#XmlEnumValue("CLCO1")
CLCO_1("CLCO1"),
/**
* Portugal
*
*/
#XmlEnumValue("CLCO2")
CLCO_2("CLCO2");
private final String value;
ClientCountry(String v) {
value = v;
}
public String value() {
return value;
}
public static ClientCountry fromValue(String v) {
for (ClientCountry c: ClientCountry.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
}
}
Much better, but still not perfect, is it?

How to setConstraintViolations on EditorDriver using return value of client side Validator Validate method call

Using GWT 2.5.0,
I would like to use Client side validation and Editors. I encounter the following error when trying to pass the ConstraintViolation java.util.Set to the EditorDriver as follows.
Validator a = Validation.buildDefaultValidatorFactory().getValidator();
Set<ConstraintViolation<Person>> b = a.validate(person);
editorDriver.setConstraintViolations(b);
The method setConstraintViolations(Iterable<ConstraintViolation<?>>) in the type EditorDriver<Person> is not applicable for the arguments (Set<ConstraintViolation<Person>>)
The only somewhat relevant post I could find was Issue 6270!
Below is an Example which brings up a PopUpDialog with a Person Editor that allows you to specify a name and validate it against your annotations. Commenting out the personDriver.setConstraintViolations(violations); line in the PersonEditorDialog will allow you to run the example.
I don't have enough reputation points to post the image of the example.
Classes
Person
public class Person {
#NotNull(message = "You must have a name")
#Size(min = 3, message = "Your name must contain more than 3 characters")
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
PersonEditorDialog
public class PersonEditorDialog extends DialogBox implements Editor<Person> {
private static PersonEditorDialogUiBinder uiBinder = GWT
.create(PersonEditorDialogUiBinder.class);
interface PersonEditorDialogUiBinder extends
UiBinder<Widget, PersonEditorDialog> {
}
private Validator validator;
public PersonEditorDialog() {
validator = Validation.buildDefaultValidatorFactory().getValidator();
setWidget(uiBinder.createAndBindUi(this));
}
interface Driver extends SimpleBeanEditorDriver<Person, PersonEditorDialog> {
};
#UiField
ValueBoxEditorDecorator<String> nameEditor;
#UiField
Button validateBtn;
private Driver personDriver;
#UiHandler("validateBtn")
public void handleValidate(ClickEvent e) {
Person created = personDriver.flush();
Set<ConstraintViolation<Person>> violations = validator
.validate(created);
if (!violations.isEmpty() || personDriver.hasErrors()) {
StringBuilder violationMsg = new StringBuilder();
for (Iterator<ConstraintViolation<Person>> iterator = violations.iterator(); iterator.hasNext();) {
ConstraintViolation<Person> constraintViolation = (ConstraintViolation<Person>) iterator
.next();
violationMsg.append(constraintViolation.getMessage() + ",");
}
Window.alert("Detected violations:" + violationMsg);
personDriver.setConstraintViolations(violations);
}
}
#Override
public void center() {
personDriver = GWT.create(Driver.class);
personDriver.initialize(this);
personDriver.edit(new Person());
super.center();
}
}
SampleValidationFactory
public final class SampleValidationFactory extends AbstractGwtValidatorFactory {
/**
* Validator marker for the Validation Sample project. Only the classes and
* groups listed in the {#link GwtValidation} annotation can be validated.
*/
#GwtValidation(Person.class)
public interface GwtValidator extends Validator {
}
#Override
public AbstractGwtValidator createValidator() {
return GWT.create(GwtValidator.class);
}
}
EditorValidationTest
public class EditorValidationTest implements EntryPoint {
/**
* This is the entry point method.
*/
public void onModuleLoad() {
PersonEditorDialog personEditorDialog = new PersonEditorDialog();
personEditorDialog.center();
}
}
UiBinder
PersonEditorDialog.ui.xml
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:e="urn:import:com.google.gwt.editor.ui.client">
<ui:style>
.important {
font-weight: bold;
}
</ui:style>
<g:HTMLPanel>
<g:Label>Enter your Name:</g:Label>
<e:ValueBoxEditorDecorator ui:field="nameEditor">
<e:valuebox>
<g:TextBox />
</e:valuebox>
</e:ValueBoxEditorDecorator>
<g:Button ui:field="validateBtn">Validate</g:Button>
</g:HTMLPanel>
</ui:UiBinder>
GWT Module
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.0//EN"
"http://google-web-toolkit.googlecode.com/svn/tags/2.5.0/distro-source/core/src/gwt-module.dtd">
<module rename-to='editorvalidationtest'>
<inherits name='com.google.gwt.user.User' />
<inherits name='com.google.gwt.user.theme.clean.Clean' />
<inherits name="com.google.gwt.editor.Editor"/>
<!-- Validation module inherits -->
<inherits name="org.hibernate.validator.HibernateValidator" />
<replace-with
class="com.test.client.SampleValidationFactory">
<when-type-is class="javax.validation.ValidatorFactory" />
</replace-with>
<!-- Specify the app entry point class. -->
<entry-point class='com.test.client.EditorValidationTest' />
<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />
</module>
Libs required on Classpath
hibernate-validator-4.1.0.Final.jar
hibernate-validator-4.1.0.Final-sources.jar
validation-api-1.0.0.GA.jar (in GWT SDK)
validation-api-1.0.0.GA-sources.jar (in GWT SDK)
slf4j-api-1.6.1.jar
slf4j-log4j12-1.6.1.jar
log4j-1.2.16.jar
As discussed in the comments, the following cast was determined to be a valid workaround.
Set<?> test = violations;
editorDriver.setConstraintViolations((Set<ConstraintViolation<?>>) test);
This is what I do over and over again :
List<ConstraintViolation<?>> adaptedViolations = new ArrayList<ConstraintViolation<?>>();
for (ConstraintViolation<Person> violation : violations) {
adaptedViolations.add(violation);
}
editorDriver.setConstraintViolations(adaptedViolations);
The driver has a wild card generic type defined and you can not pass in the typed constraint violations.

Use Dispatcher servlet for interceptor call only for selective URL

I am having a controller class with two types of methods. first type must execute its body as soon as URL is hit suppose "http://localhost:8080/SpringAOP1/welcome/two/aa". Here SpringAOP1 is my project,welcome is the controller class name(Which is set with annotation) and two is the function name with parameter "aa".
The Second type of function needs to be pre-handled by a interceptor.So when URL is hit suppose "http://localhost:8080/SpringAOP1/welcome/intercep/six/aa" the interceptor must be called. Here i am passing the "intercep" parameter with all those functions of second type which needs interceptor call.
Controller class:-
#Controlle
#RequestMapping("/welcome")
public class HelloController {
#RequestMapping(method = RequestMethod.GET)
public String printWelcome1(ModelMap model) {
model.addAttribute("message", "Spring 3 MVC Hello World 1");
return "hello";
}
#RequestMapping( value="two/{name}", method = RequestMethod.GET)
public String printWelcome2(#PathVariable String name,ModelMap model) {
model.addAttribute("message", "Spring 3 MVC Hello World 2");
model.addAttribute("value", name);
return "hello";
}
#RequestMapping( value="intercep/six/{name}", method = RequestMethod.GET)
public String printWelcome6(#PathVariable String name,ModelMap model) {
model.addAttribute("message", "Spring 3 MVC Hello World 6");
model.addAttribute("value", name);
return "hello";
}
`
Dispatcher servlet
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="com.mkyong.common.controller" />
<bean name="HijackBeforeMethod" class="com.mkyong.common.controller.HijackBeforeMethod"/>
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/intercep/*"/>
<bean id="HijackBeforeMethod" class="com.mkyong.common.controller.HijackBeforeMethod" />
</mvc:interceptor>
</mvc:interceptors>
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="order" value="0" />
<property name="prefix">
<value>/WEB-INF/pages/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
HijackBeforeMethod
(This is the interceptor Class which is called)
public class HijackBeforeMethod extends HandlerInterceptorAdapter {
public Boolean comp(String u,String p)
{
Map mMap = new HashMap();
mMap.put("aa", "bb");
mMap.put("mm", "nn");
mMap.put("xx", "yy");
Iterator iter = mMap.entrySet().iterator();
String k,v;
Boolean flg=false;
while (iter.hasNext())
{
Map.Entry mEntry = (Map.Entry) iter.next();
if(mEntry.getKey().equals(u) && mEntry.getValue().equals(p))
flg=true;
}
return flg;
}
public boolean preHandle(HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse, Object o) throws Exception {
String u="aa";
String p="bb";
//System.out.println(" The username is--> "+u+" and pass is --> "+p);
Boolean ch=comp(u,p);
if(ch)
{
if(httpServletRequest.getMethod().equalsIgnoreCase("get")){
String uri = httpServletRequest.getRequestURI();
System.out.println("The method is GET :: "+ uri);
}
else
{
return false;
}
}
}
Please help me finding this. I am in greate trouble..
You can use the WebRequestInterceptor interface instead of HandlerInterceptorAdapter.
The following code segment is working fine for me.
public class FlashInterceptor implements WebRequestInterceptor {
private Flash flash;
#Autowired
public void setFlash(Flash flash) {
this.flash = flash;
}
#Override
public void preHandle(WebRequest request) throws Exception {
final Map<String, Object> messages = flash.getMessages();
if (messages.containsKey("flash_info")) {
request.setAttribute("flash_info", messages.get("flash_info"),
RequestAttributes.SCOPE_REQUEST);
request.setAttribute("flash_info_params",
messages.get("flash_info_params"),
RequestAttributes.SCOPE_REQUEST);
}
if (messages.containsKey("flash_error")) {
request.setAttribute("flash_error", messages.get("flash_error"),
RequestAttributes.SCOPE_REQUEST);
request.setAttribute("flash_error_params",
messages.get("flash_error_params"),
RequestAttributes.SCOPE_REQUEST);
}
if (messages.containsKey("flash_success")) {
request.setAttribute("flash_success",
messages.get("flash_success"),
RequestAttributes.SCOPE_REQUEST);
request.setAttribute("flash_success_params",
messages.get("flash_success_params"),
RequestAttributes.SCOPE_REQUEST);
}
flash.reset();
}
#Override
public void postHandle(WebRequest request, ModelMap model) throws Exception {
}
#Override
public void afterCompletion(WebRequest request, Exception ex)
throws Exception {
}
}

Unable to instantiate Action, signupFormAction, defined for 'signupForm' in namespace '/'signupFormAction. ClassNotFoundException: signupFormAction

Been trying to setup a Struts2 + Sprint + Hibernate basic framework and was working on creating a sample application. Everything configured and the stack doesnt through any error/exception while starting tomcat. Even when I run the action it doesnt throw any Exception, but on the browser it throws the following stack
Unable to instantiate Action, signupFormAction, defined for 'signupForm' in namespace '/'signupFormAction
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:318)
com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:399)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:198)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:475)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
root cause
java.lang.ClassNotFoundException: signupFormAction
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:157)
com.opensymphony.xwork2.ObjectFactory.getClassInstance(ObjectFactory.java:107)
com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:223)
com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:143)
com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:150)
com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:120)
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:299)
com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:399)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:198)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:475)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
My struts.xml
<struts>
<!-- <constant name="struts.enable.DynamicMethodInvocation" value="false" />-->
<constant name="struts.devMode" value="false" />
<constant name="struts.custom.i18n.resources" value="ApplicationResources" />
<package name="default" extends="struts-default" namespace="/">
<action name="login" class="loginAction">
<result name="success">welcome.jsp</result>
<result name="error">login.jsp</result>
</action>
<action name="signup" class="registerAction" method="add">
<result name="success">welcome.jsp</result>
<result name="error">login.jsp</result>
</action>
<action name="signupForm" class="signupFormAction">
<result name="input">registerForm.jsp</result>
<result name="error">login.jsp</result>
</action>
</package>
</struts>
My SpringBeans.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<!-- Database Configuration -->
<import resource="config/spring/DataSource.xml" />
<import resource="config/spring/HibernateSessionFactory.xml" />
<!-- Beans Declaration -->
<import resource="com/srisris/khiraya/spring/register.xml" />
<import resource="com/srisris/khiraya/spring/login.xml" />
</beans>
My register.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<!-- <bean id="ownerService" class="com.srisris.khiraya.service.OwnerServiceImpl">-->
<!-- <property name="ownerDAO" ref="ownerDAO" />-->
<!-- </bean>-->
<bean id="signupForm" class="com.srisris.khiraya.action.RegisterAction"/>
<!-- <bean id="registerAction" class="com.srisris.khiraya.action.RegisterAction">-->
<!-- <property name="ownerService" ref="ownerService" /> -->
<!-- </bean>-->
<!-- <bean id="ownerDAO" class="com.srisris.khiraya.dao.OwnerDAOImpl" >-->
<!-- <property name="sessionFactory" ref="sessionFactory" />-->
<!-- </bean>-->
</beans>
My Action Class
package com.srisris.khiraya.action;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.srisris.khiraya.dao.hibernate.Owner;
import com.srisris.khiraya.service.OwnerService;
#SuppressWarnings("rawtypes")
public class RegisterAction extends ActionSupport implements ModelDriven{
private static final long serialVersionUID = 6521996078347478542L;
private String ownerFirstName;
private String ownerLastName;
private String username;
private String password;
private String ownerPhone;
private String ownerEmail;
private OwnerService ownerService;
Owner owner = new Owner();
public void setOwnerService(OwnerService ownerService) {
this.ownerService = ownerService;
}
public String add() {
owner.setOwnerFirstName(ownerFirstName);
owner.setOwnerLastName(ownerLastName);
owner.setOwnerPassword(password);
owner.setOwnerPhone(ownerPhone);
owner.setOwnerEmail(ownerEmail);
ownerService.save(owner);
return SUCCESS;
}
public String execute() {
return INPUT;
}
public String getOwnerFirstName() {
return ownerFirstName;
}
public void setOwnerFirstName(String ownerFirstName) {
this.ownerFirstName = ownerFirstName;
}
public String getOwnerLastName() {
return ownerLastName;
}
public void setOwnerLastName(String ownerLastName) {
this.ownerLastName = ownerLastName;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getOwnerPhone() {
return ownerPhone;
}
public void setOwnerPhone(String ownerPhone) {
this.ownerPhone = ownerPhone;
}
public String getOwnerEmail() {
return ownerEmail;
}
public void setOwnerEmail(String ownerEmail) {
this.ownerEmail = ownerEmail;
}
public Object getModel() {
return owner;
}
}
I made a trivial mistake which costed me hours of pain. Silly me the problem was that my class name in struts.xml and id in register.xml were not matching and hence the issue.