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")
@TransactionAttribute(value=TransactionAttributeType.REQUIRED)
public class ExtraButtonsCreationImpl implements ExtraService{

	@Override
	public Button createNewButton(String caption) {
		Button b = new Button(caption);
		b.setStyleName(Runo.BUTTON_LINK);
		return b;
	}

	@Override
	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) {
			e.printStackTrace();
		}
		return null;
	}

com.vaadin.event.ListenerMethod$MethodException
Cause: java.lang.NoClassDefFoundError: com/vaadin/ui/Button
	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:1154)
	at com.vaadin.ui.Button.fireClick(Button.java:371)
	at com.vaadin.ui.Button.changeVariables(Button.java:193)
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1094)
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:590)
	at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:266)
	at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:476)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
	at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
	at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
	at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:183)
	at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.doIt(WebAppServletContext.java:3686)
	at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3650)
	at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
	at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
	at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2268)
	at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2174)
	at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1446)
	at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
	at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused by: java.lang.NoClassDefFoundError: com/vaadin/ui/Button
	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
	at java.lang.Class.privateGetPublicMethods(Class.java:2547)
	at java.lang.Class.getMethods(Class.java:1410)
	at sun.misc.ProxyGenerator.generateClassFile(ProxyGenerator.java:409)
	at sun.misc.ProxyGenerator.generateProxyClass(ProxyGenerator.java:306)
	at java.lang.reflect.Proxy.getProxyClass(Proxy.java:501)
	at weblogic.common.internal.ProxyClassResolver.resolveProxyClass(ProxyClassResolver.java:98)
	at weblogic.common.internal.WLObjectInputStream.resolveProxyClass(WLObjectInputStream.java:76)
	at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1531)
	at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1493)
	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
	at weblogic.rmi.extensions.server.CBVInputStream.readObject(CBVInputStream.java:64)
	at weblogic.jndi.internal.JNDIHelper.copyObject(JNDIHelper.java:28)
	at weblogic.jndi.WLSJNDIEnvironmentImpl.copyObject(WLSJNDIEnvironmentImpl.java:77)
	at weblogic.jndi.internal.WLEventContextImpl.copyObject(WLEventContextImpl.java:369)
	at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:255)
	at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:393)
	at javax.naming.InitialContext.lookup(InitialContext.java:392)
	at com.finenotes.MainApplication.getExtraService(MainApplication.java:175)
	at com.finenotes.MainApplication.insertNoteComponent(MainApplication.java:151)
	at com.finenotes.MainApplication.startApplication(MainApplication.java:72)
	at com.finenotes.MainApplication.access$0(MainApplication.java:52)
	at com.finenotes.MainApplication$1.buttonClick(MainApplication.java:41)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:487)
	... 22 more
Caused by: java.lang.ClassNotFoundException: com.vaadin.ui.Button
	at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:280)
	at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:253)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
	at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:177)
	... 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.