keycloak admin client on JBOSS AS 7 - jboss

I am not able to call keycloak-admin-client from JBOSS AS 7.1 REST endpoint. I am able to call the same service from JUNIT test, but when I try to do the same thing from REST endpoint I am having the error:
Caused by:com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "access_token" (class org.keycloak.representations.AccessTokenResponse), not marked as ignorable
I am having the same error in JUNIT test when I change the dependency from jackson2 -> jackson
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson2-provider</artifactId>
<version>3.0.7.Final</version>
</dependency>
I guess its somehow connected with Jackson provider, but I tried everything from excluding jackson in deployemnt structure to using different, older version of keycloak admin client and keycloak-adapter-bom (2.5.5 or 3.4.3).
<module name="org.jboss.resteasy.resteasy-jackson-provider"/>
Can anybody provide working pom.xml for keycloak-admin-client for JBOSS AS 7.1 ?
Many thanks

Thank you #ravthiru for your response.
The problem was more prozaic and simple. I have put the rest endpoint inside the war module, which is secured by keycloak adapter and that prevents the calls to any REST endpoint from outside. I have create separate war module for all REST endpoints associated with Keycloak and it works like charm. Before I called the keycloak admin client just via Unit tests, which means inside from war module and therefore I havent encountered the problem. But it cost me few days to realized where is the problem, cause I was sure it was because of jackson2.
My shame. Cheers.

Related

JBoss EAP 5.1 - JBossGenericPrincipal

Right now I inherited legacy application to support and I found a very strange thing. The application is Vaadin based app and it is hosted on JBoss EAP 5.1. On JBoss there is configured login-config module - org.jboss.security.auth.spi.LdapExtLoginModule. This module works fine and does its job. What would I like to do is how to get access to JBossGenericProncipal which is created by this login module? When I debug app and check session (StandardSessionFacade) I can see that it has a field principal but it is private and there is no way to access this principal.
Do you know how to retrieve this Principal? :)
Thanks in advance!
Kamil
If you are referring to the class org.jboss.web.tomcat.security.JBossGenericPrincipal
you can call the method getCallerPrincipal() that returns a java.security.Principal
Here's a reference from docjar: http://www.docjar.com/docs/api/org/jboss/web/tomcat/security/JBossGenericPrincipal.html.
There's also a org.jboss.as.web.security.JBossGenericPrincipal class, but is not available on JBoss EAP 5.
You can also retrieve the java.security.Principal calling the method getUserPrincipal() from HttpServletRequest

Wildfly swarm jax-rs multipart form NotSupportedException

I have a fairly simple jax-rs application running on wildfly 9. It makes use of resteasy multipart form. It runs 100%. Now I am trying to run the same application with wildfly swarm, but get a
javax.ws.rs.NotSupportedException: Could not find message body reader for type .... multipart/form-data on execute of the resource post operation.
This as far as I understand is the resteasy-multipart-provider. In my pom I have the wildfly-swarm-weld-jaxrs fraction. Is this not suppose to take care of the multipart features? If not how do I get it included in the swarm fat jar/package? I have tried including the resteasy-multipart-provider as a compile dependency, but this breaks the swarm application and it refuses to start/boot. Or have I missed something else?
JAX-RS Multipart support is declared as an optional module in WildFly, so the necessary classes to make it work were not included in the application.
Since then Ken Finnigan added a new WildFly Swarm API for the module.
If you build the latest from wildfly-swarm/wildfly-swarm on GitHub you can add the wildfly-swarm-jaxrs-multipart artifact as a dependency to the project and that should resolve the problem.

SOAP Web Service Client conflcts with xfire

I generated wsdl using wsimport from JDK 1.6. I then wrote a client to invoke the web service I got the following error.
java.lang.IllegalStateException: Could not initialize Service.
at org.codehaus.xfire.jaxws.ServiceDelegate.<init>(ServiceDelegate.java:77)
at org.codehaus.xfire.jaxws.Provider.createServiceDelegate(Provider.java:32)
at javax.xml.ws.Service.<init>(Service.java:56)
Then I removed xfire-all 1.2.6 jar used in my
application and found it working but only if the class was invoked from command line and not from application functionality which is the real need as removing xfire jar is not an option for me..Please help I read numberyyy of posts but did not get any fruitful solution yet.
Thanks in advance

How does using the javax.ws.rs-api-2.0.jar works at runtime as it is only the API

We were working on creating a RESTful service. We have thought of using frameworks like jersey or cxf. But apparently we found that just using the javax.ws.rs-api-2.0.jar and the related annotations, we can get the service working.
Question is:
How does it work? Is it dependent on the application servers?
What if we application server does not support or have the implementation of the API?
If it is dependent on application servers, can I find out the library which the server is using especially tomcat?
EDIT 1
This question is invalid. javax.ws.rs-api-2.0.jar is just an API. Using this jar does not suffice. It will not give compilation errors.
But at run-time, you need providers which will implement the rs-api. And thus we need the frameworks like jersey or cxf.
In our application, these jars were added to the war during ant-build from external location and that is why it confused us.
I am closing this question.

JAXWS style Web Service client jar not working inside a webapp

I have created a web service client project with the netbeans 6.9.1. The jar works like a charm when I run it directly from netbeans or from the console with java -jar. But when I put this jar into a webapplication as a library, It doesn't work. Actually, here is the weird thing about it, I have monitored the network traffic and saw that the responses on both sides are the same, but somehow when the jar is inside a webapp or working from an application server it doesn't manages to parse the response I think.
Long story in short,
The web service client code generated inside netbeans jaxws style(2.1) works by itself, But when it's called inside a web application within an application server , the response methods such as getsomething which resides in the response as sdfds doesn't work, but they work when runned separately. And the responses are exactly the same when I monitor the network traffics.
Can anyone help about this weird situation.
Thanks.
Edit: Also I discovered an exception:
com.sun.xml.internal.messaging.saaj.soap.impl.TextImpl cannot be cast to javax.xml.soap.SOAPElement
Which is not thrown anywhere in my local, bu only running at application servers. Tomcat or weblogic , both.
I encountered the exact sample problem in my SOAPHandler class. It turned out that the white space in the SOAP body is what cause this problem. Below are my SOAP request example from SOAPUI:
username
password
1
usa
75044
vn
usa
75034
SOAP request without white space in SOAP body:
username
password
1usa75044vnusa75034