On 2017-10-29 04:06 Anh Nguyen Tuan wrote:
Hi Francesco,

I think this is because in rest method "update" you don't have
@PathParam for {key}

org.apache.syncope.common.rest.api.service.AnyService (UserService
extends AnyService)
    @PATCH
    @Path("{key}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
    Response update(@NotNull P anyPatch);

Look at same issue at:
http://mail-archives.apache.org/mod_mbox/cxf-dev/201207.mbox/%3CCABcEujvLKN1eHwtAWLHaib=NW+FZyDqZs4f1_=ktbfhvkmk...@mail.gmail.com%3E

read method has PathParam defined so it works in my snippet.
    @GET
    @Path("{key}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
    TO read(@NotNull @PathParam("key") String key);

...and how would it work for everyone else here (including the Admin Console and the Enduser UI, which are "pure" REST clients to the Core), if that was the case? :-)

The actual point is that @PathParam is properly defined in the payload bean AnyPatch:

https://github.com/apache/syncope/blob/2_0_X/common/lib/src/main/java/org/apache/syncope/common/lib/patch/AnyPatch.java#L53

You can read more about this CXF feature at

https://cxf.apache.org/docs/jax-rs-basics.html#JAX-RSBasics-DealingwithParameters

As said below, I suspect that there is something that, with Karaf, somehow "blocks" such a CXF feature, resulting in the error you are getting.

Maybe Sergey can shed some light?

Regards.

On 10/23/2017 1:34 PM, Francesco Chicchiriccò wrote:
Hi,
from the snippet and stacktrace below, I have some observations:

1. why Syncope 2.0.1? it's one year old - FYI 2.0.6 was recently released, take a look at [1] to see how many issues were fixed ever since 2. Syncope on Karaf? It sounds interesting, though I am sorry I've zero experience with OSGi in general and Syncope on Karaf in particular
3. I also see Shiro involved: not sure how it comes into play
4. the User creator is set once for all by a JPA listener, and cannot be normally altered via REST 5. the actual error, e.g. "java.lang.IllegalArgumentException: Unresolved variables; only 0 value(s) given for 1 unique variable(s)" seems CXF-related, possibly to the fact that the update method you are invoking [2] requires an explicit path parameter {key} which is not resolved at it should, e.g. by the value from the passed UserTO instance - but I'd suppose this is Karaf-specific

Regards.

[1] https://cwiki.apache.org/confluence/display/SYNCOPE/Jazz
[2] https://github.com/apache/syncope/blob/syncope-2.0.1/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/AnyService.java#L149

On 23/10/2017 04:52, Anh Nguyen Tuan wrote:
Hi team,

I'm using Syncope 2.0.1 and Syncope client API 2.0.1 deployed in OSGI environment (Karaf 4.0.4). When I read a user and update it as following: UserService userService = m_syncopeServiceFactory.getUserService(); UserTO user = m_syncopeServiceFactory.getUserService().read(username);
        user.setCreator("test");
        userService.update(user);

I'm getting this error:
2017-10-22 15:52:31,197 | WARN | tp304587724-1277 | AbstractAuthenticator | 342 - org.apache.shiro.core - 1.3.2 | Authentication failed for token submission [org.apache.shiro.authc.UsernamePasswordToken - adminuser, rememberMe=false (192.168.92.41)]. Possible unexpected error? (Typical or expected login exceptions should extend from AuthenticationException).
java.lang.reflect.UndeclaredThrowableException
at com.sun.proxy.$Proxy96.update(Unknown Source)[420:security-app:1.0.0.SNAPSHOT] at com.nokia.anv.app.security.SyncopeUserRealm.doGetAuthenticationInfo(SyncopeUserRealm.java:69)[420:security-app:1.0.0.SNAPSHOT] at org.apache.shiro.realm.AuthenticatingRealm.getAuthenticationInfo(AuthenticatingRealm.java:568)[342:org.apache.shiro.core:1.3.2] at org.apache.shiro.authc.pam.ModularRealmAuthenticator.doSingleRealmAuthentication(ModularRealmAuthenticator.java:180)[342:org.apache.shiro.core:1.3.2] at org.apache.shiro.authc.pam.ModularRealmAuthenticator.doAuthenticate(ModularRealmAuthenticator.java:267)[342:org.apache.shiro.core:1.3.2] at org.apache.shiro.authc.AbstractAuthenticator.authenticate(AbstractAuthenticator.java:198)[342:org.apache.shiro.core:1.3.2] at org.apache.shiro.mgt.AuthenticatingSecurityManager.authenticate(AuthenticatingSecurityManager.java:106)[342:org.apache.shiro.core:1.3.2] at org.apache.shiro.mgt.DefaultSecurityManager.login(DefaultSecurityManager.java:270)[342:org.apache.shiro.core:1.3.2] at org.apache.shiro.subject.support.DelegatingSubject.login(DelegatingSubject.java:256)[342:org.apache.shiro.core:1.3.2] at org.apache.shiro.web.filter.authc.AuthenticatingFilter.executeLogin(AuthenticatingFilter.java:53)[344:org.apache.shiro.web:1.3.2] at org.apache.shiro.web.filter.authc.FormAuthenticationFilter.onAccessDenied(FormAuthenticationFilter.java:154)[344:org.apache.shiro.web:1.3.2] at org.apache.shiro.web.filter.AccessControlFilter.onAccessDenied(AccessControlFilter.java:133)[344:org.apache.shiro.web:1.3.2] at org.apache.shiro.web.filter.AccessControlFilter.onPreHandle(AccessControlFilter.java:162)[344:org.apache.shiro.web:1.3.2] at org.apache.shiro.web.filter.PathMatchingFilter.isFilterChainContinued(PathMatchingFilter.java:203)[344:org.apache.shiro.web:1.3.2] at org.apache.shiro.web.filter.PathMatchingFilter.preHandle(PathMatchingFilter.java:178)[344:org.apache.shiro.web:1.3.2] at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:131)[344:org.apache.shiro.web:1.3.2] at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)[344:org.apache.shiro.web:1.3.2] at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)[344:org.apache.shiro.web:1.3.2] at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)[344:org.apache.shiro.web:1.3.2] at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)[344:org.apache.shiro.web:1.3.2] at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)[342:org.apache.shiro.core:1.3.2] at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)[342:org.apache.shiro.core:1.3.2] at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)[342:org.apache.shiro.core:1.3.2] at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)[344:org.apache.shiro.web:1.3.2] at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)[344:org.apache.shiro.web:1.3.2] at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)[78:org.eclipse.jetty.servlet:9.2.14.v20151106] at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)[78:org.eclipse.jetty.servlet:9.2.14.v20151106] at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:70)[108:org.ops4j.pax.web.pax-web-jetty:4.2.4] at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)[77:org.eclipse.jetty.server:9.2.14.v20151106] at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)[76:org.eclipse.jetty.security:9.2.14.v20151106] at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)[77:org.eclipse.jetty.server:9.2.14.v20151106] at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)[77:org.eclipse.jetty.server:9.2.14.v20151106] at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:271)[108:org.ops4j.pax.web.pax-web-jetty:4.2.4] at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)[78:org.eclipse.jetty.servlet:9.2.14.v20151106] at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)[77:org.eclipse.jetty.server:9.2.14.v20151106] at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)[77:org.eclipse.jetty.server:9.2.14.v20151106] at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)[77:org.eclipse.jetty.server:9.2.14.v20151106] at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80)[108:org.ops4j.pax.web.pax-web-jetty:4.2.4] at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)[77:org.eclipse.jetty.server:9.2.14.v20151106] at org.eclipse.jetty.server.Server.handle(Server.java:499)[77:org.eclipse.jetty.server:9.2.14.v20151106] at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)[77:org.eclipse.jetty.server:9.2.14.v20151106] at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)[77:org.eclipse.jetty.server:9.2.14.v20151106] at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)[69:org.eclipse.jetty.io:9.2.14.v20151106] at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)[80:org.eclipse.jetty.util:9.2.14.v20151106] at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)[80:org.eclipse.jetty.util:9.2.14.v20151106]
    at java.lang.Thread.run(Thread.java:745)[:1.8.0_40]
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.8.0_40] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)[:1.8.0_40] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_40]
    at java.lang.reflect.Method.invoke(Method.java:497)[:1.8.0_40]
at com.nokia.anv.app.security.SyncopeServiceInvocationHandler.invoke(SyncopeServiceInvocationHandler.java:21)[420:security-app:1.0.0.SNAPSHOT]
    ... 46 more
Caused by: java.lang.IllegalArgumentException: Unresolved variables; only 0 value(s) given for 1 unique variable(s) at org.apache.cxf.jaxrs.impl.UriBuilderImpl.substituteVarargs(UriBuilderImpl.java:285) at org.apache.cxf.jaxrs.impl.UriBuilderImpl.doBuildUriParts(UriBuilderImpl.java:121) at org.apache.cxf.jaxrs.impl.UriBuilderImpl.doBuild(UriBuilderImpl.java:101) at org.apache.cxf.jaxrs.impl.UriBuilderImpl.buildFromEncoded(UriBuilderImpl.java:230) at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:180)
    at com.sun.proxy.$Proxy86.update(Unknown Source)
    ... 51 more

I seem to be some issue when passing key to CXF, can you please have a look?

Regards,
Anh

--
Francesco Chicchiriccò

Tirasa - Open Source Excellence
http://www.tirasa.net/

Member at The Apache Software Foundation
Syncope, Cocoon, Olingo, CXF, OpenJPA, PonyMail
http://home.apache.org/~ilgrosso/

Reply via email to