Camel-swagger and Hawt.io incompatibility - apache-camel

We have Camel (2.15.2) based application with some REST services published.
Camel-swagger component is used to publish information about the services.
Everything works perfectly if the app is alone in a Tomcat container.
127.0.0.1 - - [12/Jun/2015:11:25:20 +0200] "GET /myapp/api-docs/ HTTP/1.1" 200 383
However if I deploy freshly downloaded Hawt.io 1.4.51 WAR (sample-1.4.51.war) in the same container (no changes o configurations done) I get 204 response code from my original app.
127.0.0.1 - - [12/Jun/2015:12:50:51 +0200] "GET /myapp/api-docs/ HTTP/1.1" 204 -
I guess it all about JMX and how Swagger gets information about REST services published in the Camel context, but I not sure how to avoid this error

Related

S3 hosted React app gets 405 Method Not Allowed

I have a react app hosted in S3. It is behind a Cloudfront CDN, which is reachable via a custom domain:
console.example.com -> CDN -> S3 hosted app
I also have a serverless application acting as my backend to handle API calls from the React app. This is also behind a Cloudfront CDN, which is reachable via a custom domain:
api.example.com -> CDN -> API Gateway
The front end is correctly configured to point to api.example.com. For the API Gateway, CORS is enabled.
When I navigate to the home page and attempt to login, console.example.com/login, I get the 405 Method Not Allowed error. Login, obviously using POST
I verified that the following curl is successful, when hitting the backend via API Gateway endpoint, Cloudfront Domain and the custom domain, effectively ruling out any API Gateway issue.
curl:
curl --header "Content-Type: application/json" \
--request POST \
--data '{"email":"name#test123.com","password":"xyz"}' \
https://api.example.com/login
In my research, I have found that S3 does not support POST. I have also found similar questions such as this and this, which were not helpful in my case unfortunately.
It is also worth noting that running my frontend and backend locally, works just fine, leaving me to think the S3 issue is my blocker here. But I'm not sure why. My POST endpoints are not trying to POST an object to the S3 bucket, they should be using the bundle.js file to hit the api endpoint.
So what am I missing? While I am not a frontend specialist, I assume others host react apps on S3 and can hit their api's just fine no?
I have intentionally not included the code as there would be a lot to digest there but am happy to include any that would be helpful, such as serverless.yml files or cloudformation templates etc. Any help would be awesome.
**** UPDATE - Added Cloudformation template for frontend Cloudfront CDN ****
Distribution:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
Origins:
-
# Use the Website as the origin
DomainName: !GetAtt 'Website.DomainName'
Id: !Ref Website
CustomOriginConfig:
HTTPPort: 80
HTTPSPort: 443
OriginProtocolPolicy: https-only
Enabled: true
HttpVersion: http2
DefaultRootObject: index.html
CustomErrorResponses:
- ErrorCode: 404
ResponseCode: 200
ResponsePagePath: /index.html
- ErrorCode: 403
ResponseCode: 200
ResponsePagePath: /index.html
DefaultCacheBehavior:
AllowedMethods:
- DELETE
- GET
- HEAD
- OPTIONS
- PATCH
- POST
- PUT
DefaultTTL: 60
ForwardedValues:
QueryString: true
Cookies:
Forward: none
# The origin id defined above
TargetOriginId: !Ref Website
ViewerProtocolPolicy: "redirect-to-https" # we want to force https
# The certificate to use when using https
Aliases:
- console.example.com
ViewerCertificate:
AcmCertificateArn: arn:aws:acm:us-east-1:11111111:certificate/11111111-fa9b-4705-b9d2-11111111
MinimumProtocolVersion: TLSv1
SslSupportMethod: sni-only
I updated CustomErrorResponses to include 405 and I no longer get "405 Method Not Allowed" error:
CustomErrorResponses:
- ErrorCode: 405
ResponseCode: 200
ResponsePagePath: /index.html
- ErrorCode: 404
ResponseCode: 200
ResponsePagePath: /index.html
- ErrorCode: 403
ResponseCode: 200
ResponsePagePath: /index.html

_ah/ URLs being passed into app via app.yaml

I've installed a CakePHP application onto App Engine, and I'm redirecting URLs into it using a wildcard URL in my app.yaml:
url: /.*
script: app/webroot/index.php
The documentation states that /_ah/* URLs will be ignored (I don't know what these are for yet), but they are being caught by my CakePHP app and throwing errors into the error log. I also suspect this is the cause of 500 errors with an appengine error of 204 that keep happening randomly.
Does anyone have a solution for this? How do I ensure that the /_ah/ urls pass through to the app engine and not my specific application code?
Example error:
E 08:51:48.957 2015-03-17 404 841 B 304ms /_ah/start
0.1.0.3 - - [17/Mar/2015:01:51:48 -0700] "GET /_ah/start HTTP/1.1" 404 841 - - "****.appspot.com" ms=304 cpu_ms=416 cpm_usd=0.000094 loading_request=1 instance=0 app_engine_release=1.9.18
E 08:51:48.854 error: [MissingControllerException] Controller class AhController could not be found.
MissingControllerException is thrown by my app.
Request to /_ah/start is an initial request from Appengine itself, to initialize your app. I think you can ignore it, if you don't need to do anything special. Or return empty response.
See docs: https://cloud.google.com/appengine/docs/php/modules/#PHP_Instance_states

GAE TaskQueue hitting Endpoints API

I have an endpoint api named "gameApi"
I have an api called:
#ApiMethod(name = "startNewRound", path = "evaluateRound", httpMethod = HttpMethod.POST)
I'm trying to run the following task queue:
queue.add(
ofy().getTransaction(),
TaskOptions.Builder.withUrl("/_ah/api/gameApi/v1/evaluateRound")
.param("gameId", gameId.toString())
.method(TaskOptions.Method.POST)
.countdownMillis(5000));
I'm getting a 404 in the logs:
0.1.0.2 - - [14/Nov/2014:14:58:28 -0800] "POST /_ah/api/gameApi/v1/evaluateRound HTTP/1.1" 404 234 "https://some-appspot-123.appspot.com/_ah/spi/com.appspot.some_appspot_123.spi.GameAPI.playCard" "AppEngine-Google; (+http://code.google.com/appengine)" "some-appspot-123.appspot.com" ms=8 cpu_ms=21 cpm_usd=0.000026 queue_name=default task_name=62689306220576549071 instance=00c61b117c54ec2fb802c51c19fe26523ec51854 app_engine_release=1.9.16
It looks like it's hitting the HTTP and not the HTTPS page. Is there a way I can force it to use HTTPS?
In endpoints, HTTP 404 corresponds to com.google.api.server.spi.response.NotFoundException.
Is it possible that the method has not been defined in the API class, or that it doesn't have a correct annotation?
Also, it doesn't seem like it's hitting http, the trace clearly shows https as the protocol. I think it's only possible to use http on localhost.

App Engine Backends and Taskqueue URL login Error

I'm getting this error from a request called from the task queue. It suggests I need to change the app.yaml handler but I think I have the correct handler
Here is the error log entry:
2011-11-17 13:30:35.849 /tasks/kacher 302 209ms 0kb
0.1.0.1 - - [17/Nov/2011:13:30:35 -0800] "GET /tasks/kacher HTTP/1.1" 302 0 - - "rawload.XXX.appspot.com" ms=209 cpu_ms=0 api_cpu_ms=0 cpm_usd=0.000032 queue_name=default task_name=cf2e2f1d39d108b3972a1da8c6532fea
W2011-11-17 13:30:35.842
Request failed because URL requires user login. For requests invoked within App Engine (offline requests like Task Queue, or webhooks like XMPP and Incoming Mail), the URL must require admin login (or no login).
This is the code to call the task:
taskqueue.add(url='/tasks/kacher',target='rawload',method='GET')
Here is my app.yaml, with the task urls as login:admin which seems correct (to me):
- url: /tasks.*
script: main.py
login: admin
- url: .*
script: main.py
login: required
secure: always
There's a known bug in the dev_appserver with tasks that require admin login sometimes failing like this. Try logging your browser session in as an admin before accessing the URL that enqueues the task, or try uploading your app to production to see if you experience the issue there.

Google App Engine Error 0kb AppEngine-Google

I have a project on Google App Engine. It has 2 separate data-stores one which holds articles and the other holds any article which is classified as a crime. (True or False)
But when I try and run my cron to move the crime articles into the "crime" data-store I receive this error:
Has anyone experienced this and how did they over come it!?
0kb AppEngine-Google;
0.1.0.1 - - [22/Apr/2011:09:47:02 -0700] "GET /place HTTP/1.1" 500 138 - "AppEngine-Google;
(+http://code.google.com/appengine)"
"geo-event-maps.appspot.com" ms=1642
cpu_ms=801 api_cpu_ms=404
cpm_usd=0.022761 queue_name=__cron
task_name=740b13ec69de6ac36b81ff431d584a1a loading_request=1
As a result my cron fails.
I just had a similar problem where my cron was crashing due to the fact that it was finding an non-ascii character and not able to process it? Try encode('utf-8'). My cron's work ok without needing the login URL, but it's a good tip for future :-)
Just my 2 cents worth for your question ;-)
It's probably not related to cron. Trying to load your URL directly (http://geo-event-maps.appspot.com/place) returns an HTTP 500 error. As an admin of the app, you should be able to run any cron job without error just by pasting the URL into a browser, so start there.
By the way, make sure to require admin access to any cron URLs. As an unauthorized user I should have received a 401 error, not a 500. Even if you use just one handler, you can do something like this in your app.yaml:
- url: /cron/.*
script: main.py
login: admin
- url: /.*
script: main.py

Resources