Metaclass not found

Hi,

I came across this strange error. I think I had a similar one a couple months back, and got solved by clearing and redeploying. However this one is more perseverant.

Here the stacktrace to hint out a possible solution. A remarkable feature of my project is that I update sources from a git repo, to enable code migration in a dev and a uat machine. Recently I added the REST API Plugin in the dev machine, committed changes and updated in the UAT machine. Can that be an issue?

The error appears so far only upon opening one editor screen in the application, among roughly 70 or 80 pages. So it seems to be something very particular and elusive.

Any hints are greatly appreciated.

Regards and happy new year.

Carlos.

Blockquote
java.lang.IllegalArgumentException: MetaClass not found for test1_ReciboIndividualizado
at com.haulmont.cuba.core.sys.CachingMetadataSession.getClassNN(CachingMetadataSession.java:67)
at com.haulmont.cuba.core.sys.MetadataImpl.create(MetadataImpl.java:294)
at com.haulmont.cuba.gui.config.MenuItemCommands$ScreenCommand.getEntityToEdit(MenuItemCommands.java:365)
at com.haulmont.cuba.gui.config.MenuItemCommands$ScreenCommand.run(MenuItemCommands.java:318)
at com.haulmont.cuba.web.sys.MenuBuilder$MenuCommandExecutor.accept(MenuBuilder.java:256)
at com.haulmont.cuba.web.sys.MenuBuilder$MenuCommandExecutor.accept(MenuBuilder.java:241)
at com.haulmont.cuba.web.gui.components.mainwindow.WebAppMenu$MenuItemImpl.menuSelected(WebAppMenu.java:435)
at com.vaadin.ui.MenuBar.changeVariables(MenuBar.java:225)
at com.vaadin.server.communication.ServerRpcHandler.changeVariables(ServerRpcHandler.java:611)
at com.vaadin.server.communication.ServerRpcHandler.handleInvocation(ServerRpcHandler.java:457)
at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:400)
at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:260)
at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:82)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1577)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:425)
at com.haulmont.cuba.web.sys.CubaApplicationServlet.serviceAppRequest(CubaApplicationServlet.java:329)
at com.haulmont.cuba.web.sys.CubaApplicationServlet.service(CubaApplicationServlet.java:215)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:107)
at org.springframework.web.filter.CompositeFilter.doFilter(CompositeFilter.java:73)
at com.haulmont.cuba.web.sys.CubaHttpFilter.doFilter(CubaHttpFilter.java:93)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:836)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1747)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)

Blockquote

I have discovered that the issue has its root cause at:

MenuItemCommands.java line 358

The error occurs because I launch an editor FROM THE MENUBAR (not from a browse table) which is not the main entity editor. Say we have entity A, so I would have the standard A.edit. But this editor is an extension of the main one because the entity A is constructed in a very different manner in this extended editor, named let’s say A2.edit.

I have been able to use it for a long time and all of a sudden it stopped working.

The error in that line occurs, because when the getEntityToEdit() method in the mentioned class is called, if there’s no entity passed as parameter, it solely checks the screenId and splits the string to extract the metaClassName, hence not being found since the screenId is A2.edit, and A2 doesn’t correspond to any metaClassName.

Can I workaround that? How can I set the entity instance being edited in the ScreenCommand parameter or anywhere else to avoid the piece of code that concludes that the metaClassName derives from the screenId.

I see it as an important design mistake, then you must be able to approach the edition of an entity in many different ways.

Regards,

Carlos.

Finally solved it by creating a web bean and launching the screen via screenBuilders according to the solution proposed in this link

Thanks and hope this might help someone.

Regards,

Carlos.

1 Like