Solved

question on using dwr with spring

Posted on 2009-07-09
4
561 Views
Last Modified: 2012-08-14
This is my first time using dwr. I am using dwr 1.0 library and trying to integrate it with spring. I have a service class and a main AJAXUser class in which i am getting the bean name for my service layer through WebApplicationContextUtils and in the same AJAXUser class i am calling the service layer to get some values from the DB. Below you can see my configuration for dwr.xml.

EVerytime i run my JSP page and tries to click on a button which will call an Ajax function to output the values  i get a javascript error 'name cannot be null' and i get an exception in my console. I am sure that my service layer is defined properly in applicationContext.xml. It looks like the dwr.xml cannot instantiate my AJAXUser class.

<!DOCTYPE dwr PUBLIC 

"-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN"

 "http://www.getahead.ltd.uk/dwr/dwr10.dtd">

 <dwr>

 <allow>

 <create creator="spring" javascript="AJAX">

 <param name="class" value="user.AJAXUser"></param>

 </create>

 </allow>

 </dwr> 

 

Error :-

 

WARNING: Method execution failed: 

java.lang.IllegalArgumentException: 'name' must not be null

	at org.springframework.util.Assert.notNull(Assert.java:112)

	at org.springframework.beans.factory.BeanFactoryUtils.transformedBeanName(BeanFactoryUtils.java:71)

	at org.springframework.beans.factory.support.AbstractBeanFactory.transformedBeanName(AbstractBeanFactory.java:799)

	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)

	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)

	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:733)

	at uk.ltd.getahead.dwr.create.SpringCreator.getInstance(SpringCreator.java:143)

	at uk.ltd.getahead.dwr.impl.ExecuteQuery.execute(ExecuteQuery.java:181)

	at uk.ltd.getahead.dwr.impl.DefaultExecProcessor.handle(DefaultExecProcessor.java:48)

	at uk.ltd.getahead.dwr.impl.DefaultProcessor.handle(DefaultProcessor.java:81)

	at uk.ltd.getahead.dwr.AbstractDWRServlet.doPost(AbstractDWRServlet.java:162)

Open in new window

0
Comment
Question by:Micheal_Male
  • 2
  • 2
4 Comments
 
LVL 10

Expert Comment

by:mahome
ID: 24820772
If you are using Spring you use the param beanname and specfiy this name. Class is only used for creator "new".
So it have to be something like this:

Also have a look here: http://directwebremoting.org/dwr/server/integration/spring.html

<create creator="spring" javascript="AJAX">

    <param name="beanName" value="ajaxUser"/>

</create>

Open in new window

0
 

Author Comment

by:Micheal_Male
ID: 24828370
Thank you mahome. I created a beanName by the name ajaxUser in my applicationContext and had the property set to my userService and now my class is getting compiled. I actually thought the beanname was the ACTUAL beanname of my controller class.

0
 
LVL 10

Accepted Solution

by:
mahome earned 250 total points
ID: 24837732
Yes it's a little bit confusing, as there are two ways. If you use the creator "new" (see snippet) it would be the classname, but in that case DWR would instantiate your class and not Spring. In the spring way it's not necessary to declare the class as the declaration of the spring bean already contains the class-info.

<create creator="new" javascript="AJAX">

    <param name="class" value="user.ajaxUser"/>

</create>

Open in new window

0
 

Author Closing Comment

by:Micheal_Male
ID: 31601951
Perfect explanation. Thanks
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
copyEndy  challenge 15 55
maven java path setting 5 50
Understanding websocket example in spring 1 42
JDeveloper 12c for 32 bit 4 34
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now