Problem i18n4vaadin use.

Hello everyone
I try to create a project that uses the add-on i18n4vaadin.
I work with Netbeans 7.4 and I use the Maven.
in fact I have two concerns:

  • The first: when I compile my project, the generation is not done in the manner described “MyClasse.java” to “MyClasseBundle.java” but I only “Bundle.java” in each package. I think this is due to a misconfiguration of my Project / Netbeans (I can not do it), and for “message.properties” .
    -the second: when I run my project I get the error (exception) NullPointerException Grave: Servlet.service() for servlet [com.github.peholmst.i18n4vaadin.simple.demo.DemoUI$Servlet] in context with path [/I18N] threw exception [com.vaadin.server.ServiceException: java.lang.NullPointerException] with root cause java.lang.NullPointerException at com.github.peholmst.i18n4vaadin.simple.demo.Bundle.getLocale(Bundle.java:28) at com.github.peholmst.i18n4vaadin.simple.demo.Bundle.getBundle(Bundle.java:37) at com.github.peholmst.i18n4vaadin.simple.demo.Bundle.getMessage(Bundle.java:71) at com.github.peholmst.i18n4vaadin.simple.demo.Bundle.name_caption(Bundle.java:43) at com.github.peholmst.i18n4vaadin.simple.demo.DemoView.updateStrings(DemoView.java:73) at com.github.peholmst.i18n4vaadin.simple.demo.DemoView.<init>(DemoView.java:48) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at java.lang.Class.newInstance(Class.java:374) at com.vaadin.navigator.Navigator$ClassBasedViewProvider.getView(Navigator.java:336) at com.vaadin.navigator.Navigator.navigateTo(Navigator.java:512) at com.github.peholmst.i18n4vaadin.simple.demo.DemoUI.init(DemoUI.java:73) at com.vaadin.ui.UI.doInit(UI.java:639) at com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:224) at com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(UIInitHandler.java:76) at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41) at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1404) at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:305) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:724) I do not know the exact cause of this error.
    my code is:

[code]
import com.github.peholmst.i18n4vaadin.I18N;
import com.github.peholmst.i18n4vaadin.annotations.Message;
import com.github.peholmst.i18n4vaadin.simple.I18NProvidingUIStrategy;
import com.github.peholmst.i18n4vaadin.simple.SimpleI18N;
import com.github.peholmst.i18n4vaadin.util.I18NHolder;
import com.github.peholmst.i18n4vaadin.util.I18NProvider;
import com.vaadin.annotations.PreserveOnRefresh;
import javax.servlet.annotation.WebServlet;

import com.vaadin.annotations.Theme;
import com.vaadin.annotations.Title;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.navigator.Navigator;
import com.vaadin.navigator.ViewChangeListener;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.UI;
import fonction.fn01.CustomFactureView;
import gz.tn.db.tables.LwUtilisateur;
import gz.tn.logtexweb.login.CustomLogin;
import gz.tn.logtexweb.login.CustomRegistre;
import gz.tn.logtexweb.vues.CustomGlobal;
import java.util.Arrays;
import java.util.Locale;

@Theme(“mytheme”)
@SuppressWarnings(“serial”)
@PreserveOnRefresh
@Title(“Appli WEB”)
public class MyVaadinUI extends UI implements I18NProvider {

public Navigator navigator;

private I18N i18n = new SimpleI18N(Arrays.asList(new Locale("fr"), new Locale("en")));

static {
    I18NHolder.setStrategy(new I18NProvidingUIStrategy());
}

@Override
public I18N getI18N() {
    return i18n;
}

@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = MyVaadinUI.class, widgetset = "gz.tn.logtexweb.AppWidgetSet")
public static class Servlet extends VaadinServlet {
}
Bundle bundle = new Bundle();

@Message(key = "message1", value = "FR Message")

@Override
protected void init(VaadinRequest request) {
    try {
        navigator = new Navigator(this, this);

        System.out.println(bundle.message1());
        
        getNavigator().addView("", CustomLogin.class);
        getNavigator().addView(CustomLogin.NAME, CustomLogin.class);
        getNavigator().addView(CustomGlobal.NAME, CustomGlobal.class);
        getNavigator().addView(CustomRegistre.NAME, CustomRegistre.class);

        getNavigator().addView(CustomFactureView.NAME, CustomFactureView.class);

        //
        // We use a view change handler to ensure the user is always redirected
        // to the login view if the user is not logged in.
        //
        getNavigator().addViewChangeListener(new ViewChangeListener() {

            @Override
            public boolean beforeViewChange(ViewChangeEvent event) {

                LwUtilisateur utilisateur = (LwUtilisateur) getSession().getAttribute("utilisateur");

                // Check if a user has logged in
                boolean isLoggedIn = utilisateur != null;
                boolean isLoginView = event.getNewView() instanceof CustomLogin;
                boolean isRegistreView = event.getNewView() instanceof CustomRegistre;

                if (!isLoggedIn && !isLoginView) {
                    // Redirect to login view always if a user has not yet
                    // logged in
                    getNavigator().navigateTo(CustomLogin.NAME);
                    return false;

                } else if (isLoggedIn && isLoginView) {
                    // If someone tries to access to login view while logged in,
                    // then cancel
                    return false;
                }

                return true;
            }

            @Override
            public void afterViewChange(ViewChangeEvent event) {

            }
        });

    } catch (Exception e) {
        e.printStackTrace();
    }
}

}
[/code]The generated class Bundle.java is

import com.github.peholmst.i18n4vaadin.I18N;
import com.github.peholmst.i18n4vaadin.LocaleChangedEvent;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import javax.annotation.Generated;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.event.Observes;
import javax.enterprise.event.Reception;
import javax.inject.Inject;

/**
 * Please note that this class is not thread safe! Invocations from multiple
 * threads must be synchronized!
 */
@Generated(value = "com.github.peholmst.i18n4vaadin.ap.shared.JavaFileGenerator", date = "2014-10-07T19:19:48+0200")
@SessionScoped
public class Bundle implements java.io.Serializable {

    private transient ResourceBundle bundle;

    @Inject I18N i18n;

    private Locale getLocale() {
        return i18n.getLocale();
    }

    void localeChanged(@Observes(notifyObserver = Reception.IF_EXISTS) LocaleChangedEvent event) {
        bundle = null;
    }

    ResourceBundle getBundle() {
        if (bundle == null) {
            bundle = ResourceBundle.getBundle("gz.tn.logtexweb.messages", getLocale());
        }
        return bundle;
    }

    public String message1(Object... args) {
        return getMessage("message1", args);
    }

    public static final class Keys {

        private Keys() {
        }
        public static final String message1 = "message1";
    }

    public String getMessage(String key, Object... args) {
        try {
            final MessageFormat mf = new MessageFormat(getBundle().getString(key), getLocale());
            return mf.format(args, new StringBuffer(), null).toString();
        } catch (MissingResourceException e) {
            return "!" + key;
        }
    }

    public static String getMessage(String key, Locale locale, Object... args) {
        try {
            ResourceBundle bundle = ResourceBundle.getBundle("gz.tn.logtexweb.messages", locale);
            final MessageFormat mf = new MessageFormat(bundle.getString(key), locale);
            return mf.format(args, new StringBuffer(), null).toString();
        } catch (MissingResourceException e) {
            return "!" + key;
        }
    }
}

Thank you for any help.

hello,
I tried a test with a demo application (without CDI) but I still have the same problems.
There may be something I did not do or I am wrong.
Thank you for any help.

good evening,
Finally I found the solution to the blocking part (the null pointer exception).
I deleted the two entries dependency treatment related with CDI pom.xml of shots it works and I was able to move forward.

[code]

javax
javaee-web-api
6.0
provided

        <!-- API -->
        <dependency>
            <groupId>com.github.peholmst.i18n4vaadin</groupId>
            <artifactId>i18n4vaadin-api</artifactId>
            <version>2.0.0</version>
        </dependency>

        <!-- CDI support
        <dependency>
            <groupId>com.github.peholmst.i18n4vaadin</groupId>
            <artifactId>i18n4vaadin-cdi</artifactId>
            <version>2.0.0</version>
        </dependency>
         -->
        <!-- Annotation processor
        <dependency>
            <groupId>com.github.peholmst.i18n4vaadin</groupId>
            <artifactId>i18n4vaadin-cdi-ap</artifactId>
            <version>2.0.0</version>
            <scope>provided</scope>
        </dependency>




com.github.peholmst.i18n4vaadin
i18n4vaadin-simple
2.0.0



com.github.peholmst.i18n4vaadin
i18n4vaadin-simple-ap
2.0.0
provided

[/code]you should not put the two dependencies “without CDI” and “with CDI” simultaneously.
I have a question now that I can move forward in my project, is there a way to run the translation of custumLayout?
kind regards,