Problems using java client against karaf/hawtio hosted Jolokia

classic Classic list List threaded Threaded
6 messages Options
Stefan Larsen Stefan Larsen
Reply | Threaded
Open this post in threaded view
|

Problems using java client against karaf/hawtio hosted Jolokia

Hi
I have modified the JolokiaDemo java class slightly to make it use the correct url and username/password, but I keep getting "org.jolokia.client.exception.J4pRemoteException: Forbidden"

The only modification I have made is how the J4pClient is created:
        J4pClient j4pClient = J4pClient.url("http://localhost:8181/hawtio/jolokia").user("karaf").password("karaf").build();

I can connect using curl without problems:
curl -su karaf:karaf http://localhost:8181/hawtio/jolokia/read/java.lang:type=Memory/HeapMemoryUsage
{"timestamp":1400769276,"status":200,"request":{"mbean":"java.lang:type=Memory","attribute":"HeapMemoryUsage","type":"read"},"value":{"max":518979584,"committed":133644288,"init":134217728,"used":56233064}}

I am trying to reach a Jolokia in Hawt.io 1.4.0 running in Apache Karaf 3

Any help appreciated ;-)

Cheers,
Stefan
roland roland
Reply | Threaded
Open this post in threaded view
|

Re: Problems using java client against karaf/hawtio hosted Jolokia

I will have a look at it tomorrow.

Stay tuned ...
... roland
... roland
Stefan Larsen Stefan Larsen
Reply | Threaded
Open this post in threaded view
|

Re: Problems using java client against karaf/hawtio hosted Jolokia

Thanks roland!

/Stefan
roland roland
Reply | Threaded
Open this post in threaded view
|

Re: Problems using java client against karaf/hawtio hosted Jolokia

The problem is, that hawat.io used as karaf feature doesn't do plain Basic Authentication, but has more complex initial handshake.

I opened an issue: https://github.com/rhuss/jolokia/issues/141 The implementation for this is already finished, in the meantime you could create an HttpClient on your own and send an empty POST request to /hawtio/auth/login with the Header 'Authorization' set properly as for BasicAuthentication. Then you receive a session Cookie which needs to be used for the Jolokia Request.

I'll come back as soon as the implementation is finished. This will go into 1.2.2
... roland
Stefan Larsen Stefan Larsen
Reply | Threaded
Open this post in threaded view
|

Re: Problems using java client against karaf/hawtio hosted Jolokia

Great!

I will try your tip and keep try 1.2.2 when it comes.
Thanks for helping on this :-)

Cheers,
Stefan
roland roland
Reply | Threaded
Open this post in threaded view
|

Re: Problems using java client against karaf/hawtio hosted Jolokia

FYI, I just posted a possible (though untested) workaround over there at the Github issue.
... roland