Re: Playing with readEntity(String.class)

2015-12-29 Thread Sergey Beryozkin

Hi

This is to do with a default CXF JSONProvider which is Jettison based.

Jettison, historically, escapes forward slashes, I don't know why, it 
was there when I started maintaining it.

What you can do is to configure CXF JSONProvider not to do it, set its
'escapeForwardSlashesAlways' to false.

Or use a Jackson provider instead (if you do - Make sure Jettison is on 
on the classpath)


HTH, Sergey



On 29/12/15 14:40, Vincenzo D'Amore wrote:

Hi All,

I don't understand why when I receive a json encoded string this is not
decoded automatically.
I wrote this code:

 Client client = ClientBuilder.newClient().register(JSONProvider.class);

 WebTarget target = client.target("http://example.org/rest/service1;);
 target = target.queryParam("method", "method1");

 Entity entity = Entity.entity(new
EndpointRequest(""),
MediaType.APPLICATION_JSON);
 Response response = builder.post(entity);

System.out.println( response.getStatus() );

if (response.getStatus() == 200) {

// The problem comes here

String basePath = response.readEntity(String.class);
System.out.println( basePath );
}

The request is successfully executed but basePath contains
"\/opt\/local\/application\/rest\/"  (backslash and double quotes included)

basePath should instead contain this:  /opt/local/application/rest/

It seems to me, the json deserialization hasn't be triggered when it should.

Thanks in advance for your help,
Vincenzo




--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/


Re: Log empty message (with HTTP status code only)

2015-12-29 Thread Sergey Maslov
Sergey, thank you.
But how could I log the fact of 202 response?

Segery Maslov

On Tue, Dec 29, 2015 at 11:55 PM, Sergey Beryozkin 
wrote:

> I think it might be because 202 is handled by a oneway processor and the
> outbound chain is not invoked though I might be wrong...
>
> Sergey
> On 29/12/15 11:17, Sergey Maslov wrote:
>
>> The issue is reproduced for with 202 - Accepted http status.
>>
>> On Tue, Dec 29, 2015 at 1:28 PM, Sergey Maslov 
>> wrote:
>>
>> Hi!
>>> I need to log imcoming requests with corresponsing responses.
>>> According
>>> I add custom LoggingFeature and implement LogEventSender interface.
>>> The messages log fine except messages with emtpty body and
>>> containing http status code only (these are the responses to the
>>> service).
>>> According the contract, these messages are needed to be sent.
>>> How could I log them?
>>>
>>> --
>>> *Sergey Maslov*
>>>
>>>
>>
>>
>>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>



-- 
*Sergey Maslov*


Re: Log empty message (with HTTP status code only)

2015-12-29 Thread Sergey Beryozkin
I think it might be because 202 is handled by a oneway processor and the 
outbound chain is not invoked though I might be wrong...


Sergey
On 29/12/15 11:17, Sergey Maslov wrote:

The issue is reproduced for with 202 - Accepted http status.

On Tue, Dec 29, 2015 at 1:28 PM, Sergey Maslov 
wrote:


Hi!
I need to log imcoming requests with corresponsing responses.
According
I add custom LoggingFeature and implement LogEventSender interface.
The messages log fine except messages with emtpty body and
containing http status code only (these are the responses to the service).
According the contract, these messages are needed to be sent.
How could I log them?

--
*Sergey Maslov*








--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/


Re: Log empty message (with HTTP status code only)

2015-12-29 Thread Sergey Beryozkin

I'm not sure right now, perhaps Aki or Dan may have an idea.
May be you can register a custom Log interceptor, after 
LoggingInInterceptor, that will check CXF message if it is one way 
(there has to be some property set in the message) and log only if it is 
oneway...


Cheers, Sergey
On 29/12/15 18:00, Sergey Maslov wrote:

Sergey, thank you.
But how could I log the fact of 202 response?

Segery Maslov

On Tue, Dec 29, 2015 at 11:55 PM, Sergey Beryozkin 
wrote:


I think it might be because 202 is handled by a oneway processor and the
outbound chain is not invoked though I might be wrong...

Sergey
On 29/12/15 11:17, Sergey Maslov wrote:


The issue is reproduced for with 202 - Accepted http status.

On Tue, Dec 29, 2015 at 1:28 PM, Sergey Maslov 
wrote:

Hi!

I need to log imcoming requests with corresponsing responses.
According
I add custom LoggingFeature and implement LogEventSender interface.
The messages log fine except messages with emtpty body and
containing http status code only (these are the responses to the
service).
According the contract, these messages are needed to be sent.
How could I log them?

--
*Sergey Maslov*








--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/








--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/


Re: Playing with readEntity(String.class)

2015-12-29 Thread Vincenzo D'Amore
Thanks Sergey,

but in the meanwhile I tried fruitless different options which include
escapeForwardSlashesAlways(false).
I have also tried to change entirely the implementation, but even Jersey
have the same behaviour.
This is pretty strange to me.

On Tue, Dec 29, 2015 at 7:10 PM, Sergey Beryozkin 
wrote:

> Hi
>
> This is to do with a default CXF JSONProvider which is Jettison based.
>
> Jettison, historically, escapes forward slashes, I don't know why, it was
> there when I started maintaining it.
> What you can do is to configure CXF JSONProvider not to do it, set its
> 'escapeForwardSlashesAlways' to false.
>
> Or use a Jackson provider instead (if you do - Make sure Jettison is on on
> the classpath)
>
> HTH, Sergey
>
>
>
>
> On 29/12/15 14:40, Vincenzo D'Amore wrote:
>
>> Hi All,
>>
>> I don't understand why when I receive a json encoded string this is not
>> decoded automatically.
>> I wrote this code:
>>
>>  Client client =
>> ClientBuilder.newClient().register(JSONProvider.class);
>>
>>  WebTarget target = client.target("http://example.org/rest/service1
>> ");
>>  target = target.queryParam("method", "method1");
>>
>>  Entity entity = Entity.entity(new
>> EndpointRequest(""),
>> MediaType.APPLICATION_JSON);
>>  Response response = builder.post(entity);
>>
>> System.out.println( response.getStatus() );
>>
>> if (response.getStatus() == 200) {
>>
>> // The problem comes here
>>
>> String basePath = response.readEntity(String.class);
>> System.out.println( basePath );
>> }
>>
>> The request is successfully executed but basePath contains
>> "\/opt\/local\/application\/rest\/"  (backslash and double quotes
>> included)
>>
>> basePath should instead contain this:  /opt/local/application/rest/
>>
>> It seems to me, the json deserialization hasn't be triggered when it
>> should.
>>
>> Thanks in advance for your help,
>> Vincenzo
>>
>>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>



-- 
Vincenzo D'Amore
email: v.dam...@gmail.com
skype: free.dev
mobile: +39 349 8513251


async problem ; Illegal State Exception

2015-12-29 Thread Benson Margulies
I switched some code of mine to use AsyncRequest, and I get some scary
backtraces even though everything seems to be working just fine.

Note the presence of
org.jolokia.osgi.security.BasicAuthenticationHttpContext.handleSecurity
in the backtrace. Now, I am running in Karaf with the jolokia feature
enabled, but until now I had no idea that jolokia was inserting itself
into the process. Can anyone suggest a way to learn anything about
what's happening here?



2015-12-29 14:32:14,328 | WARN  | tp1821513140-131 | HttpChannel
   | 150 - org.eclipse.jetty.util - 9.2.10.v20150310 |
/rest/worker/process
java.lang.IllegalStateException: Committed
at 
org.eclipse.jetty.server.Response.resetBuffer(Response.java:1253)[147:org.eclipse.jetty.server:9.2.10.v20150310]
at 
org.eclipse.jetty.server.Response.sendError(Response.java:567)[147:org.eclipse.jetty.server:9.2.10.v20150310]
at 
org.eclipse.jetty.server.Response.sendError(Response.java:544)[147:org.eclipse.jetty.server:9.2.10.v20150310]
at 
javax.servlet.http.HttpServletResponseWrapper.sendError(HttpServletResponseWrapper.java:167)[51:javax.servlet-api:3.1.0]
at 
org.jolokia.osgi.security.BasicAuthenticationHttpContext.handleSecurity(BasicAuthenticationHttpContext.java:49)[164:org.jolokia.osgi:1.3.0]
at 
org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:68)[191:org.ops4j.pax.web.pax-web-jetty:4.2.2]
at 
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)[147:org.eclipse.jetty.server:9.2.10.v20150310]
at 
org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)[146:org.eclipse.jetty.security:9.2.10.v20150310]
at 
org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)[147:org.eclipse.jetty.server:9.2.10.v20150310]
at 
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)[147:org.eclipse.jetty.server:9.2.10.v20150310]
at 
org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:271)[191:org.ops4j.pax.web.pax-web-jetty:4.2.2]
at 
org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)[148:org.eclipse.jetty.servlet:9.2.10.v20150310]
at 
org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)[147:org.eclipse.jetty.server:9.2.10.v20150310]
at 
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)[147:org.eclipse.jetty.server:9.2.10.v20150310]
at 
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)[147:org.eclipse.jetty.server:9.2.10.v20150310]
at 
org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:99)[191:org.ops4j.pax.web.pax-web-jetty:4.2.2]
at 
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)[147:org.eclipse.jetty.server:9.2.10.v20150310]
at 
org.eclipse.jetty.server.Server.handleAsync(Server.java:553)[147:org.eclipse.jetty.server:9.2.10.v20150310]
at 
org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317)[147:org.eclipse.jetty.server:9.2.10.v20150310]
at 
org.eclipse.jetty.server.HttpChannel.run(HttpChannel.java:261)[147:org.eclipse.jetty.server:9.2.10.v20150310]
at 
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)[150:org.eclipse.jetty.util:9.2.10.v20150310]
at 
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)[150:org.eclipse.jetty.util:9.2.10.v20150310]


Re: async problem ; Illegal State Exception

2015-12-29 Thread Benson Margulies
Removing jolokia made this disappear, so I don't think it belongs
here, however odd it is that it only appeared with the use of CXF
async.

On Tue, Dec 29, 2015 at 2:38 PM, Benson Margulies  wrote:
> I switched some code of mine to use AsyncRequest, and I get some scary
> backtraces even though everything seems to be working just fine.
>
> Note the presence of
> org.jolokia.osgi.security.BasicAuthenticationHttpContext.handleSecurity
> in the backtrace. Now, I am running in Karaf with the jolokia feature
> enabled, but until now I had no idea that jolokia was inserting itself
> into the process. Can anyone suggest a way to learn anything about
> what's happening here?
>
>
>
> 2015-12-29 14:32:14,328 | WARN  | tp1821513140-131 | HttpChannel
>| 150 - org.eclipse.jetty.util - 9.2.10.v20150310 |
> /rest/worker/process
> java.lang.IllegalStateException: Committed
> at 
> org.eclipse.jetty.server.Response.resetBuffer(Response.java:1253)[147:org.eclipse.jetty.server:9.2.10.v20150310]
> at 
> org.eclipse.jetty.server.Response.sendError(Response.java:567)[147:org.eclipse.jetty.server:9.2.10.v20150310]
> at 
> org.eclipse.jetty.server.Response.sendError(Response.java:544)[147:org.eclipse.jetty.server:9.2.10.v20150310]
> at 
> javax.servlet.http.HttpServletResponseWrapper.sendError(HttpServletResponseWrapper.java:167)[51:javax.servlet-api:3.1.0]
> at 
> org.jolokia.osgi.security.BasicAuthenticationHttpContext.handleSecurity(BasicAuthenticationHttpContext.java:49)[164:org.jolokia.osgi:1.3.0]
> at 
> org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:68)[191:org.ops4j.pax.web.pax-web-jetty:4.2.2]
> at 
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)[147:org.eclipse.jetty.server:9.2.10.v20150310]
> at 
> org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)[146:org.eclipse.jetty.security:9.2.10.v20150310]
> at 
> org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)[147:org.eclipse.jetty.server:9.2.10.v20150310]
> at 
> org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)[147:org.eclipse.jetty.server:9.2.10.v20150310]
> at 
> org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:271)[191:org.ops4j.pax.web.pax-web-jetty:4.2.2]
> at 
> org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)[148:org.eclipse.jetty.servlet:9.2.10.v20150310]
> at 
> org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)[147:org.eclipse.jetty.server:9.2.10.v20150310]
> at 
> org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)[147:org.eclipse.jetty.server:9.2.10.v20150310]
> at 
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)[147:org.eclipse.jetty.server:9.2.10.v20150310]
> at 
> org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:99)[191:org.ops4j.pax.web.pax-web-jetty:4.2.2]
> at 
> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)[147:org.eclipse.jetty.server:9.2.10.v20150310]
> at 
> org.eclipse.jetty.server.Server.handleAsync(Server.java:553)[147:org.eclipse.jetty.server:9.2.10.v20150310]
> at 
> org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317)[147:org.eclipse.jetty.server:9.2.10.v20150310]
> at 
> org.eclipse.jetty.server.HttpChannel.run(HttpChannel.java:261)[147:org.eclipse.jetty.server:9.2.10.v20150310]
> at 
> org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)[150:org.eclipse.jetty.util:9.2.10.v20150310]
> at 
> org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)[150:org.eclipse.jetty.util:9.2.10.v20150310]


Problem starting CXF API bundle in Eclipse Virgo

2015-12-29 Thread Setya
Hi all,

When deploying & starting CXF DOSGI bundles in Eclipse Virgo I notice the
following exception in the logs:

/[2015-12-29 13:31:09.326] ERROR Blueprint Extender: 3   
org.apache.aries.blueprint.container.BlueprintContainerImpl   Unable to
start blueprint container for bundle org.apa
che.cxf.cxf-api
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to
instantiate components
at
org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:672)
at
org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:370)
at
org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:261)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at
org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106)
at
org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by:
org.eclipse.virgo.kernel.osgi.framework.ExtendedNoClassDefFoundError:
org/apache/aries/blueprint/NamespaceHandler in KernelBundleClassLoader:
[bundle=org.apache.cxf.cxf-a
pi_2.7.8] in KernelBundleClassLoader: [bundle=org.apache.cxf.cxf-api_2.7.8]
at
org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader.loadClass(KernelBundleClassLoader.java:152)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at
org.eclipse.osgi.internal.loader.BundleLoader.loadClass(BundleLoader.java:340)
at
org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:229)
at
org.eclipse.osgi.framework.internal.core.AbstractBundle.loadClass(AbstractBundle.java:1212)
at
org.apache.aries.blueprint.container.BlueprintContainerImpl.loadClass(BlueprintContainerImpl.java:419)
at
org.apache.aries.blueprint.container.BlueprintRepository.loadClass(BlueprintRepository.java:410)
at
org.apache.aries.blueprint.container.GenericType.parse(GenericType.java:113)
at
org.apache.aries.blueprint.di.AbstractRecipe.doLoadType(AbstractRecipe.java:168)
at
org.apache.aries.blueprint.di.AbstractRecipe.loadType(AbstractRecipe.java:161)
at
org.apache.aries.blueprint.container.BeanRecipe.loadClass(BeanRecipe.java:249)
at
org.apache.aries.blueprint.container.BeanRecipe.getType(BeanRecipe.java:895)
at
org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:323)
at
org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:806)
at
org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)
at
org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at
org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)
at
org.apache.aries.blueprint.di.RefRecipe.internalCreate(RefRecipe.java:62)
at
org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:106)
at
org.apache.aries.blueprint.container.ServiceRecipe.createService(ServiceRecipe.java:282)
at
org.apache.aries.blueprint.container.ServiceRecipe.internalGetService(ServiceRecipe.java:249)
at
org.apache.aries.blueprint.container.ServiceRecipe.getService(ServiceRecipe.java:351)
at
org.apache.aries.blueprint.container.ServiceRecipe$TriggerServiceFactory.getService(ServiceRecipe.java:504)
at
org.eclipse.osgi.internal.serviceregistry.ServiceUse$1.run(ServiceUse.java:141)
at java.security.AccessController.doPrivileged(Native Method)
at
org.eclipse.osgi.internal.serviceregistry.ServiceUse.getService(ServiceUse.java:139)
at
org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:468)
at
org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.getService(ServiceRegistry.java:467)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.getService(BundleContextImpl.java:594)
at
org.eclipse.virgo.shell.internal.CommandRegistry.serviceRegistered(CommandRegistry.java:82)
  

Re: Log empty message (with HTTP status code only)

2015-12-29 Thread Sergey Maslov
The issue is reproduced for with 202 - Accepted http status.

On Tue, Dec 29, 2015 at 1:28 PM, Sergey Maslov 
wrote:

> Hi!
> I need to log imcoming requests with corresponsing responses.
> According
> I add custom LoggingFeature and implement LogEventSender interface.
> The messages log fine except messages with emtpty body and
> containing http status code only (these are the responses to the service).
> According the contract, these messages are needed to be sent.
> How could I log them?
>
> --
> *Sergey Maslov*
>



-- 
*Sergey Maslov*


Playing with readEntity(String.class)

2015-12-29 Thread Vincenzo D'Amore
Hi All,

I don't understand why when I receive a json encoded string this is not
decoded automatically.
I wrote this code:

Client client = ClientBuilder.newClient().register(JSONProvider.class);

WebTarget target = client.target("http://example.org/rest/service1;);
target = target.queryParam("method", "method1");

Entity entity = Entity.entity(new
EndpointRequest(""),
   MediaType.APPLICATION_JSON);
Response response = builder.post(entity);

   System.out.println( response.getStatus() );

   if (response.getStatus() == 200) {

// The problem comes here

   String basePath = response.readEntity(String.class);
   System.out.println( basePath );
   }

The request is successfully executed but basePath contains
"\/opt\/local\/application\/rest\/"  (backslash and double quotes included)

basePath should instead contain this:  /opt/local/application/rest/

It seems to me, the json deserialization hasn't be triggered when it should.

Thanks in advance for your help,
Vincenzo