-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running embedded jetty in my Application through IntelliJ gives no error, but contexts are not running. What could be the reason? #7373
Comments
Difficult to say, too little information. Are you using IntelliJ-Jetty integration, or just running the Jetty code? |
I am running the jetty code, which is written in my application. I wasn't sure what exactly needs to be shared, thats why I didnt share anything. I am using code suggested by Joakime here: |
There are multiple snippets of code in that SO question/answer. |
Hi @sbordet Code used:
I have attached the jetty trace here and config.properties. I am getting HTTP 500 server error, on running through intelliJ, but it works fine when I run it using Services. |
Add this line and run it again. myServer = (Server) idMap.get("Server");
myServer.setDumpAfterStart(true); // <-- this line
myServer.start(); The output (to STDERR) will include your server state dump. |
Hi Joakime, |
You have a started server. It's listening on port 9096 on every network interface on that machine. Which means you can access your webapp from Using just It should be noted as well, that your WebApp doesn't have a normal default servlet, it's configured for |
Hi Joakime, I get proper response somehow, when I run the project through Windows Services. but while I run using intelliJ dev setup I get internal server error 500 which is little weird. It should be noted as well, that your WebApp doesn't have a normal default servlet, it's configured for [/]=>org.eclipse.jetty.servlet.ServletHandler$Default404Servlet-2a0e2c85 |
What do the server logs say for this 500 error?
In your example code above you have a line that says ... xmls.add(new PathResource(customBasePath.resolve("context.xml"))); Is that your |
Hi Joakime, 500 server error comes when I hit any of the deployed context: Pleasze find the stack trace here: I dont see any difference with the one shared earlier. Please find the context.xml here |
The The If you make the requests that result in a 500 error, the DEBUG logs should at least indicate the incoming request, the parsing of the request, it's path through Jetty to your Servlet context, and the reasons for the 500 error, the generation of the response, the sending of the response, and eventual completion of the response.
Ah, you are directly declaring a |
Seeing as you are running on Windows, make sure you don't have another process listening on port 9096 that is taking your requests. (this would explain the lack of DEBUG logs on the incoming requests) Windows allows this kind of nonsense setup (more than 1 process listening on the same port), no other OS does. |
I have checked again and again, no other services are running on port 9096. Do you have any suggestion for me to catch and log record whenever any request is sent to defined URL? Also, Is it possible to define separate contexthandler for each context? Can you please help me with that using shared context.xml? |
Stop your server, and try hitting your URLs again. If you get a connection error from the browser then you likely have no service present. Next, ensure your logging is setup to DEBUG for everything in Jetty (the named logger You need to ensure that the requests reach your server first. (The logs should indicate this, and those DEBUG logs will be crucial to help you) Try looking at the complete request/response of the failed 500 attempts, including all headers and body content, there could be something revealing about that information. (I would expect the response headers to indicate that they were produced by Jetty, and the response body content to include the stacktrace explaining the 500 error for example) |
Or, Do I need to pass any VM option or set any property to make it work? |
In the 500 response, look at the response body content. |
Hi @joakime, |
@avin15cs no response body content means that Jetty is not the one producing the 500 error for you. |
Yes, That might be possibly true, but the jetty stack trace is not able to catch it and idk how through Windows services, this error doesn't come into picture. |
Hi @joakime ,
Found out the reason behind this issue, it was not working because I was using older version of servlet-api, removing that worked! |
@joakime , |
The jetty-all uber jar is not meant to be used by another application as a dependency. It only exists to help with the tutorial section in the documentation. (it should have been called See: |
Hi @joakime , In that case, How can I run embedded jetty without using jetty-all-uber.jar? |
Using the normal dependencies and a build tool (like maven, gradle, scala, ant+ivy, grape, leiningen, buildr, bazel, etc) to obtain the top level components you need while letting the build tool pull all of the dependencies for those top level components. Note, it is not possible to have "all of jetty" in your project, there are many components that require you to choose which implementation you want to use. Based on your past questions I would start with ...
Do a build, and then, only after you discover a missing dependency from that build add the extra components you need. |
Yes I was able to get the dependencies through Maven tool: [INFO] org.example:JettyTest:jar:1.0-SNAPSHOT Thanks for help, @joakime! |
Jetty version
9.4.44.v20210927
Java version
java-11-openjdk-11.0.7.10-1.windows.redhat.x86_64
Question
I am using jetty in my application where it is embedded. When I try to access configured contexts while running my project through Services, I am able to get proper response.
But same thing when I run through intelliJ, only http://localhost:9096/ is accessible and for rest URLs I get internal server error 500.
What could have gone wrong here?
The text was updated successfully, but these errors were encountered: