Unable to follow J6EE wiki - NullPointerException

Hello To All of You,

I am trying to follow this tutorial on the
vaadin wiki
for creating a Vaadin JEE6 application. I am going for Option 2 here and watched the
mentioned at the end of the page.

I followed the steps exactly as described in the video. I also have netbeans (6.9.1) and I am using GlassFish v 3.1. The app is deployed without a problem. But as soon as I hit the Button
Say Hello
Glassfish shows the following error:

INFO: Portable JNDI names for EJB HelloBean : [java:global/Vaadin2/HelloBean, java:global/Vaadin2/HelloBean!com.example.vaadin.services.HelloBean]

INFO: WEB0671: Loading application [Vaadin2]
INFO: Vaadin2 wurde erfolgreich bereitgestellt in 1.687 Millisekunden.
SCHWERWIEGEND: =================================================================
Vaadin is running in DEBUG MODE.
Add productionMode=true to web.xml to disable debug features.
To show debug window, add ?debug to your application URL.
SCHWERWIEGEND: com.vaadin.event.ListenerMethod$MethodException
Cause: java.lang.NullPointerException
        at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:507)
        at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161)
        at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1107)
        at com.vaadin.ui.Button.fireClick(Button.java:341)
        at com.vaadin.ui.Button.changeVariables(Button.java:177)
        at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1060)
        at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:561)
        at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:260)
        at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:438)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
        at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1534)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
        at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
        at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:170)
        at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
        at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
        at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
        at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
        at java.lang.Thread.run(Thread.java:717)
Caused by: java.lang.NullPointerException
        at com.example.vaadin.Vaadin2$1.buttonClick(Vaadin2.java:40)
        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:613)
        at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:487)
        ... 34 more

I don’t know what I am doing wrong. Can someone please help me here?

This is my Vaadin-Class:

package com.example.vaadin;           

import com.example.vaadin.services.HelloBean;
import com.vaadin.Application;
import com.vaadin.ui.*;
import com.vaadin.data.*;
import com.vaadin.ui.Button.ClickEvent;
import javax.ejb.EJB;
import javax.enterprise.context.SessionScoped;
 * @author 
 * @version 
public class Vaadin2 extends Application {

    HelloBean helloBean;

    public void init() {
	Window mainWindow = new Window("Vaadin2");

        Label label = new Label("Hello Vaadin user");
        final TextField tf = new TextField();
        final Button bu = new Button("Say Hello");
        final Label msg = new Label();

        bu.addListener(new Button.ClickListener() {

            public void buttonClick(ClickEvent event) {





This is my Servlet:

package com.example.vaadin;

import com.vaadin.Application;
import com.vaadin.terminal.gwt.server.AbstractApplicationServlet;
import javax.enterprise.inject.Instance;
import javax.inject.Inject;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;

 * @author
public class Vaadin2Servlet extends AbstractApplicationServlet {

    Instance<Vaadin2> application;

    protected Application getNewApplication(HttpServletRequest request) throws ServletException {
        return application.get();

    protected Class<? extends Application> getApplicationClass() throws ClassNotFoundException {
        return Vaadin2.class;


And thats my SessionBean:

package com.example.vaadin.services;

import javax.ejb.Stateless;

 * @author
public class HelloBean {

    public String sayHello(String name) {
        return "Hello " + name + "!";
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")


No one?

I tried the whole day but I can not find out what’s wrong.

Maybe someone can send me a complete war-file, with such an example (which is working on his or her’s application server) which I then can deploy on my server. This way I might find out if my GlassFish has a wrong configuration.

I hate bagging. But please try to help me.


Hi Kurt!

I think you need to implement @Local interface in your Bean or use annotation @LocalBean.

public interface LocalHello{
        public String sayHello(String name);


public class HelloBean impements LocalHello{
        public String sayHello(String name) {
        return "Hello " + name + "!";


public class Vaadin2 extends Application {

    LocalHello helloBean;


public class HelloBean {
        public String sayHello(String name) {
        return "Hello " + name + "!";


thank you very much for your answer. I really appreciate it.

I tried it with the Local Interface as you said. But still I get the same error.

But I found something else out:

When I go for Option 1 in the
(Using Stateful Session) I get the same error.


when I delete the generated web.xml file (I am using the Vaadin Plugin for NetBeans) the thing works!!!

So I deleted the generated web.xml file in my Context and Dependency Example (Option 2 in the wiki) as well. But when doing this my browser is showing me a blank page (no error message). When I hit reload I get a HTTP Status 500

HTTP Status 500 -

type Exception report


descriptionThe server encountered an internal error () that prevented it from fulfilling this request.


javax.servlet.ServletException: java.lang.NullPointerException

root cause


note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1 logs.

So I guess this has something to do with GlassFish. But I can not find out what it is.

I am sure this can have a thousand reasons. However any help (even wild guesses) is really appreciated.


It’s easy. Download

That archive contains full example(2 way) how to use EJB and Vaadin UI

I used Netbeans 7.0 and Glassfish 3.1


you are my hero!!! I really mean it.

Your example works like a charm. Both the @EJB Annotation and the Standard Lookup. I downloaded it, unpacked it, deployed it and it worked!

I still haven’t found out what is wrong with my code. But now I know for sure that I am doing something wrong and that it is not GlassFish. As soon as I have found out I will post it here.

I can’t say thank you enough for all the effort you put in this.

All the best

Ok, I found out what was wrong. I don’t even want to say it as what I did is a bit stupid. Anyways here we go:

I took the wiki a little bit to literally. It says to create an empty beans.xml file. So I copied the given code in the wiki and pasted it into my file…

<?xml version="1.0" encoding="UTF-8"?>
<!-- Namespace declarations omitted -->

…and never thought about it.

While investigating Andris example and comparing it with mine I saw no difference. But then I checked the beans.xml file and saw my mistake. After altering it to:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">

my example from above works.

Sorry for wasting your time and thanks again to Andris who’s help was very useful for me.


Hi Kurt! I am glad that I helped you :slight_smile:

Oh yes, this empty beans.xml seems to be a common trap.
Did personally step on it several times being aware on this, both cost me a 1/2 hr of “wtf” brain overloading :slight_smile:


Glad I am not the only one. Although it took me much, much longer and the excellent help from Andris till I found out. I would have been so glad if it had take only 1/2 hr. :smiley:

I think it took me longer than you to solve this problem… I had stopped working on my project for weeks
and today I finally found the solution. The Wiki entry should definitley be changed to include the correct beans.xml :wink:

Made my Day!

Sorry that you have had troubles with the wiki page. Apparently we’re having problems with the urls within the namespace declarations - extraneous square brackets is inserted in the page, even if none have been written. I guess that was the original reason to omit the namespace declarations (I’m not the original author).

I’ll see what we can do about this, but I’m not making any promises :frowning:

Hi, Andris!

This file not avaible now. :frowning:
Can you repeat upload your example?

Thank you. Best regards!

Hi Yuriy!
New example url