ZATS - NullPointerException

asked 2014-04-01 13:26:17 +0800

ziccardi gravatar image ziccardi
321 7

Hi all.

I'm trying to follow the documentation to write some unit test for my web application, however I always get a NullPointerException:

org.zkoss.zats.ZatsException at org.zkoss.zats.mimic.impl.EmulatorClient.connect(EmulatorClient.java:130) at x.y.z.testclass.fakeTest(UserManagementTest.java:50) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Caused by: java.lang.NullPointerException at org.zkoss.zats.mimic.impl.DefaultDesktopAgent.getId(DefaultDesktopAgent.java:42) at org.zkoss.zats.mimic.impl.EmulatorClient.connect(EmulatorClient.java:109) ... 27 more

I digged into the code, and found the problem to be here:

desktopAgents.put(desktopAgent.getId(), desktopAgent);

in my case, desktopAgent is null.

The page I'm trying to connect to is a zul page that includes a login.zul page that submits username/password to jspringsecurity_check.

Do you have any workaround?

Thanks in advance, Massimiliano

delete flag offensive retag edit


Do you use context/bindingsparams in the init/doaftercompose?

chillworld ( 2014-04-01 13:27:53 +0800 )edit

No... both the index.zul page and the included login.zul page do not have viewmodel or composer.

ziccardi ( 2014-04-01 13:47:20 +0800 )edit

3 Answers

Sort by » oldest newest most voted

answered 2014-04-01 13:50:30 +0800

ziccardi gravatar image ziccardi
321 7

updated 2014-04-01 13:51:01 +0800

The ZATS code I use is:

DefaultZatsEnvironment env = new DefaultZatsEnvironment("./src/main/webapp/WEB-INF");
env.newClient().connect("/public/index.zul"); // NullPointerException

Here is the index.zul page :

<?page title="${labels.a3serverweb.title}" contentType="text/html;charset=UTF-8"?>
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
    <borderlayout >
        <north height="52px">
                <west width="250px" sclass="a3-header-left"
                    border="none" />
                <center border="none" sclass="a3-header-center" />
                <east width="373px" sclass="a3-header-right"
        <west size="180px" style="background-color: darkgray;" collapsible="true" splittable="true">
            <include src="loginHelp.zul"/>
        <center autoscroll="true" >
            <window style="background-color: white">
                <include src="login.zul" />

Below the included login.zul page:

<?page id="testZul" title="CUSTOM ZK + SPRING SECURITY LOGIN"?>
<vlayout width="100%">
        String contextRoot = Executions.getCurrent().getContextPath();
    <space orient="vertical" height="30px" />
    <label sclass="z-header"
        value="${labels.a3serverweb.admin.login.instructions}" />
        <h:form id="f" name="f"
            action="${contextRoot}/j_spring_security_check" method="POST"
                    <column hflex="min" />
                    <column hflex="min" />
                    <column />
                            value="${labels.a3serverweb.admin.login.label.username}" />
                        <textbox id="u" name="j_username" />
                        <label />
                        <textbox id="p" type="password"
                            name="j_password" />

                        <button type="submit" label="Login" iconSclass="z-icon-sign-in a3server-button-icon"/>

                    <row spans="3">
                        <html style="color:red"
                            if="${not empty param.login_error}">

link publish delete flag offensive edit

answered 2014-04-01 15:07:32 +0800

IngoB gravatar image IngoB flag of Germany
256 6


DesktopAgent desktop = Zats.newClient().connect("/public/index.zul");


link publish delete flag offensive edit


That's the first think I did, and didn't work. Than I read that since I use spring I have to use the other syntax and changed from Zats.init to env.

ziccardi ( 2014-04-01 15:09:40 +0800 )edit

answered 2014-04-02 11:13:57 +0800

ziccardi gravatar image ziccardi
321 7

No workaround for this bug?

Do the ZK team still follow this forum?

I think this is a high priority bug: if the test is not able to pass the login page, there's no way to use it at all...

link publish delete flag offensive edit


Zk team follows this forum, got today answer from a team member of zk.

chillworld ( 2014-04-02 11:17:29 +0800 )edit

Thank you. I was beginning to think they didn't follow this anymore since lately I wrote more than one bug and never got an answer.I've even opened issues with working ZK fiddles to replicate the problem, but no-one did even comment the jira issue (http://tracker.zkoss.org/browse/ZK-2154).

ziccardi ( 2014-04-02 11:39:04 +0800 )edit

It take sometimes long, I just got 1 tracker resolved and a lot still open :). For your problem, with the zats, can't you put a user in the securitycontextholder so your authentication is already done?

chillworld ( 2014-04-02 12:23:40 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools




Asked: 2014-04-01 13:26:17 +0800

Seen: 30 times

Last updated: Apr 02 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More