Embedded Jetty - Disable URL rewriting for external URLs - url-rewriting

I'm using Jetty, in an embedded server configuration. When the client is not accepting cookies, Jetty uses URL rewriting to encode the session ID in the URL itself (adding something like ;jsessionid=xxx to the URL).
My problem is that when I redirect the client (using a HTTP 302, moved temporarily) to an external URL, this URL rewriting breaks the external URL I redirect to (ie, ;jsessionid=xxx is also present in the URL).
How can I selectively disable URL rewriting on embedded Jetty for external URL? Is this a bug of Jetty? I'm using Jetty 9.4.7. I also tried to set the option org.eclipse.jetty.servlet.SessionDomain, but with no avail.

I finally found the answer by digging into the Jetty code path. You just need to enable the following init option:
org.eclipse.jetty.servlet.CheckingRemoteSessionIdEncoding=true
For example for embedded Jetty:
ServletContextHandler context = ...
context.setInitParameter(
"org.eclipse.jetty.servlet.CheckingRemoteSessionIdEncoding",
"true");
Note for the interested reader: The code related to this is in org.eclipse.jetty.server.Response::encodeURL() (line 477 for v9.4.7).

Related

Migrating URLs from WebSphere Traditional Application Server to Liberty

I'm working on migrating a complex application to Liberty and it uses property files that use the WAS URL resource. Is there a way, without re-writing anything in the application so that it will run in Liberty? How can I define the URL in the server.xml ?
Did you try using jndiURL like this:
<jndiURLEntry jndiName="myFirstJNDIEntry" value='"file:///myDirectory/myConfigFile.properties"' />
And access it in code like:
#Resource(name="myFirstJNDIEntry")
private URL propsURL;
It is discussed in this Redbook Microservices Best Practices for Java and in documentation JNDI URL Entry (jndiURLEntry)

Cannot call the REST with usual relative urls of new spring boot project

I have two projects
1. Project-UI (containing angular pages)
2. Project-REST (Rest web services)
Initially they used to be on same tomcat so I could call any of the REST resource with url "/Project-REST/Customer/id/1234" since the context path was same e.g. localhost:8080
Now, the Project-REST has been converted to Spring boot and uses inbuilt tomcat of the boot on a port say 8085. so my relative urls dont work.
is there any way to make it work so that I need not change all my urls..... without entering context path ?
I am using eclipse as IDE
Here are 3 suggestions in random order:
All requests go to tomcat (Project-UI, port 8080), where you configure URL rewriting to redirect some requests to spring-boot (Project-REST port 8085). A quick google search produced this and this, both similar to mod_rewrite of Apache.
If as I understand &Project-UI* one contains static files, you can easily serve these from your spring-boot application at port 8085. Spring boot docs for serving static content here. In summary spring-boot will serve static content from a directory called /static (or /public or /resources or /META-INF/resources) in the classpath or from the root of the ServletContext.
Put a proxy server in front of both Project-UI and Project-REST and configure request redirects there. This is a more involved solution but may help you if you more projects in the future.

The HAL Browser doesn't get autoconfigured correctly in spring-data-rest

I have install HAL Browser in my spring boot app.
In the documentation they say it will be started at http://localhost:8080.
but it got started at http://localhost:8080/api which is my repositories.
So it override the base path of my spring-data-rest api.
Then inside the HAL browser app, I can see all of my repositories.
If I try a GET, it try's to query them under http://localhost:8080/api/api/entities , which return 404.
The original endpoint http://localhost:8080/api/entities also return 404.
Is the plugin broken with latest spring, spring-data, spring-hateoas modules ?
If I change the data rest api path to "/" it work fine.
Also, I would like to know if it's possible to authorize the client using OAuth. I use spring-security-oauth and all the request are rejected .
Edit It appear the plugin doesn't support different path than /
Also, it is not possible to support spring-data-oauth, my best chance is to install HAL Browser my self
You don't need to use complete URL like http://localhost:8080/api/entities
You should use only the URI like -
/api/api/entities

Wildfly Undertow HTTP Response 200 but no content

I am developing a simple web service using Eclipse Java EE IDE for Web Developers : Version: Kepler Service Release 2 Build id: 20140224-0627 and Wildfly-8.2.0.Final. I chose wildfly-javaee7-webapp-blank-archetype using Maven and started development. Firstly, there was no problem, I could add some simple jsp pages and also a simple html page with some images and javascript inclusion then I could deployed, launched and accessed those pages by browser. But all of a sudden, Wildfly (I guess Undertow maybe?) started to response with HTTP response 200 with no content... I really don't get what is going on. I also did rollback my sources to the very early simple pages only. But still the symptoms are the same. Also I have tried to use newer version of Wildfly-9.0.1.Final and deployed manually but I haven't seen any difference.
ex1) this is ok. (Of course browsers take care of this...)
ex2) this kind of contents won't be loaded and sent back as content 0...
I doubted local path issue but I haven't changed anything and it was loaded earlier.
It would be really appreciated if somebody could give me a solution.
Finally I have solved this problem. I have found a problem on a servlet I have added at last. Actually I was trying to migrate my web service running on glassfish and did migrate files one by one. I specified a URL to be handled by the servlet in Web.xml when it run on glassfish. But somehow, it's not working on Wildfly which means all URL request are unexpectedly handled by the servlet... Since I have no idea to specify url to be handled by the specific servlet in Web.xml for Wildfly, I decided to filter request URL in the servlet code. So it is working now. Thank you guys trying to help me...

Apache Camel load external XSLT contentCache duration

I am using Apache Camel on a web-app and I want to call external xslt stylesheet.
I am using the absolute file URI (until now I was not able to use the relative file URI on Tomcat)
The Camel doc refer the following option :
contentCache default:true Camel 2.6: Cache for the resource content (the stylesheet file) when it is loaded. If set to false Camel will reloader the stylesheet file on each message processing. This is good for development.
But I haven't find anything about the duration of this cache.
Is there anyway to know the default value of this cache duration and to change it?
The content is cached without a timeout and there currently isn't an option to change it (see the source code here).
Feel free to log a CAMEL enhancement request in JIRA and we can possibly add support for specifying a custom timeout.

Resources