Apache CXF 2.7.1 ResponseReader - web-services

I'm working through a tutorial that uses Apache CXF 2.6.2 to create a RESTful web service. I installed version 2.7.1 (the latest at the time), because the tutorial indicated that any version 2.6.2 or later would work, and I figured why not use the latest. I am creating the client, and the tutorial directs me to use org.apache.cxf.jaxrs.client.ResponseReader. The problem is that Eclipse tells me "ResponseReader cannot be resolved to a type" and trying to import the class also gives an error. I searched the internet some, and it sounds like ResponseReader is no longer available in CXF 2.7.x. My question is, what is the alternative to ResponseReader in 2.7.x to represent the return value of a REST invocation as XML?

Quoting this web page:
JAX-RS: 3 classes have been removed from the org.apache.cxf.jaxrs.client package: ResponseReader... The first class in the list is not needed with JAX-RS 2.0 Response class...
So, I guess that answers my question. There is no replacement per se, it's just not needed anymore.

Related

Can Apache cxf 2.7.10 be integrated with Swagger?

I have developed Restful web service using Apache CXF 2.7.10. I am trying to integrate same with Swagger (and Swagger UI). I couldn't look up an example over the internet for the same. All the examples point to recent versions of Apache CXF.
Is the integration with Apache CXF 2.7.10 version possible? If so, can anyone please point to the steps or a working example for the same?
Note: My application is regular maven based project.
Thanks!
Why not upgrading to CXF 3? Everything is implemented there and easy to use: http://cxf.apache.org/docs/swagger2feature.html
Should be possible to backport the stuff to 2.7.x. You would need to add swagger-jaxrs dependency and customize the ApiListingResource (https://github.com/swagger-api/swagger-core/wiki/swagger-core-jax-rs-project-setup-1.5.x). I guess upgrading to CXF 3 would be much easier...

WSO2 IS 5.2.0 : CXF based JAX-RS Client in a custom PIP not working

I am trying to implement a PIP extension for WSO2 Identity Server 5.2.0, which uses a CXF baseed JAX-RS client. Unfortunately I am still getting ClassNotFound Exception, e.g.:
Caused by: java.lang.ClassNotFoundException: org.apache.cxf.jaxrs.client.WebClient cannot be found by com.example.wso2.pip_1.0.0_1.0.0
In my understanding the CXF runtime einvironment is loaded through the definition in "webapp-classloading.xml". Am I missing s.th.?
Although it is for sure not the best solution, I ended up putting the CXF dependecies into the PIP bundle itself.
My hope was that this is not necessary. My code runs now, but appreciate if someone is able to point me to the preferred solution without having the CXF jars in the bundle.

python-social-auth failure on Google App Engine

I am attempting to follow Tutorial: Adding Facebook/Twitter/Google Authentication to a Django Application. The only thing I am doing differently is that I am running DjangoAppEngine on the Google App Engine development server, otherwise everything is exactly as per the tutorial.
When I get to Step 4 and actually try to authenticate with Facebook, I am getting a runtime error:
error('illegal IP address string passed to inet_pton',)
Request Method: GET
Request URL: http://localtest.com:8080/o/complete/facebook/?redirect_state=FG4K...UG1k
Django Version: 1.6.11
Exception Type: RuntimeError
Exception Location: /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py in _MakeRealSyncCall, line 235
Python Executable: /usr/local/opt/python/bin/python2.7
Python Version: 2.7.11
Obviously FB is passing an approval back to my app, as the request URL includes the callback path.
It appears that something in the GoogleAppEngineLauncher is trying to look up an address and is not receiving the right data in? I'm not really sure.
In trying to resolve this, I've come across a single comment somewhere suggesting to a user that SimpleAuth might be a better way to go, but I don't understand why and I'm not really sure I want to start over if I am just missing something obvious.
Does anyone know why I am getting this error and what I can do to correct it?
It happens because the Facebook SDK depends on the awesome requests library. However, requests doesn't work on Google App Engine since the platform has some restrictions. You have to use their urlfetch APIs to fetch external contents on Google App Engine.
So yes, the official Facebook SDK won't work. You have to roll your own solution or find one that works. SimpleAuth is one of the solution that is known to have worked.
UPDATE: the original answer (starting with 'HOWEVER') is no longer necessary, just use requests 2.10.0 or above, urllib3 1.15.1 or above, and requests_toolbelt 0.6.2 or above and perform the following in your main():
from requests_toolbelt.adapters import appengine
appengine.monkeypatch()
HOWEVER if you're using older versions of requests and/or urllib3, then you need the patches below:
This can be accomplished using a patched version of requests along with the requests-toolbelt package. Threads that apply:
HTTPS not working on Google App Engine #1905
urllib3 / Contrib Modules / Google App Engine
Fixes the AppEngineManager to work within the requests framework #763
Add AppEngineAdapter for GAE users #114
Adds a monkeypatch() function that ensures all Sessions use the AppEngineAdapter compatibility class. #119
I've applied all of this and now have python-social-auth and facebook-sdk working in both local test (the dev server) and production (full App Engine).
In your vendored libraries, ensure that you have requests_toolbelt. (pip install -t lib requests_toolbelt). Then "monkeypatch" appengine support before python-social-auth ever calls requests. In my project/wsgi.py, I added the following lines:
from requests_toolbelt.adapters import appengine
appengine.monkeypatch()
python-social-auth depends on requests, so it should also exist in your vendor directory.
You must also ensure you are using requests version >= 2.10.0. This has not been released yet, so you can fake it. Edit lib/requests/__init__.py so that __build__ = 0x021000. You also must upgrade the packaged version of urllib3 in the lib/requests/packages/ directory to the latest version.
This is what worked for me.

Intuit Quickbooks OAuth version 1.0 or 2.0?

I am using Django for my website/app and I want to integrate quickbooks. I wasn't sure whether you are using Oauth version 1.0 or 2.0. Also the documentation is more specific for PHP but the django-oauth-toolkit documentation I THINK is more geared towards hosting your own Oauth than connecting as a client. So although my main question is what version are you using any links to where I could read up on connecting with django would be greatly appreciated. I do have PHP still setup but I have been converting all my modules to django (python) and I was trying to avoid that. I thought reading the IETF protocol might help my understanding but there is the older version 1.0 by the original author and then the newer 2.0 that is currently supported. He does seem to have a pretty good beginner's guide but at the same time he seems a little 'disgruntled', if that's the right word, about the newer version. Also I believe the django-oauth-toolkit is version 2.0 protocol.
It's OAuth v1.0.
They have a bit of documentation here:
https://developer.intuit.com/docs/0100_quickbooks_online/0100_essentials/0085_develop_quickbooks_apps/0004_authentication_and_authorization
I would highly recommend you find an existing OAuth library for Django/Python - writing your own is likely going to be a painful process.

TomEE lookup errors

I've a WebApp that uses tomcat and openejb in separate installations. I'm trying to move this to a TomEE (web profile / plus) environment and I'm running into lookup errors. JNDIContext is throwing a java.lang.NullPointerException.
I tried w/ TomEE web profile first. My webapp also uses web services and google search lead me to try TomEE plus because the web profile doesn't support web services. No luck w/ this version either.
One difference between the two version is that in the TomEE web profile, I see all the Remote objects when I access the openejb webapp. However I don't see them w/ TomEE plus version.
http://localhost:8080/openejb/viewjndi.jsp
Any suggestions of how I could resolve this? I'm guessing it is configuration issue and I don't know which one.
Here is the complete stack trace:
java.lang.NullPointerException
org.apache.openejb.client.JNDIContext.createBusinessObject(JNDIContext.java:203)
org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:247)
javax.naming.InitialContext.lookup(InitialContext.java:392)
org.bluebox.customer.client.CustomerConnection.getCustomerAccountRemote(CustomerConnection.java:67)
org.bluebox.customer.client.CustomerLogin.prepare(CustomerLogin.java:65)
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:167)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:498)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:434)
TomEE Plus is definitely the right distro to use if migrating from an OpenEJB/Tomcat install. They match identically in features with the difference that the stack now supports full EJB 3.1, JAP 2.0 and JAX-RS. The Web Profile version of TomEE is quite a bit leaner and lacks WebServices, JMS and any non-WebProfile requirement. Here's a brief comparison of APIs supported.
That looks like a bug that was fixed with TomEE 1.0.0-beta-2 released in January. If you can give it a try, it'd be wonderful. We will absolutely want to make sure any issues you might face are cleared up before the 1.0.0 GA.