vaadin and ear

Hello Vaadin users.

I am a kinda noob in JavaEJB technology and Vaadin.

I have created two enterpriseArchive. One with the Vaadin WebProject and in the other one I dropped the vaadin jar in the EAR/APP-INF/lib, that enables me to create the EJBService ( shown below).

If I remove the createNewButton method, my ctxLookup and sayHello works fine , other wise I get the error (shown below).

I know I must be setting this up somehow wrong but don’t know how to fix. Appreciate any help.

I am using weblogic.

@Stateless(name="ExtraService", mappedName="ExtraService")
public class ExtraButtonsCreationImpl implements ExtraService{

	public Button createNewButton(String caption) {
		Button b = new Button(caption);
		return b;

	public String sayHello(String toWho) {
		return "Hello" + toWho;


System.out.println(getExtraService().sayHello(" Mr Lazy"));
body.addComponent(getExtraService().createNewButton("Lazy Boy"));

	private ExtraService getExtraService()  {
		InitialContext ctx;
		try {
			ctx = new InitialContext();
			ExtraService service = 
				(ExtraService) ctx.lookup("ExtraService#com.extranote.model.ExtraService");
			return service;
		} catch (NamingException e) {
		return null;

Cause: java.lang.NoClassDefFoundError: com/vaadin/ui/Button
	at com.vaadin.event.ListenerMethod.receiveEvent(
	at com.vaadin.event.EventRouter.fireEvent(
	at com.vaadin.ui.AbstractComponent.fireEvent(
	at com.vaadin.ui.Button.fireClick(
	at com.vaadin.ui.Button.changeVariables(
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(
	at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(
	at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(
	at javax.servlet.http.HttpServlet.service(
	at weblogic.servlet.internal.StubSecurityHelper$
	at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(
	at weblogic.servlet.internal.ServletStubImpl.execute(
	at weblogic.servlet.internal.ServletStubImpl.execute(
	at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.doIt(
	at weblogic.servlet.internal.WebAppServletContext$
	at weblogic.servlet.internal.WebAppServletContext.securedExecute(
	at weblogic.servlet.internal.WebAppServletContext.execute(
Caused by: java.lang.NoClassDefFoundError: com/vaadin/ui/Button
	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(
	at java.lang.Class.privateGetPublicMethods(
	at java.lang.Class.getMethods(
	at sun.misc.ProxyGenerator.generateClassFile(
	at sun.misc.ProxyGenerator.generateProxyClass(
	at java.lang.reflect.Proxy.getProxyClass(
	at weblogic.common.internal.ProxyClassResolver.resolveProxyClass(
	at weblogic.common.internal.WLObjectInputStream.resolveProxyClass(
	at weblogic.rmi.extensions.server.CBVInputStream.readObject(
	at weblogic.jndi.internal.JNDIHelper.copyObject(
	at weblogic.jndi.WLSJNDIEnvironmentImpl.copyObject(
	at weblogic.jndi.internal.WLEventContextImpl.copyObject(
	at weblogic.jndi.internal.WLEventContextImpl.lookup(
	at weblogic.jndi.internal.WLContextImpl.lookup(
	at javax.naming.InitialContext.lookup(
	at com.finenotes.MainApplication.getExtraService(
	at com.finenotes.MainApplication.insertNoteComponent(
	at com.finenotes.MainApplication.startApplication(
	at com.finenotes.MainApplication.access$0(
	at com.finenotes.MainApplication$1.buttonClick(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	at com.vaadin.event.ListenerMethod.receiveEvent(
	... 22 more
Caused by: java.lang.ClassNotFoundException: com.vaadin.ui.Button
	at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(
	at weblogic.utils.classloaders.GenericClassLoader.findClass(
	at java.lang.ClassLoader.loadClass(
	at java.lang.ClassLoader.loadClass(
	at weblogic.utils.classloaders.GenericClassLoader.loadClass(
	... 53 more

This is a classloading problem, but you probably already knew that :slight_smile:

Seems like either the vaadin classes are not available in the web application or classes are loaded twice using different classloaders and they are not compatible.

Should the classes in APP-INF/lib be visible both to ejbs and the web applications? If not, check that the same vaadin.jar is also in the WEB-INF/lib.

If it is a class compatibility issue, I guess the easiest option is to install the vaadin.jar into server common lib folder - not into the ear at all.

The vaadin.jar should only be in the web-part (war-file).
Only if your rely on it in the ejb part you have to move it to the ear itself.
So either in war (preferred) or in ear, not in both.

If it is only in the web part, the ejb part does not find the runtime classes for the createNewButton service.

What I mean is that I have seen application servers fail, if the classes shared between web and ejb parts are not installed at the server level. I hope this is not the case here, because it complicates the deployment.