abhi jitnag

Greenhorn
+ Follow
since Oct 17, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by abhi jitnag

Hi,

I have implemented CometProcessor in my TestComet java class and configure NIO connector in server.xml in Tomcat 7 accordingly.
When I am trying to hit the Servlet class through ajax, init() method of servlet is getting called but failed to call the
"event(CometEvent event)" method, rather it's calling service(HttpServletRequest request, HttpServletResponse response) method. It seems to me NIO is not configured properly. Could any one please suggest me where I went wrong.

The Servlet class :



Server.xml



URL I have hit through Browser :
http://localhost:8080/CometServerHome/TestComet

Response I received in Browser :
message You must be using the APR or NIO connector to get the event method called.
description The server encountered an internal error (You must be using the APR or NIO connector to get the event method called.) that prevented it from fulfilling this request.

In console
in init start
error

Please help me to resolve this problem.

12 years ago
Hi all,
I am facing a problem when trying to return value from formBackingObject

In Js

function callSearch(){
var empName=document.getElementById("empName").value;
document.forms[0].action = "applicationContextTest.html?empName="+empName;
document.forms[0].submit();
}


In Controller

protected Object formBackingObject(HttpServletRequest request){
String empName = request.getParameter("empName");
NewEmployeeCmd employee = new NewEmployeeCmd();
employee=employeeService.findEmployeeByName(empName);
return employee;
}

In dispatcher-servlet.xml

<bean name="/applicationContextTest.html" class="com.app.controller.ApplicationContextTest">
<property name="employeeService" ref="employeeService"></property>
</bean>

In jsp
<form:form method="post" commandName="employee" action="${FORM_ACTION_PATH}">
<fieldset><legend>${LABEL_NAME} Employee Details</legend>
<table width="90%" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td align="right" valign="middle"> </td>
<td align="center" valign="middle"> </td>
<td align="left" valign="middle"> </td>
</tr>
<tr>
<td width="35%" align="right" valign="middle">Employee Name</td>
<td width="5%" align="center" valign="middle"> </td>
<td width="60%" align="left" valign="middle">
<form:hidden path="employeeId" /> <form:input id="empName" path="employeeName" size="35" />
</td>
</tr>..........................

The control is coming to Controller properly but when returning ,it is giving following exception.
22-Apr-2011 21:49:23 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet dispatcher threw exception
javax.servlet.ServletException: successView isn't set
at org.springframework.web.servlet.mvc.SimpleFormController.onSubmit(SimpleFormController.java:423)....................


Could anyone please suggest.



12 years ago

Posts: 9

[Post New]posted Today 09:24:18
0
Quote Edit
I have written a java class for custom validation and update validation.xml, validator-rules.xml and struts-config.xml as below.

struts-config.xml

<form-bean name="emp_details" type="bean.EmpDetails"/>

<action-mappings>
<action path="/EmpSaveAaction"
type="action.hh"
name="emp_details"
scope="request"
validate="true"
input="/Rgistration.jsp"/>

<action path="/Welcome" forward="/welcomeStruts.jsp"/>
</action-mappings>


validation.xml

<form name="emp_details">
<field property="uname" depends="required">
<arg position="0" key="User Name" resource="false"/>
</field>
<field property="password" depends="required,mask,minlength,maxlength,password">
<arg position="0" key="password" resource="false"/>
<arg position="1" name="minlength" key="${var:minlength}" resource="false"/>
<arg position="1" name="maxlength" key="${var:maxlength}" resource="false"/>
<arg position="1" name="mask" key="${var:mask}" resource="false"/>
<var>
<var-name>mask</var-name>
<var-value>^[a-zA-Z]</var-value>
</var>
<var>
<var-name>minlength</var-name>
<var-value>5</var-value>
</var>
<var>
<var-name>maxlength</var-name>
<var-value>10</var-value>
</var>
</field>
</form>

validator-rules.xml

<validator name="password"
classname="customvalidation.AbhiValidation"
method="validatePasswordchk"
methodParams="java.lang.Object,
org.apache.commons.validator.Field,
javax.servlet.http.HttpServletRequest,
org.apache.commons.validator.Validator,
org.apache.commons.validator.ValidatorAction,
org.apache.struts.action.ActionMessages"
msg="errors.required"/>



And the java class for custom validation


import javax.servlet.http.HttpServletRequest;
import org.apache.commons.validator.Field;
import org.apache.commons.validator.Validator;
import org.apache.commons.validator.ValidatorAction;
import org.apache.commons.validator.ValidatorUtil;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.validator.Resources;

class AbhiValidation{
public static boolean validatePasswordchk(Object bean,ValidatorAction action,
Field field,ActionMessages errors,Validator validator,HttpServletRequest request){
String pass=ValidatorUtil.getValueAsString(bean,field.getProperty());
if(pass!=null){
if(pass.contains("-")){
errors.add(field.getKey(),Resources.getActionMessage(validator,request, action, field));
return false;
}
}
return true;
}



But during run control is not coming in java class.
The following exception has given

customvalidation.AbhiValidation.validatePasswordchk(java.lang.Object, org.apache.commons.validator.Field, javax.servlet.http.HttpServletRequest, org.apache.commons.validator.Validator, org.apache.commons.validator.ValidatorAction, org.apache.struts.action.ActionMessages)
org.apache.commons.validator.ValidatorException: customvalidation.AbhiValidation.validatePasswordchk(java.lang.Object, org.apache.commons.validator.Field, javax.servlet.http.HttpServletRequest, org.apache.commons.validator.Validator, org.apache.commons.validator.ValidatorAction, org.apache.struts.action.ActionMessages)
at org.apache.commons.validator.ValidatorAction.loadValidationMethod(ValidatorAction.java:627)

Could anyone please help.
12 years ago
I have used org.springframework.web.servlet.handler.SimpleUrlHandlerMapping

In dispatcher-servlet.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" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">


<!-- ************************************ SimpleUrlHandlerMapping **************************************** -->
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"/>


<!-- ************************************ CONTROLLER MAPPINGS **************************************** -->
<bean name="LoadEmployeeDetails" class="com.app.controller.LoadEmployeeDetailsController">
<property name="employeeService" ref="employeeService"></property>
<property name="applicationContextTest" ref="applicationContextTest"></property>
</bean>


In jsp page

<%
response.sendRedirect("LoadEmployeeDetails");
%>


In Web.xml

<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>

This is not working.
First time I am using this. Could anyone help me please.






12 years ago
Thank you.
12 years ago
In dispatcher-servlet we can do whatever we do in ApplicationContext.xml .

So why ApplicationContext.xml is used ?
12 years ago
Thanks for your reply.
I think struts-el-1.2.4.jar may be required. But I have solved the problem using the following jar and tld files.

struts.jar
struts-bean.tld struts-bean-el.tld
struts-html.tld struts-html-el.tld
struts-logic.tld struts-logic-el.tld
13 years ago

Hi all,
I am getting the following run time exception. Though I have place bothe struts.jar and struts-html-el.tld in WEB-INF/lib.

org.apache.jasper.JasperException: /pages/Login.jsp(55,0) Unable to load tag handler class "org.apache.strutsel.taglib.html.ELFormTag" for tag "html-el:form"
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:198)
org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1224)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1449)
org.apache.jasper.compiler.Parser.parse(Parser.java:133)..........

Please suggest me to address it.
13 years ago

Hi All,
During deployment of a war file in JBOSS I am getting the following problem. But it is deployed properly in Tomcat and no problem so far during building the war file.
The server log shows
2010-10-24 07:45:05,984 DEBUG [org.jboss.varia.deployment.BeanShellScript] Failed to obtain interfaces
java.lang.reflect.UndeclaredThrowableException
at $Proxy56.getInterfaces(Unknown Source)
at org.jboss.varia.deployment.BeanShellScript.loadScript(BeanShellScript.java:410)
at org.jboss.varia.deployment.BeanShellScript.<init>(BeanShellScript.java:109)
at org.jboss.varia.deployment.BeanShellSubDeployer.create(BeanShellSubDeployer.java:153)
at org.jboss.deployment.MainDeployer.create(MainDeployer.java:969)
at org.jboss.deployment.MainDeployer.create(MainDeployer.java:959)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:818)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
at sun.reflect.GeneratedMethodAccessor21.invoke(Unknown Source).............................

2010-10-24 07:45:05,984 DEBUG [org.jboss.varia.deployment.BeanShellScript] EvalError during create
Method create() not found in bsh scripted object: global : at Line: -1 : in file: <Called from Java Code> : <Compiled Java Code>

at bsh.This.invokeMethod(Unknown Source)
at bsh.This.invokeMethod(Unknown Source)
at bsh.XThis$Handler.invokeImpl(Unknown Source)
at bsh.XThis$Handler.invoke(Unknown Source)
at $Proxy56.create(Unknown Source)
at org.jboss.varia.deployment.BeanShellScript.createService(BeanShellScript.java:242)
at org.jboss.system.ServiceMBeanSupport.jbossInternalCreate(ServiceMBeanSupport.java:260)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:243)
at org.jboss.system.ServiceDynamicMBeanSupport.invoke(ServiceDynamicMBeanSupport.java:124)
at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
at $Proxy0.create(Unknown Source)
at org.jboss.system.ServiceController.create(ServiceController.java:330)
at org.jboss.system.ServiceController.create(ServiceController.java:273)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)

please reply
13 years ago
Thanks a lot for your reply. It works for me
13 years ago
Hi all,
During the deployment of a an application developed through spring hibernate struts I am getting the following problems.

2010-10-17 18:24:45,640 INFO [STDOUT] 18:24:45,625 ERROR [ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'baseHiberNetDao' defined in ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]: Cannot resolve reference to bean 'mySessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [org.jboss.resource.adapter.jdbc.WrapperDataSource] to required type [javax.sql.DataSource] for property 'dataSource'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [org.jboss.resource.adapter.jdbc.WrapperDataSource] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found
Caused by:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [org.jboss.resource.adapter.jdbc.WrapperDataSource] to required type [javax.sql.DataSource] for property 'dataSource'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [org.jboss.resource.adapter.jdbc.WrapperDataSource] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found
Caused by:
org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessException details (1) are:
PropertyAccessException 1:
org.springframework.beans.TypeMismatchException: Failed to convert property value of type [org.jboss.resource.adapter.jdbc.WrapperDataSource] to required type [javax.sql.DataSource] for property 'dataSource'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [org.jboss.resource.adapter.jdbc.WrapperDataSource] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found
Caused by:
java.lang.IllegalArgumentException: Cannot convert value of type [org.jboss.resource.adapter.jdbc.WrapperDataSource] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:224)
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:139)

Could you please suggest where I went wrong....
13 years ago