java.lang.ClassNotFoundException: com$vaadin$ui$Grid inside Eclipse with to

Hi,
I’m getting this weird behaviour from my Vaadin into Eclipse.

If I launch Vaadin with tomcat7:run , every View that I’ve manually created works fine, but if I try to click on a view that is created with Vaadin Designer, it throws this error… looks like he’s not finding the classes inside it.

giu 19, 2018 1:09:49 PM com.vaadin.server.DefaultErrorHandler doDefault
GRAVE: 
java.lang.IllegalArgumentException: Unable to create an instance of {0}. The constructor threw an exception.
	at com.vaadin.util.ReflectTools.createInstance(ReflectTools.java:298)
	at com.vaadin.navigator.Navigator$ClassBasedViewProvider.getView(Navigator.java:412)
	at it.xxx.xxx.xxxNavigator$2.getView(xxxNavigator.java:165)
	at com.vaadin.navigator.Navigator.navigateTo(Navigator.java:652)
	at it.xxx.xxx.xxxMenu$ValoMenuItemButton$1.buttonClick(xxxMenu.java:268)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:499)
	at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:273)
	at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:237)
	at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:1014)
	at com.vaadin.ui.Button.fireClick(Button.java:384)
	at com.vaadin.ui.Button$1.click(Button.java:57)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:155)
	at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:116)
	at com.vaadin.server.communication.ServerRpcHandler.handleInvocation(ServerRpcHandler.java:445)
	at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:410)
	at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:274)
	at com.vaadin.server.communication.PushHandler.lambda$new$1(PushHandler.java:146)
	at com.vaadin.server.communication.PushHandler.callWithUi(PushHandler.java:236)
	at com.vaadin.server.communication.PushHandler.onMessage(PushHandler.java:522)
	at com.vaadin.server.communication.PushAtmosphereHandler.onMessage(PushAtmosphereHandler.java:87)
	at com.vaadin.server.communication.PushAtmosphereHandler.onRequest(PushAtmosphereHandler.java:77)
	at org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:224)
	at org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:114)
	at org.atmosphere.container.Servlet30CometSupport.service(Servlet30CometSupport.java:67)
	at org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:2290)
	at org.atmosphere.websocket.DefaultWebSocketProcessor.dispatch(DefaultWebSocketProcessor.java:594)
	at org.atmosphere.websocket.DefaultWebSocketProcessor$3.run(DefaultWebSocketProcessor.java:345)
	at org.atmosphere.util.VoidExecutorService.execute(VoidExecutorService.java:101)
	at org.atmosphere.websocket.DefaultWebSocketProcessor.dispatch(DefaultWebSocketProcessor.java:340)
	at org.atmosphere.websocket.DefaultWebSocketProcessor.invokeWebSocketProtocol(DefaultWebSocketProcessor.java:448)
	at org.atmosphere.container.JSR356Endpoint$3.onMessage(JSR356Endpoint.java:272)
	at org.atmosphere.container.JSR356Endpoint$3.onMessage(JSR356Endpoint.java:269)
	at org.apache.tomcat.websocket.WsFrameBase.sendMessageText(WsFrameBase.java:369)
	at org.apache.tomcat.websocket.WsFrameBase.processDataText(WsFrameBase.java:468)
	at org.apache.tomcat.websocket.WsFrameBase.processData(WsFrameBase.java:272)
	at org.apache.tomcat.websocket.WsFrameBase.processInputBuffer(WsFrameBase.java:116)
	at org.apache.tomcat.websocket.server.WsFrameServer.onDataAvailable(WsFrameServer.java:54)
	at org.apache.tomcat.websocket.server.WsHttpUpgradeHandler$WsReadListener.onDataAvailable(WsHttpUpgradeHandler.java:192)
	at org.apache.coyote.http11.upgrade.AbstractServletInputStream.onDataAvailable(AbstractServletInputStream.java:178)
	at org.apache.coyote.http11.upgrade.AbstractProcessor.upgradeDispatch(AbstractProcessor.java:92)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:601)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at com.vaadin.util.ReflectTools.createInstance(ReflectTools.java:276)
	... 52 more
Caused by: com.vaadin.ui.declarative.DesignException: Unable to load component for design
	at com.vaadin.ui.declarative.Design$DefaultComponentFactory.resolveComponentClass(Design.java:205)
	at com.vaadin.ui.declarative.Design$DefaultComponentFactory.createComponent(Design.java:158)
	at com.vaadin.ui.declarative.Design$DefaultComponentFactory.createComponent(Design.java:167)
	at com.vaadin.ui.declarative.Design$DefaultComponentFactory.createComponent(Design.java:167)
	at com.vaadin.ui.declarative.Design$DefaultComponentFactory.createComponent(Design.java:167)
	at com.vaadin.ui.declarative.Design$DefaultComponentMapper.tagToComponent(Design.java:249)
	at com.vaadin.ui.declarative.DesignContext.instantiateComponent(DesignContext.java:569)
	at com.vaadin.ui.declarative.DesignContext.readDesign(DesignContext.java:505)
	at com.vaadin.ui.AbstractOrderedLayout.readDesign(AbstractOrderedLayout.java:471)
	at com.vaadin.ui.declarative.DesignContext.readDesign(DesignContext.java:526)
	at com.vaadin.ui.declarative.Design.designToComponentTree(Design.java:503)
	at com.vaadin.ui.declarative.Design.read(Design.java:613)
	at it.xxx.xxx.xxx.xxx.ElencoPreventiviDesign.<init>(ElencoPreventiviDesign.java:32)
	at it.xxx.xxx.xxx.xxx.ElencoPreventiviView.<init>(ElencoPreventiviView.java:43)
	... 57 more
Caused by: java.lang.ClassNotFoundException: com$vaadin$ui$Grid
	at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:348)
	at com.vaadin.ui.declarative.Design$DefaultComponentFactory.resolveComponentClass(Design.java:200)
	... 70 more

But the more strange thing is that if I package the project, and I deploy it on an external tomcat server, it works fine without problems.
I suppose it could be something related to the POM, but I can’t figure what.

These are the dependencies who involve Vaadin in my POM.

		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>javax.servlet-api</artifactId>
			<version>3.1.0</version>
			<scope>provided</scope>
		</dependency>
		
		<dependency>
			<groupId>com.vaadin</groupId>
			<artifactId>vaadin-compatibility-server</artifactId>
		</dependency>
		<dependency>
			<groupId>com.vaadin</groupId>
			<artifactId>vaadin-push</artifactId>
		</dependency>
		<dependency>
			<groupId>com.vaadin</groupId>
			<artifactId>vaadin-compatibility-client</artifactId>
			<exclusions> 
	            <exclusion>
	                <groupId>javax.servlet</groupId>
	                <artifactId>servlet-api</artifactId>
	            </exclusion>
	        </exclusions>
		</dependency>
		<dependency>
			<groupId>com.vaadin</groupId>
			<artifactId>vaadin-themes</artifactId>
		</dependency>
		<dependency>
			<groupId>com.vaadin</groupId>
			<artifactId>vaadin-compatibility-themes</artifactId>
		</dependency>
		

What the hell is wrong?!? :smiley:
Thanks

I had the same problem. It turns out that it had to do with nested/inner classes being selected as a type in a Grid. The Class selector inserts the class into the Type field like this: com.company.MyClass.InnerClass. But, it should be com.company.MyClass$InnerClass. But when you manually enter the correct class name into the designer, the generated design class is generated with the $, which is a compiler error. I had to manually edit the generated class to be correct. But, everytime I save the design file, the error is generated again. I found this issue https://github.com/vaadin/designer/issues/1005, which seems to capture the problem. Make sure to +1 it to increase the priority it is given.

Eric Wetmiller:
I had the same problem. It turns out that it had to do with nested/inner classes being selected as a type in a Grid. The Class selector inserts the class into the Type field like this: com.company.MyClass.InnerClass. But, it should be com.company.MyClass$InnerClass. But when you manually enter the correct class name into the designer, the generated design class is generated with the $, which is a compiler error. I had to manually edit the generated class to be correct. But, everytime I save the design file, the error is generated again. I found this issue https://github.com/vaadin/designer/issues/1005, which seems to capture the problem. Make sure to +1 it to increase the priority it is given.

Thanks for your answer, glad to know that I’m not totally brain freezed and this is a weird bug :smiley:
I’ve commented your post in github and added a +1, let’s hope it will be fixed soon!

In the meanwhile I’m running with jetty:run , with different problems… but that’s another story! :slight_smile:

Keep in touch for updates!