PDA

View Full Version : DWR 2.0.3 and Spring DM



huankev
Aug 1st, 2008, 01:08 AM
Hi everyone,

Has anyone ever got DWR AJAX libs working with Spring MVC and Spring web extender? I am having lots of problems with the dwrController init. Any help/direction would be greatly appreciated.

Thanks,

Kevin

See Exception:


SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListe ner
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'dwrController': Invocation of init method failed; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1337)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:473)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 64)
at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:221)
at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:261 )
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:729)
at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:381)
at org.springframework.osgi.context.support.AbstractD elegatedExecutionApplicationContext.normalRefresh( AbstractDelegatedExecutionApplicationContext.java: 148)
at org.springframework.osgi.context.support.AbstractD elegatedExecutionApplicationContext$NoDependencies WaitRefreshExecutor.refresh(AbstractDelegatedExecu tionApplicationContext.java:73)
at org.springframework.osgi.context.support.AbstractD elegatedExecutionApplicationContext.refresh(Abstra ctDelegatedExecutionApplicationContext.java:136)
at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 45)
at org.apache.catalina.core.StandardContext.listenerS tart(StandardContext.java:3843)
at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4350)
at org.apache.catalina.core.ContainerBase.addChildInt ernal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(Co ntainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(Sta ndardHost.java:525)
at org.springframework.osgi.web.deployer.tomcat.Tomca tWarDeployer.startCatalinaContext(TomcatWarDeploye r.java:144)
at org.springframework.osgi.web.deployer.tomcat.Tomca tWarDeployer.startDeployment(TomcatWarDeployer.jav a:133)
at org.springframework.osgi.web.deployer.support.Abst ractWarDeployer.deploy(AbstractWarDeployer.java:93 )
at org.springframework.osgi.web.extender.internal.act ivator.WarLoaderListener$DeploymentManager$DeployT ask.doRun(WarLoaderListener.java:244)
at org.springframework.osgi.web.extender.internal.act ivator.WarLoaderListener$DeploymentManager$BaseTas k.run(WarLoaderListener.java:216)
at org.springframework.scheduling.timer.DelegatingTim erTask.run(DelegatingTimerTask.java:66)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
Caused by: java.lang.NullPointerException
at org.directwebremoting.spring.DwrController.afterPr opertiesSet(DwrController.java:213)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1368)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1334)
... 31 more

dr_pompeii
Aug 1st, 2008, 08:43 AM
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListe ner
org.springframework.beans.factory.BeanCreationExce ption:
Error creating bean with name 'dwrController':
Invocation of init method failed;
nested exception is java.lang.NullPointerException

can you post your controller configuration?

regards

huankev
Aug 4th, 2008, 06:34 PM
Thanks for the reply,

My spring config are as follows:


<bean id="urlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlH andlerMapping">
<property name="mappings">
<props>
<prop key="/dwr/engine.js">dwrController</prop>
<prop key="/dwr/interface.js">dwrController</prop>
<prop key="/dwr/call/**">dwrController</prop>
<prop key="/dwr/interface/**">dwrController</prop>
</props>
</property>
</bean>

<dwr:controller id="dwrController" debug="true" />

<dwr:configuration>
<dwr:convert type="enum" class="com.bglobal.syd.valkyrie.domain.Status" />
</dwr:configuration>

And my

huankev
Aug 4th, 2008, 06:36 PM
and my web.xml if it helps


<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:persistence-context.xml /WEB-INF/dwr-context.xml /WEB-INF/valkyrie-servlet.xml
</param-value>
</context-param>

<context-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.osgi.web.context.support.OsgiB undleXmlWebApplicationContext</param-value>
</context-param>

<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListe ner
</listener-class>
</listener>

<servlet>
<display-name>DWR Servlet</display-name>
<servlet-name>dwr</servlet-name>
<servlet-class>
org.directwebremoting.spring.DwrSpringServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>activeReverseAjaxEnabled</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.osgi.web.context.support.OsgiB undleXmlWebApplicationContext</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>dwr</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>

dr_pompeii
Aug 4th, 2008, 07:21 PM
Hi there

i used to configure dwr/spring in the old way
after to see in google
it seems that this thread works
http://www.nabble.com/Spring-2.0.6-%2B-DWR-2.0-td12042078.html

regards

huankev
Aug 4th, 2008, 08:57 PM
Thanks again for the reply,

I've read the post you are referring to, it seems to deal with problem related to configuration with spring and DWR 2.0. In my case I can get Spring 2.5.5 to work with DWR 2.0.3 fine in conventional Tomcat Server.

It only stops working when deployed in OSGi environment with spring web extender. Any help on that would be greatly appreciated.

Thanks.

Costin Leau
Aug 6th, 2008, 06:33 AM
On a first glance, your configuration looks okay. The problem seems to be caused by a NPE inside DWR code:

org.directwebremoting.spring.DwrController.afterPr opertiesSet(DwrController.java:213)
Try looking at the sources to see what's wrong if that's possible.
It's likely a certain property is not set which causes the exception to be triggered.

huankev
Aug 6th, 2008, 06:23 PM
Thanks for looking into it Costin, currently I can bypass the problem by using the traditional way to config dwr, but it would be nice to be able to leverage Spring to config it.

Costin Leau
Aug 7th, 2008, 01:34 AM
I haven't used DWR so I'm don't know the traditional way or the 'Spring-way' - if you have any extra details on the problem, please post them here.
DWR aside, your post describes a configuration that fails due to a NPE inside the library code - I'm curios to see what's the assumption that the library code makes and why does that work outside OSGi...
Cheers,

Costin Leau
Aug 7th, 2008, 01:38 AM
I've searched for the sources and found this link: http://fisheye5.cenqua.com/browse/dwr/java/org/directwebremoting/spring/DwrController.java?r=1.25
However, there isn't anything interesting at line 213 which suggests that the code changed.
What's the version that you use?

Costin Leau
Aug 7th, 2008, 01:45 AM
Just saw the version in the title (2.0.3) - the associated source code might be this one:
http://tinyurl.com/5ono7j
Line 213 indicates a finally block calling methods on a variable that might not be initialized (if the statements before it throw an exception) which is what probably happens in your case.
Try debugging the code to catch the actual exception so we can figure out what's wrong - additionally, there seems to be some logging in there;that might help.

dafe52
Oct 15th, 2008, 11:23 AM
I have just the same problem... but It works in Jetty and in a previous version of my application in Tomcat... Suddenly I try to deploy my application and this error appears... I don't want to change to traditionally way because if it works in jetty properly... what happens with Tomcat ???