noboomu / proteus Goto Github PK
View Code? Open in Web Editor NEWProteus is a blazing fast minimalist Java web server framework built atop Undertow.
License: Apache License 2.0
Proteus is a blazing fast minimalist Java web server framework built atop Undertow.
License: Apache License 2.0
I have a method:
@GET
@Path("{givenDate:[0-9]}")
public ServerResponse<Rates> givenDate(ServerRequest request, @PathParam("givenDate") String from) {
...
When I try to call the method, I get:
UT005071: Undertow request failed HttpServerExchange{ GET /v1/method/1 request {Accept=[application/json], Accept-Language=[en-US,en;q=0.5], Accept-Encoding=[gzip, deflate], DNT=[1], Origin=[http://localhost:8090], User-Agent=[Mozilla/5.0], Connection=[keep-alive], Referer=[http://localhost:8090/v1/openapi], Host=[localhost:8090]} response {Server=[proteus]}}
java.lang.IllegalArgumentException: Missing parameter givenDate
at io.sinistral.proteus.server.Extractors.string(Extractors.java:397)
at io.sinistral.proteus.controllers.handlers.CurrencyConvertRouteSupplier$2.handleRequest(CurrencyConvertRouteSupplier.java:56)
at io.sinistral.example.wrappers.DummyWrapper$1.handleRequest(DummyWrapper.java:39)
at io.undertow.server.handlers.accesslog.AccessLogHandler.handleRequest(AccessLogHandler.java:138)
at io.undertow.server.RoutingHandler.handleRequest(RoutingHandler.java:93)
at io.sinistral.proteus.server.handlers.ServerDefaultHttpHandler.handleRequest(ServerDefaultHttpHandler.java:70)
at io.undertow.server.session.SessionAttachmentHandler.handleRequest(SessionAttachmentHandler.java:68)
at io.undertow.server.protocol.http2.Http2UpgradeHandler.handleRequest(Http2UpgradeHandler.java:102)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:360)
at io.undertow.server.protocol.http.HttpReadListener.handleEventWithNoRunningRequest(HttpReadListener.java:255)
at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:136)
at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:162)
at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:100)
at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:57)
at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
at org.xnio.ChannelListeners$10.handleEvent(ChannelListeners.java:291)
at org.xnio.ChannelListeners$10.handleEvent(ChannelListeners.java:286)
at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
at org.xnio.nio.QueuedNioTcpServer$1.run(QueuedNioTcpServer.java:129)
at org.xnio.nio.WorkerThread.safeRun(WorkerThread.java:582)
at org.xnio.nio.WorkerThread.run(WorkerThread.java:466)
Caused by: java.lang.NullPointerException: null
at io.sinistral.proteus.server.Extractors.string(Extractors.java:394)
... 20 common frames omitted
java.lang.IllegalArgumentException: Missing parameter givenDate
at io.sinistral.proteus.server.Extractors.string(Extractors.java:397) ~[proteus-core-0.3.7-SNAPSHOT.jar:na]
at io.sinistral.proteus.controllers.handlers.CurrencyConvertRouteSupplier$2.handleRequest(CurrencyConvertRouteSupplier.java:56) ~[na:na]
at io.sinistral.example.wrappers.DummyWrapper$1.handleRequest(DummyWrapper.java:39) ~[classes/:na]
at io.undertow.server.handlers.accesslog.AccessLogHandler.handleRequest(AccessLogHandler.java:138) ~[undertow-core-2.0.15.Final.jar:2.0.15.Final]
at io.undertow.server.RoutingHandler.handleRequest(RoutingHandler.java:93) ~[undertow-core-2.0.15.Final.jar:2.0.15.Final]
at io.sinistral.proteus.server.handlers.ServerDefaultHttpHandler.handleRequest(ServerDefaultHttpHandler.java:70) ~[proteus-core-0.3.7-SNAPSHOT.jar:na]
at io.undertow.server.session.SessionAttachmentHandler.handleRequest(SessionAttachmentHandler.java:68) ~[undertow-core-2.0.15.Final.jar:2.0.15.Final]
at io.undertow.server.protocol.http2.Http2UpgradeHandler.handleRequest(Http2UpgradeHandler.java:102) ~[undertow-core-2.0.15.Final.jar:2.0.15.Final]
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:360) ~[undertow-core-2.0.15.Final.jar:2.0.15.Final]
at io.undertow.server.protocol.http.HttpReadListener.handleEventWithNoRunningRequest(HttpReadListener.java:255) ~[undertow-core-2.0.15.Final.jar:2.0.15.Final]
at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:136) ~[undertow-core-2.0.15.Final.jar:2.0.15.Final]
at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:162) [undertow-core-2.0.15.Final.jar:2.0.15.Final]
at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:100) [undertow-core-2.0.15.Final.jar:2.0.15.Final]
at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:57) [undertow-core-2.0.15.Final.jar:2.0.15.Final]
at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92) [xnio-api-3.3.8.Final.jar:3.3.8.Final]
at org.xnio.ChannelListeners$10.handleEvent(ChannelListeners.java:291) [xnio-api-3.3.8.Final.jar:3.3.8.Final]
at org.xnio.ChannelListeners$10.handleEvent(ChannelListeners.java:286) [xnio-api-3.3.8.Final.jar:3.3.8.Final]
at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92) [xnio-api-3.3.8.Final.jar:3.3.8.Final]
at org.xnio.nio.QueuedNioTcpServer$1.run(QueuedNioTcpServer.java:129) [xnio-nio-3.3.8.Final.jar:3.3.8.Final]
at org.xnio.nio.WorkerThread.safeRun(WorkerThread.java:582) [xnio-nio-3.3.8.Final.jar:3.3.8.Final]
at org.xnio.nio.WorkerThread.run(WorkerThread.java:466) [xnio-nio-3.3.8.Final.jar:3.3.8.Final]
Caused by: java.lang.NullPointerException: null
at io.sinistral.proteus.server.Extractors.string(Extractors.java:394) ~[proteus-core-0.3.7-SNAPSHOT.jar:na]
... 20 common frames omitted
Please note that io.sinistral.proteus.server.Extractors.string(Extractors.java:394)
is calling HttpServerExchange.getQueryParameters()
and I suspect that the call should be HttpServerExchange.getPathParameters()
.
I get this when I run the quickstart:
$ /bin/bash -e <(curl -fsSL https://raw.githubusercontent.com/noboomu/proteus-example/master/scripts/quickStart.sh)
Cloning into 'proteus-example'...
Warning: Permanently added the RSA host key for IP address '{removed}' to the list of known hosts.
remote: Enumerating objects: 18, done.
remote: Counting objects: 100% (18/18), done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 226 (delta 0), reused 10 (delta 0), pack-reused 208
Receiving objects: 100% (226/226), 441.58 KiB | 4.80 MiB/s, done.
Resolving deltas: 100% (52/52), done.
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< io.sinistral:proteus-example >--------------------
[INFO] Building proteus-example 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.328 s
[INFO] Finished at: 2019-08-30T14:08:10-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project proteus-example: Could not resolve dependencies for project io.sinistral:proteus-example:jar:1.0.0: Failed to collect dependencies at io.sinistral:proteus-core:jar:0.4.1: Failed to read artifact descriptor for io.sinistral:proteus-core:jar:0.4.1: Failure to find io.sinistral:proteus-project:pom:0.4.1 in https://oss.sonatype.org/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of oss-sonatype has elapsed or updates are forced
Is it possible to register a Service that will spawn/use its own thread? As I see it the supported BaseService is using the AbstractIdleService
which, according to the javadoc can't use its own thread.
Alternatively, if Proteus does not support this, is it possible to get to Undertow's builder? The idea is to poll messages from a queue (hence the thread that constantly checks for messages) and feeding it to undertow's websockets.
Can I map the controller to root '/' ?
http://localhost:8080/
@GET
@Path("/downloadFile/{fileName}")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public ServerResponse<ByteBuffer> downloadFile(ServerRequest request, @PathParam("fileName") final String fileName ) throws Exception
{
String userDir = System.getProperty("user.dir");
File file = new File(userDir + "/assets/" + fileName);
ServerResponse serverResponse = new io.sinistral.proteus.server.ServerResponse();
serverResponse.contentType("application/json;charset=UTF-8");
serverResponse.addHeader("Content-Disposition", "attachment;filename=" + file.getName());
serverResponse.addHeader("Content-Length", "" + file.length());
return serverResponse.entity(ByteBuffer.wrap(Files.toByteArray(file))).applicationOctetStream();
}
Is it correct? :)
http://localhost:8090/v1/openapi
Fetch error
Not Found http://localhost:8090/v1/openapi.yaml
e.g catch all errors in controller:
@ExceptionHandler
public ServerResponse<Result> errorHandle(ServerRequest request){
.....
return response(result);
}
Exception in thread "main" com.google.inject.ConfigurationException: Guice configuration errors:
hi,
bindInterceptor(Matchers.any(), Matchers.annotatedWith(Names.named("log")), new LoggerMethodInterceptor());
@Named("log")
public String get() {
return "hello";
}
Getting DependencyResolutionException when attempting to run the quickstart script, full logs as below:
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< io.sinistral:proteus-example >--------------------
[INFO] Building proteus-example 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for org.pac4j:undertow-pac4j:jar:3.0.0-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.011 s
[INFO] Finished at: 2020-05-26T23:59:52-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project proteus-example: Could not resolve dependencies for project io.sinistral:proteus-example:jar:1.0.0: Failure to find org.pac4j:undertow-pac4j:jar:3.0.0-SNAPSHOT in https://oss.sonatype.org/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of oss-sonatype has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
Any help is appreciated
Kindly specify minimum dependencies as too many dependencies are being downloaded when used with maven. Also poor documentation.
Most maven projects can be imported with Gradle with no issues. However, this one fails as proteus-project artifact is missing in maven (Gradle scans parent project from pom.xml of the main dependency). Could you please solve this issue?
> Could not resolve all files for configuration ':compileClasspath'.
> Could not resolve io.sinistral:proteus-core:0.4.2.
Required by:
project :
> Could not resolve io.sinistral:proteus-core:0.4.2.
> Could not parse POM https://repo.maven.apache.org/maven2/io/sinistral/proteus-core/0.4.2/proteus-core-0.4.2.pom
> Could not find io.sinistral:proteus-project:0.4.2.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/io/sinistral/proteus-project/0.4.2/proteus-project-0.4.2.pom
If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
There is no pom for proteus-project in maven as far as I can say in the given link or anywhere else in the repo.
Support @path with regex defined in JAX-RS.
Put some values into session like springmvc? Thanks.
hi,:)
POST http://localhost:8080/api/user/login
playload
{"username":"admin","password":"111111"}
server:
public ServerResponse<Map<String,Object>> login(ServerRequest request)
How to get json data?
get http://localhost:8090/v1/examples/user?name=tom&birth=1990-10-28
into User:
private String name;
private Date birth;
public void reguser(ServerRequest request, @BeanParam User user) {
Another question:
using @get and @post in same method?
@GET
@POST
@Path("/user")
@Produces({MediaType.APPLICATION_JSON})
public void mybatis2(ServerRequest request, @BeanParam User user) {
TBD
How to read static file?
eg. js file, img
Please add support for registering websocket handlers.
Any plans to implement reactive? Jooby has a module (although based on Reactor 2.5).
I added this for Reactor 3, curious if something similar is possible with proteus?
fun reactor(): Route.Mapper<Any> = Route.Mapper.create("reactor") { value ->
when (value) {
is Mono<*> -> Deferred { deferred ->
value
.doOnError { deferred.reject(it) }
.doOnCancel { deferred.reject(Exception("cancelled")) }
.subscribe { deferred.resolve(it) }
}
else -> value
}
}
}
Trying to build a project with the following dependency:
io.sinistral
proteus-core
0.4.2
build is failed with the error: Could not resolve dependencies for project io.sinistral:proteus-example:jar:1.0.0: Failed to collect dependencies at io.sinistral:proteus-core:jar:0.4.2: Failed to read artifact descriptor for io.sinistral:proteus-core:jar:0.4.2: Could not find artifact io.sinistral:proteus-project:pom:0.4.2 in maven (https://repo1.maven.org/maven2/) -> [Help 1]
I'd like to use social logins such as Facebook and Google to authorise access to my JAX-RS endpoints.
Any ideas how I could do this within Proteus?
How to use maven to package into a fat jar?
And it includes resources of assets and conf.
After it be packed,what kind of directory structure should it be?
Thanks!
How to do?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.