I am deploying my RESTful web application on jBoss EAP 6.1 (7.2.1Final) with Wink 1.2 and getting following exception on all the request;
<b>JBWEB000070: exception</b>
<pre>java.lang.NullPointerException
org.apache.wink.common.internal.http.Accept.valueOf(Accept.java:139)
org.apache.wink.server.internal.contexts.HttpHeadersImpl.getAcceptHeader(HttpHeadersImpl.java:152)
org.apache.wink.server.internal.contexts.HttpHeadersImpl.getAcceptableMediaTypes(HttpHeadersImpl.java:106)
org.apache.wink.server.internal.registry.ResourceRegistry.filterByProduces(ResourceRegistry.java:558)
org.apache.wink.server.internal.registry.ResourceRegistry.filterDispatchMethods(ResourceRegistry.java:482)
org.apache.wink.server.internal.registry.ResourceRegistry.findMethod(ResourceRegistry.java:359)
org.apache.wink.server.internal.handlers.FindResourceMethodHandler.handleResourceMethod(FindResourceMethodHandler.java:138)
org.apache.wink.server.internal.handlers.FindResourceMethodHandler.handleRequest(FindResourceMethodHandler.java:65)
org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26)
org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22)
org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:63)
org.apache.wink.server.internal.handlers.FindRootResourceHandler.handleRequest(FindRootResourceHandler.java:95)
org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26)
org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22)
org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:63)
The same application works OK on previous versions of jBoss like EAP 5.1 and old.
I have also captured the posted request using tcpmon and getting following information in headers;
GET /hothouse-iris/Hothouse.svc/ HTTP/1.1
Host: 127.0.0.1:9090
Connection: keep-alive
Authorization: Basic U1NPVVNFUjE6MTIzNDU2
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36
Content-Type: application/atom+xml
Accept: */*
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6
Cookie: JSESSIONID=8D9FE5379FE7576610BB4B78A431AD10; __utma=96992031.2145502422.1381922298.1382004674.1382006170.4; __utmc=96992031; __utmz=96992031.1381922298.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
I am using Chrome extension POSTMan to request my service and it works.
The problem is that initialization of Accept class does not actually happen, and the delegate field is null.
The RuntimeDelegate is an interface whose implementation should be specified in META-INF/service/javax.ws.rs.ext.RuntimeDelegate file which is searched on the class path.
wink-common.jar contains such a service file with the correct class name of the implementation but if some other service file with the same name is found on class path (on of the jars) before the correct one, we will have such a weird behavior.
The problem was that JAX-RS implementation provided by jboss 7 was conflicting with Apache Wink, we had to disable jboss impl completely by commenting the contents of module.xml under JBOSS_HOME\modules\system\layers\base\javax\ws\rs\api\main to stop loading the Jboss JAX-RS API and it worked fine
This error is caused by the jar file conflict.I deleted jetty.jar,jetty-util.jar and also deleted jsr305.jar,the REST API just work fine.
On WAS8.5 liberty profile, even after I removed the wink dependency causing the error, the error would not go away. It finally turned out that I needed to stop & start my server. The solution was posted at the very bottom of this link https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014940544
Related
I was installed this library, I am working with sails.js
npm install sails-hook-swagger-generator --save
from their main website https://github.com/theoomoregbee/sails-hook-swagger-generator
I have created this file ./swagger/swagger.json
I want to see the swagger from the browser, how can I see the endpoints?
I have in routes something like that
'GET /api/v1/information': { action: 'actions/getinformation' },
I can not see nothing from the browser, what is the problem?
EDIT 1
from their answer https://github.com/theoomoregbee/sails-hook-swagger-generator/issues/27
you can simply change the directory you want to place the generated
swagger json may be assets, then clone
https://github.com/swagger-api/swagger-ui following the instructions
here
Just simply extract the dist folder (which is needed for just the
swagger ui) and update this line
https://github.com/swagger-api/swagger-ui/blob/1a95b9e9c972b95227a2976553fea988e58d7ff2/dist/index.html#L44
to be the path to the generated swagger json within your assets folder
i dont know what should i put in that line, i am putting the path of my file swagger.json
/disk/team/work/proyect/swagger
but when i try this url in the browser
http://127.0.0.1:8080/
i am getting this [2020-09-01T19:39:35.791Z] "GET /" Error (404): "Not found"
[2020-09-01T19:39:35.961Z] "GET /" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36"
[2020-09-01T19:39:35.963Z] "GET /" Error (404): "Not found"
Using the method described in this answer (clojure.java.io/input-stream), how would I go about setting the User-Agent request header?
You can't. clojure.java.io is a very simplistic API, for doing the easiest stuff. If you want any real customization you'll need to use a real HTTP library.
You can, but only to a certain extent, setting a property.
From this answer https://stackoverflow.com/a/47300260/483566 I tried running netcat in a terminal: nc -l -p 8080
On the REPL, I tried the following:
$ lein repl
nREPL server started on port 42819 on host 127.0.0.1 - nrepl://127.0.0.1:42819
REPL-y 0.4.3, nREPL 0.6.0
Clojure 1.10.0
OpenJDK 64-Bit Server VM 11.0.4+11-post-Ubuntu-1ubuntu218.04.3
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
Results: Stored in vars *1, *2, *3, an exception in *e
user=> (System/setProperty "http.agent" "Clojure REPL")
nil
user=> (slurp "http://localhost:8080/")
Netcat is not actually serving content, so the REPL will block, but if you see the terminal where netcat runs, you'll see something like:
GET / HTTP/1.1
User-Agent: Clojure REPL Java/11.0.4
Host: localhost:8080
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
For actual customization, you probably want to use an HTTP client library that provides access to the HTTP headers (most will do).
I have an API that is far from standard, and I want to create Swagger docs for it. Since it's so far from standard I won't be able to generate anything, instead I'll have to do it manually.
I followed the instructions and created the "hello-world" project, I have been trying to edit this to call my own API instead. A simple GET endpoint returning a JSON list of objects.
I am assuming I can ignore everything that has to do with controllers and mocks etc since this API already returns json data if I call it through postman. I.e its a working API and all I want Swagger for is documentation.
Unfortunately I only get an "ERROR Server not found or an error occurred" when trying it out, but if I browse to the URL it's using it works fine. So I assume there is something I am missing that Swagger needs. Keep in mind I have not change any configs or anything else in this hello-world project, only the editor.
Here is my Yaml:
swagger: "2.0"
info:
version: "0.0.1"
title: Hello World App
# during dev, should point to your local machine
host: localhost
# basePath prefixes all resource paths
basePath: /appname/api/v1/object
#
schemes:
# tip: remove http to make production-grade
- https
# format of bodies a client can send (Content-Type)
consumes:
- application/json
# format of the responses to the client (Accepts)
produces:
- application/json
paths:
/campaign/:
get:
description: Get all campaigns
# used as the method name of the controller
operationId: hello
responses:
"200":
description: Success
schema:
# a pointer to a definition
$ref: "#/definitions/HelloWorldResponse"
# responses may fall through to errors
default:
description: Error
schema:
$ref: "#/definitions/ErrorResponse"
# complex objects have schema definitions
definitions:
HelloWorldResponse:
required:
- message
properties:
message:
type: string
ErrorResponse:
required:
- message
properties:
message:
type: string
Here is the request it tries to send, which looks correct:
GET https://localhost/appname/api/v1/object/campaign/ HTTP/1.1
Host: localhost
Accept: application/json
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8,fa;q=0.6,sv;q=0.4
Cache-Control: no-cache
Connection: keep-alive
Origin: http://127.0.0.1:62430
Referer: http://127.0.0.1:62430/
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0
I am trying post the following string "`.4.13 - 30613 £ ₤ © ™" to a Grails Server once Deployed as a WAR and I'm having no luck when communicating between two instances of Tomcat7
Our server works as an API, and the web layer entirely seperately. Data is saved to the DB by POST request to Web App, then the Web App sends a POST (or PUT for updates) request to the server to save the data.
This works fine locally when I start the Web App and Server with "Run-App" but not when we move to non-local enviroments with Tomcat7 and deployed WAR files.
Initally I thought this may be related to a reported bug http://jira.grails.org/browse/GRAILS-8873 but upon closer inspection, it appears that UTF-8 is the default anyway, and is currently in use
The non-local enviroments use the following structure (Deployed WAR in Tomcat7)
Entry Point -> Apache 2.2 < - > Web App < - > Server
The local environments use the following structure (Run App)
Entry Point -> Web Abb < - > Server
I have output the value at the time of marshalling to string to ensure that before it is sent to the server, it is of the correct encoding
DEBUG MarshallService - Marshalling Property : name of value [ `.4.13 - 30613 £ ? © ™]
This is directly from the log for the outgoing request from the Web App to the Server
Ignore the fact that the content length is wrong, i've truncated the body for the purposes of readability.
DEBUG org.apache.http.headers - >> PUT /baseline-server/baseline/pwqi9tzyTRWX5oZogfKjJw HTTP/1.1
DEBUG org.apache.http.headers - >> Accept: application/json; charset=utf-8
DEBUG org.apache.http.headers - >> Content-Length: 349
DEBUG org.apache.http.headers - >> Content-Type: application/json
DEBUG org.apache.http.headers - >> Host: localhost:9001
DEBUG org.apache.http.headers - >> Connection: Keep-Alive
DEBUG org.apache.http.headers - >> Accept-Encoding: gzip,deflate
DEBUG org.apache.http.wire - >> "{"name":"`.4.13 - 30613 [0xa3] ? [0xa9] [0x99]"}
I have read several answers across several other locations and done the following
In Apache 2.2 HTTPD.conf before ANY VirtualHost
AddDefaultCharset utf-8
In both Tomcat Instances (Web.xml)
<filter>
<filter-name>setCharacterEncodingFilter</filter-name>
<filter-class>org.apache.catalina.filters.SetCharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<async-supported>true</async-supported>
</filter>
Additionally, as per other answers, I ahve ensured we are using webxml 1.4.1
And yet, when the value reaches the Server side, the values are all ???
What I find particularly strange is the outgoing JSON doesn't appear to show UTF-8 characters at all
Any assistance would be greatly appreciated
I can suggest some configs to try.... Let me know if any can resolve your problem :)
Are you on ubuntu or other linux? Try to set
LANG="en_US.UTF-8"
LANGUAGE="en_US:en"
LC_ALL="en_US.UTF-8"
in /etc/default/locale and run
sudo locale-gen
( and reboot )
Are you using a db connection? Check if the connection in config/dasource.groovy is utf8
url = "jdbc:mysql://localhost/?useUnicode=true&characterEncoding=UTF-8"
Put this settings in your /etc/Config.groovy
grails.views.gsp.encoding = "UTF-8"
grails.converters.encoding = "UTF-8"
Check that your tomcat connector is configured utf8
<Connector ... URIEncoding="UTF-8">
Just wondering what could the problem be why I can't access jquery ui autocomplete folder in the prod side.
I've been using this widget in the dev side and it works perfectly. However, when I deployed it, I get errors saying, jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.position.js, jquery.ui.all.css, and jquery.ui.autocomplete.js cannot be found: "404 Object Not Found".
This is how I reference these files:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script type="text/javascript" src="/folder1/folder2/jquery-ui-1.8.10.custom/development-bundle/ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="/folder1/folder2/jquery-ui-1.8.10.custom/development-bundle/ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="/folder1/folder2/jquery-ui-1.8.10.custom/development-bundle/ui/jquery.ui.position.js"></script>
<script type="text/javascript" src="/folder1/folder2/jquery-ui-1.8.10.custom/development-bundle/ui/jquery.ui.autocomplete.js"></script>
<link rel="stylesheet" href="/folder1/folder2/jquery-ui-1.8.10.custom/development-bundle/themes/base/jquery.ui.all.css">
Using Firebug, these are the Response and Request headers respectively:
HTTP/1.1 404 Object Not Found
Server: Microsoft-IIS/5.0
Date: Thu, 14 Apr 2011 08:22:27 GMT
Connection: close
Content-Length: 4040
Content-Type: text/html
GET /folder1/folder2/jquery-ui-1.8.10.custom/development-bundle/ui/jquery.ui.core.js HTTP/1.1
Host: (hostname)
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16
Accept: */*
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Referer: (referrer)
Cookie: (cookies)
I'm using Coldfusion MX 6.1. Are there permission or hosting issues involved? I don't have any idea here. Please help. Thanks.
When you use "/" before your src addresses, you are actually telling that the "folder1" is located in the root folder of your web server (i.e. WWW in Apache)
So if "folder1" is simply a folder located in the same path that your code file is, you should use:
src="folder1/folder2/jquery-ui-1.8.10.custom/development-bundle/ui/jquery.ui.core.js"
I got this working, at last. What I did was I got all folders outside of jquery-ui-1.8.10.custom folder. That is, instead of /folder1/folder2/jquery-ui-1.8.10.custom/development-bundle/ui/jquery.ui.core.js, I now have /folder1/folder2/development-bundle/ui/jquery.ui.core.js.
I still don't get why the folder name jquery-ui-1.8.10.custom can't be found. If anyone knows why please tell me. Thanks!