Unable to login in restapi - login failed for admin

I have enabled rest api add on and generated front module in studio. However on running the project i am unable to login as admin due to login failed.

  • Do I have to define any app properties.
  • security scope lookup don’t show rest api. How to add this.
  • security scope in role edit shows blank entries and clicking them gives error.

user2

Please guide.

thanks

umesh

PS: I have migrated this project from 7.1 and regenerated database to enable new security system and defined cuba.security.rolesPolicyVersion =2.

Could you give us a sequence of steps to reproduce the problem? E.g. create a new project on 7.1, migrate it to 7.2, add REST API module, etc.
Also please provide a full stack trace of the error you get.

Steps;

  1. Migrate from 7.1 to 7.2
  2. Create database again. (How can I enforce new security in migrated project without creating database again?)
  3. Add front module
  4. run project and add new role (blank entries in lookup, if new project in 7.2 then REST scope will be there)
  5. click blank entry, the error will be shown.

My another question was what i have to do to log in into front module. It don’t allow even admin to log in and says wrong credential. Do I have to other setting. Even i defined a new role with scope REST and allows everything for admin but login failure.

regards

Umesh

The error is-
java.lang.ClassCastException: com.haulmont.cuba.security.entity.RoleType$3 cannot be cast to java.lang.String
at com.haulmont.chile.core.model.utils.MethodsCache$SettersHolder.accept(MethodsCache.java:193)
at com.haulmont.chile.core.model.impl.AbstractInstance.setValue(AbstractInstance.java:160)
at com.haulmont.cuba.core.entity.BaseGenericIdEntity.setValue(BaseGenericIdEntity.java:126)
at com.haulmont.chile.core.model.impl.AbstractInstance.setValue(AbstractInstance.java:142)
at com.haulmont.chile.core.model.utils.InstanceUtils.setValueEx(InstanceUtils.java:190)
at com.haulmont.chile.core.model.impl.AbstractInstance.setValueEx(AbstractInstance.java:182)
at com.haulmont.cuba.gui.components.data.value.DatasourceValueSource.setValue(DatasourceValueSource.java:136)
at com.haulmont.cuba.gui.components.data.value.ValueBinder$ValueBindingImpl.setValueToSource(ValueBinder.java:307)
at com.haulmont.cuba.gui.components.data.value.ValueBinder$ValueBindingImpl.componentValueChanged(ValueBinder.java:300)
at com.haulmont.bali.events.EventHub.publish(EventHub.java:170)
at com.haulmont.cuba.web.gui.components.WebAbstractComponent.publish(WebAbstractComponent.java:100)
at com.haulmont.cuba.web.gui.components.WebAbstractValueComponent.componentValueChanged(WebAbstractValueComponent.java:152)
at com.haulmont.cuba.web.gui.components.WebV8AbstractField.lambda$attachValueChangeListener$ab1c93c8$1(WebV8AbstractField.java:144)
at com.vaadin.ui.ComboBox.lambda$addValueChangeListener$bddd7469$1(ComboBox.java:825)
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:496)
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:1041)
at com.vaadin.ui.AbstractSingleSelect.setSelectedItem(AbstractSingleSelect.java:358)
at com.vaadin.ui.AbstractSingleSelect$1.select(AbstractSingleSelect.java:291)
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:153)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:115)
at com.vaadin.server.communication.ServerRpcHandler.handleInvocation(ServerRpcHandler.java:431)
at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:396)
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:1578)
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:108)
at org.springframework.web.filter.CompositeFilter.doFilter(CompositeFilter.java:74)
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:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526)
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:861)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1579)
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)

Unfortunately, I cannot reproduce your error. Probably, I’m missing something. Could you please reproduce it on an empty project, archive the project (gradlew zipProject) and attach it here?

I am getting following error on running gradlew zipProject.

FAILURE: Build failed with an exception.

  • What went wrong:
    Task ‘gradlew’ not found in root project ‘abc’.

  • Try:
    Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use ‘–warning-mode all’ to show the individual deprecation warnings.
See Command-Line Interface

BUILD FAILED in 163ms
6:31:54 PM: Tasks execution finished ‘gradlew zipProject’.

zipProject is a name of the gradle task. How do you invoke it? It looks like when you invoke it you type gradlew twice

I tried everything (all combination) from ‘execute gradle taks’ button but it seems this is working gradle zipProject. (no w)

Attaching it. Check whether this is right.

This is test project made as detailed in first post today.

abc.zip (2.1 MB)

regards

Umesh

Please advice how to login in front module. It shows login failure for admin.

I have made one role with rest scope and added to admin user. (completely new project in 7.2)

Do I have to make any other changes or define properties.

regards

Umesh

Login to restapi issue is solved by giving specific permission to restapi in roles.

Okay. As for empty records in the Security scope lookup, I see that your project has a beta of multitenancy add-on included. This beta is the reason of an empty list and the ClassCastsException

Yes multitenancy addon is causing the problem. If I remove it, everything is fine.

Hello @umeshhodwala

See my answer in your new topic: Bug continues from multitenancy add on from beta to 2.0 - #4 - CUBA.Platform

Regards,
Nikita