Can not get the DataSource in buttonClick()

I’m using Vaadin 7.3.3 and Jetty-9.

I found that when I get the DataSource like this code in the buttonClick():

loginButton.addClickListener(new ClickListener() {

        public void buttonClick(ClickEvent event) {
            InitialContext ctx = new InitialContext();
            DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/myds");

[/code]I get this error : java.lang.IllegalStateException: javax.naming.NameNotFoundException; remaining name 'env/jdbc/myds' But get get the DataSource in other palces, such as in class constructor, it is fine.

And this error did not appear on jetty-8;

I found this issue caused by the the click event from client to server? I can get the datasource when I use the custom browser from my phone(Android), but failed with other browser, just like chrome, firefox…

Perhaps this could be an issue with different classloader instances being used, or a Jetty 9 bug.

Does it work in the constructor of the nesting class, or just some other class?

Are you using server push? If so, which transport are you using? Perhaps e.g. WebSockets leads to this listener being called in a thread where InitialContext initialization is problematic.

I am using server push, now, the Transport is STREAMING, and this problem will not disappear. But when I using Crtl + C to close the jetty9, a java.lang.NullPointerException will appear.