T THRADINGHAM | 16 May 2013 13:50

[dwr-users] Dwr error on WAS 8.5

Hi guys,
I wonder if you can help me as I'm experiencing a strange issue with DWR, Spring and Websphere.
 
My setup currently is Websphere 7, Spring 2.5, Dwr 2. We are moving to Websphere 8.5. This causes us the dreaded crossDomainSessionSecurity issue - currently remedied by changing the dwr configuration setting to false as per the current guidelines - and everything is working as expected.
At some stage we will probably upgrade to Dwr 3 and as we are undergoing a WAS change at the moment I decided to test this out. So I have downloaded Dwr 3 and included the jar in one of my applications. We have a number of apps using Dwr so we have no plan for major changes, but simple configuration changes are ok.
 
So, my setup now is Websphere 8.5, Dwr 3, Spring 2.5.
When trying to access my app I am getting the following error thrown in the WAs logs -
 
[16/05/13 10:37:03:478 BST] 00000092 startup I org.directwebremoting.impl.StartupUtil logStartup Starting: DwrController v3.0.0-RC2-final-312 on IBM WebSphere Application Server/8.0 / JDK 1.6.0 from IBM Corporation at /Myapp
[16/05/13 10:37:03:587 BST] 00000092 startup E org.directwebremoting.impl.DefaultCreatorManager addCreator Javascript name MyAjaxHandler is used by 2 classes (com.chubb.ezer.myapp.web.ajax.handlers.MyAjaxHandlerImpl and BeanCreator[MyAjaxHandler])
[16/05/13 10:37:03:587 BST] 00000092 DwrController E org.directwebremoting.spring.DwrController afterPropertiesSet init failed
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Duplicate name found. See logs for details.
at org.directwebremoting.spring.SpringConfigurator.configure(SpringConfigurator.java:151)
at org.directwebremoting.impl.StartupUtil.configure(StartupUtil.java:702)
at org.directwebremoting.spring.DwrController.afterPropertiesSet(DwrController.java:200)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1368)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
 
As far as I can tell this error is being caused by the dwr configuration of the javascript files and I am unable to resolve this.I have looked everywhere I can and am yet to find a resolution. Could you please help?
 
Here are the code snippets of our setup
 
web.xml
<servlet>
<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>
</servlet>
<servlet-mapping>
<servlet-name>dwr</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
 
 
dwrsetupbeans.xml
 
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.directwebremoting.org/schema/spring-dwr
http://www.directwebremoting.org/schema/spring-dwr-3.0.xsd">
<bean id="myAjaxHandler"
class="com.chubb.ezer.myapp.web.ajax.handlers.MyAjaxHandlerImpl">
<aop:scoped-proxy/>
<property name="myService" ref="myService" />
<property name="requestBuilder" ref="requestBuilder" />
<dwr:remote javascript="MyAjaxHandler">
<dwr:include method="doSave"/>
</dwr:remote>
</bean>
<dwr:controller id="dwrController" debug="true"></dwr:controller>
<dwr:configuration></dwr:configuration>
 
somemappings.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">
<!--
using two mapping handlers:
1st will map to a bean matching the URL
2nd will pass anything not picked up by the 1st to a DWR controller
-->
<bean name="urlMapping2"
class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping">
<property name="order">
<value>0</value>
</property>
</bean>
<bean name="urlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="lazyInitHandlers">
<value>true</value>
</property>
<property name="mappings">
<props>
<prop key="/*">dwrController</prop>
</props>
</property>
</bean>
 
excerpt from a root jsp file
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="expires" content="${today}">
<link href="${ctx}/style/myGeneral.css" rel="stylesheet" type="text/css">
<script src="${ctx}/javascript/h1Section.js"></script>
<script src='${ctx}/dwr/engine.js'></script>
<script src='${ctx}/dwr/util.js'></script>
<script src='${ctx}/dwr/interface/MyAjaxHandler.js'></script>
 
excerpt from the java objects
 
public interface MyAjaxHandler {
public String doSave(String arg);
}
public class MyAjaxHandlerImpl extends AbstractAjaxHandler implements MyAjaxHandler {
MyService myService;
private RequestBuilder requestBuilder;
public String doSave(String arg) {
//code here
return (arg);
}
 
 
As you can see the objects exposed to Dwr are implementations of an interface.
I believe that should cover all the various components involved and hope someone may be able to point me to a solution. Please remember that this exact same setup works with Dwr2, Spring2.5 and WAS 8.5 but with the added cross Domain session secuity setting.
Regards
Tim
Fordemo Only | 15 May 2013 00:08
Picon
Favicon

[dwr-users]

Hello
I re-deployed an app with changes, none of which I believed affected dwr and I am getting the error below.  Works perfectly in the previous environment.  Using 2.0.10, same error when deployed to Tomcat 6.0.29 and Tomcat 6.0.37.  DWR is in \WEB-INF\lib I am nonplused.  I have nothing else to try.  tia.

error snipped
0    [http-8080-1] ERROR org.directwebremoting.impl.DefaultCreatorManager  error - Error loading class for creator 'StrutsCreator[pojo00]'.
java.lang.NullPointerException
    at org.directwebremoting.struts.StrutsCreator.getType(StrutsCreator.java:121)
    at org.directwebremoting.impl.DefaultCreatorManager.addCreator(DefaultCreatorManager.java:118)
    at org.directwebremoting.impl.DefaultCreatorManager.addCreator(DefaultCreatorManager.java:100)
    at org.directwebremoting.impl.DwrXmlConfigurator.loadCreate(DwrXmlConfigurator.java:274)
    at org.directwebremoting.impl.DwrXmlConfigurator.loadAllows(DwrXmlConfigurator.java:224)
    at org.directwebremoting.impl.DwrXmlConfigurator.configure(DwrXmlConfigurator.java:170)
    at org.directwebremoting.impl.ContainerUtil.configureFromDefaultDwrXml(ContainerUtil.java:264)
    at org.directwebremoting.impl.ContainerUtil.configureContainerFully(ContainerUtil.java:421)
    at org.directwebremoting.servlet.DwrServlet.init(DwrServlet.java:79)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
...

drw.xml snipped
<!DOCTYPE dwr PUBLIC
    "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN"
    "http://directwebremoting.org/schema/dwr20.dtd">

    <dwr>
      <allow>
        <create creator="struts" javascript="pojo00" scope="session">
          <param name="formBean" value="ccAuth13_genericForm_FBO_dwr"/>
          <include method="makePOJO" />
          <include method="phaseTwoData" />
          <include method="reportWriter00" />
...
Josh Sents | 7 May 2013 18:40

[dwr-users] How disable escaped single quotes in JSON/JSONP response with dwr-3.0.0.rc2 and jsonpEnabled

I have been using DWR-native remote inside our web application.  It works awesome! Now I am creating an API for an external client within the same application.  The client has required that I return valid JSON response.   I have enabled JSON/JSONP and I get the response back from the server with the expected data.     The problem is that the JSON does not pass JSON validation.  Here is a sample site that validates a JSON string http://jsonlint.com/ .  I think the only issue is that the String fields have single quotes escaped. 

Is there a way to disable escaping for the JSON/JSONP remote responses only and leave the escaping enabled DWR-native remote?

 

Thanks

Josh

Mike Wilson | 8 May 2013 16:15
Picon
Favicon

[dwr-users] Re: Memory Leak in Clock Demo DWR 2.0.5 and IE 9

Ok, thanks for testing, Mark. I still find it strange that IE is leaking with the script tag approach. I'll keep an eye out for this in our work on http://bugs.directwebremoting.org/jira/browse/DWR-576.
 
Best regards
Mike
 
Mark Priest wrote:
Mike,

I didn't see any improvement in the leak with your script tag approach.  It was still leaking about 6.4 mb/hr.   using your script tag approach.  The memory is reclaimed when I refresh the browser.

It's worth mentioning that this leak isn't likely to be a problem for a lot of people.  In our case, customers want our app to run for a week at a time or longer without refreshing the page so any leak starts to be a problem.  I think this is probably a rare requirement, however.  Also, if we could use Chrome or Firefox I don't think we would see any leak.


On Sun, May 5, 2013 at 6:50 AM, Mike Wilson <mikewse-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:
Thanks for testing. Both JS functions trigger closures internally in IE so it might be those that IE have a hard time cleaning up. They don't have a great track record in that department ;-)
 
It might be worth trying something that doesn't trigger any closures at all. I'm successfully running the following in my local env:
 
dwr.engine._eval = function(script) {
    if (script == null) return null;
    if (script == "") { dwr.engine._debug("Warning: blank script", true); return null; }
    var elem = document.createElement("script");
    elem.text = script;
    var head = document.getElementsByTagName("head")[0];
    head.appendChild(elem);
    head.removeChild(elem);
};
 
I haven't had time to test a lot of browsers yet, or do any long running resource tests. It would be great if you could try to see what (if any) difference it makes for you?
 
Best regards
Mike
 
Mark Priest wrote:
Mike/David,

Unfortunately, I didn't see any improvement using execScript.  That function is used to do an eval in the global scope and is intended to be used to load long-lived scripts dynamically.

My coworker tried the approach of doing the eval in an iframe as suggested in the Microsoft knowledge base article I referenced.  This was their suggestion for use with IE 7.   The leak was reduced to 40% of the leak we see using eval in the parent.   However,  the memory does not get reclaimed in that case until you close the browser.   When doing the eval without the iframe the memory is reclaimed when the page is refreshed or when you browse to a new page.

We are still planning to go down the road of removing eval altogether and sending JSON back to the browser rather than executable JavaScript.

-Mark

On May 3, 2013, at 11:18 AM, David Marginian <david-H55tQ8LTKd1xxXtqJ93Y6g@public.gmane.org> wrote:

Just an FYI guys, I tried replacing our _eval last night with a version that uses the execScript and all our tests pass, etc.  So if it fixes the memory leak it will be a good fix to get in.


On Fri, May 3, 2013 at 9:15 AM, Mike Wilson <mikewse-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:
Great find, thanks Mark!
BTW, in my tests I got much lower memory increase than 8MB/hr so it seems it can vary depending on some environmental factor.
Looking forward to your execScript tests! Another alternative could be to add an inline <script> tag containing the script through the DOM.
 
Best regards
Mike
 
Mark Priest wrote:
A simpler way to demonstrate that the leak disappears when removing eval() is to run the clock demo but edit the engine.js like so:

dwr.engine._eval = function(script) {
  if (script == null) return null;
  if (script == "") { dwr.engine._debug("Warning: blank script", true); return null; }
  // dwr.engine._debug("Exec: [" + script + "]", true);
  
  //return eval(script);
  // hard-code the response so we don't call eval
  var batchNum = dwr.engine._nextBatchId - 1;
  dwr.util.setValue("clockDisplay", "" + batchNum);
  dwr.engine._remoteHandleCallback("" + batchNum,'0',0);

};

If you do that then you can test by doing this:

1. Hit the clock demo page and start the clock 
2. Close the browser 
3. Hit the clock demo page again and see the batch ids being printed

That is necessary because I changed _eval() to just print the batch id every time rather than eval the expression (and print the server date/time) and the first time that gets messed up by the call to start the clock.  After the first few minutes the memory usage stabilizes and it leaks very little - maybe 37 kb/hr compared to 8 mb/hr in the unedited demo.


Mike Wilson | 8 May 2013 16:17
Picon
Favicon

[dwr-users] Re: Incomplete reply from server in Chrome - when using location.href or window.parent.location

Does the last solution seem to work well, Aneesh?
Best regards
Mike 

Aneesh Vijendran wrote:
> Hi Mike,
> Thanks. I tried the first step and it seems to work. But will 
> confirm with a
> bit more testing.
> 
> Thanks
> Aneesh

Yabing Chen | 26 Jan 2012 01:15
Favicon
Gravatar

[dwr-users] Yabing Chen is out of the office.


I will be out of the office starting  01/25/2012 and will not return until
01/31/2012.

I will respond to your message when I return.

Shravan Shetty | 22 Jan 2012 23:14
Picon

[dwr-users] Creating/managing sessions for different users using DWR

Hello DWR users,

I am a newbie to both web development as well as DWR, so may be this question is very basic. I tried to do a lot of
reading (in vain) before posting this question. 
Version: 3.0 RC2. Eclipse IDE and tomcat server.

I am using DWR on cross-domain environment, all the remote calls are working fine. When the user logs in, I
want to save the session variables: userID and service version at user logon. What I currently see is a new
script session ID generated per DWR remote call. But the session variables set after user logs on are lost,
as new session is created per DWR request. 

What should I do to see those session variables set during the remote DWR login() request by all subsequent
requests till the user logs out? Thanks for any suggestions.

Regards,
Shaun
disller | 20 Jan 2012 00:43
Picon

[dwr-users] Can I bind postHook to each requect

Cos I need to wrap some remote call into call back( I do not know what is the
remote call ), I need do different things when the getting the response(
onStateChanged ),such before the remote call, the system generate a task id
and remove it when finish the call , so I want to set the postHook, but,
this postHook is a global stuff, another remote call will still call this
postHook. 

--
View this message in context: http://dwr.2114559.n2.nabble.com/Can-I-bind-postHook-to-each-requect-tp7205871p7205871.html
Sent from the DWR - Users mailing list archive at Nabble.com.

Bala123 | 18 Jan 2012 13:18
Picon

[dwr-users] dwr calls to another server

I want to use the dwr on a different machine which runs the application.for
example: I have server A with tomcat (jsp and js) and Server B - tomcat -
where the java files are stored

how can i achieve this ? 

--
View this message in context: http://dwr.2114559.n2.nabble.com/dwr-calls-to-another-server-tp7199966p7199966.html
Sent from the DWR - Users mailing list archive at Nabble.com.

Darrell Esau | 17 Jan 2012 20:32

[dwr-users] mixing single shots with batching

Hi all,


Say I've got an application that's polling on a regular interval for data.  I have a number of "data clients" in the browser that all have different remote method calls.  Since these aren't user-spawned events, I want to batch them up to all send together, thus only using one connection.  

However, during this polling cycle, I've also got user-generated events which result in remote calls.  I don't want any delay on these calls .. so I don't want them batched.

Is there any way that I can mix batched calls and single shot calls?

So .. I'd start a batch, then end it every 5 seconds or so (then immediately start another one).  During these batches however, I'd want to send off calls at any time, outside the batch.

Thanks!

-d

Stevo Slavić | 17 Jan 2012 17:33
Picon
Gravatar

[dwr-users] Where did dwr 3.0 RC3 snapshots go?

Hello dwr community,

dwr 3.0 rc3 snapshots used to be published on sonatype oss snapshots repository, but that directory is empty - see https://oss.sonatype.org/content/repositories/snapshots/org/directwebremoting/dwr-core/3.0.0-rc3-SNAPSHOT/

What happened with these files? From dwr sources I see it still uses sonatype parent 6 (see http://svn.directwebremoting.org/dwr/trunk/pom.xml ) so distribution management is inherited and snapshots should be released at sonatype oss snapshots repo.

Thinking out loud - maybe there is some cleanup job and there have been no (successful) dwr 3.0 RC3 snapshot builds for some time.
E.g. there are snapshots of dwr 2.0.9, with date from 2012 (see https://oss.sonatype.org/content/repositories/snapshots/org/directwebremoting/dwr/2.0.9-SNAPSHOT/ )

Kind regards,
Stevo.


Gmane