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
Regression: Static JS files served as 'application/octet-stream' instead of 'application/javascript' [SPR-14368] #18940
Comments
Brian Clozel commented Hello Luis Lebolo This might be related to #18233, but I don't see why this is behaving like this. Did you define a custom I've added a repro project for this and couldn't reproduce the problem with JDK8 on Tomcat 8.0 and Jetty 9.3. Could you try this repro project in your environment or adapt it to reproduce the issue? Thanks |
Rossen Stoyanchev commented If it's not easy to provide a repro project, perhaps you can debug your application. See what happens in |
Luis Lebolo commented Thanks for looking into this guys. Brian, the only configuration I can think of around content negotiation is <!-- ContentNegotiatingViewResolver delegates to other ViewResolvers based on application context/media type -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="viewResolvers">
<list>
<bean class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
</list>
</property>
<property name="defaultViews">
<list>
<bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView">
<property name="prefixJson" value="true" />
</bean>
</list>
</property>
</bean> I'm using Tomcat 8.0.29 and Java 8 (jdk1.8.0_66). JAF is available. The only JVM settings I add when running Tomcat are I'll try to reproduce the issue in the repo you've created, but first I'll try to debug |
Rossen Stoyanchev commented In 4.2.6 the media type for a resources was checked against the |
Luis Lebolo commented I stepped through the debugger and the issue is definitely related to changes made in #18233. I tried configuring a custom content negotiating manager like this, but that didn't work. <mvc:annotation-driven content-negotiation-manager="contentNegotiationManager" />
<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
<property name="mediaTypes">
<value>js=application/javascript</value>
</property>
</bean>
!-- ContentNegotiatingViewResolver delegates to other ViewResolvers based on application context/media type-->
<bean id="viewResolver" class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="contentNegotiationManager" ref="contentNegotiationManager"/>
<property name="viewResolvers">
<list>
<bean class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
</list>
</property>
<property name="defaultViews">
<list>
<bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView">
<property name="prefixJson" value="true" />
</bean>
</list>
</property>
</bean> For completeness (excuse the verbosity :D), I looked at I get all the way to line 530 with If I step down further into If I step down further into |
Luis Lebolo commented In |
Rossen Stoyanchev commented
What's the actual instance? It should be I'm also surprised that setting up a mapping for "js" does not work. Any idea what happens in those same steps? I'm starting to suspect something about the URL that's throwing off perhaps the determination of the extension? |
Luis Lebolo commented I'll be away for a few days, but will check on this at the end of the week. |
Rossen Stoyanchev commented I'm actually awaiting feedback from you (see my last comment). |
Luis Lebolo commented I'm back and able to devote some time. The actual instance is This is using the configuration I mentioned here. |
Rossen Stoyanchev commented Okay thanks I see the issue. I'll have a snapshot for you to try later today. |
Rossen Stoyanchev commented There is a fix in place that should address the issue. When the current build finishes please give it a try with a 4.3.1 snapshot and thanks! |
Luis Lebolo commented Sorry, I'm not too familiar with the Spring build system. Can you point me to the status of the current build? And if it's not too much trouble (I can Google around), how would I use the latest snapshot? I'm using Gradle to get Spring from mavenCentral, e.g. apply plugin: 'java'
apply plugin: 'war'
repositories {
mavenCentral()
}
dependencies {
compile 'org.springframework:spring-web:4.2.+'
// ...
} |
Rossen Stoyanchev commented The build is done. You need repo.spring.io/snapshot/ and version 4.3.1.BUILD-SNAPSHOT. |
Luis Lebolo commented Ok, things are back to normal with 4.3.1.BUILD-SNAPSHOT (i.e. javascript files have |
Steve commented I am using Spring mvc 4.3.2 and Spring Security 4.1.3 and am still experiencing the same issue. All static js resource are being served as 'application/octet-stream'. |
Steve commented Previous comment, that is with an webapp with |
Brian Clozel commented An issue related to that, #19146, has been fixed and will be released with 4.3.3. In the meantime, can you test your application with the 4.3.3.BUILD-SNAPSHOT version? If you can still reproduce the problem with 4.3.3 snapshot, please open a new issue with a small repro project so we can investigate. Thanks! |
Steve commented I can confirm that 4.3.3 fixes the issue and static js files are now served correctly. |
@spring-issuemaster I'm new with spring and I have the same problem. Could you give an example of how pom.xml should look? |
@mffonseca your pom.xml should look like a project generated from start.spring.io. If you need help with a problem in your application, you can ask a question on StackOverflow. |
spring-projects-issues commentedJun 15, 2016
•
edited
Luis Lebolo opened SPR-14368 and commented
I upgraded from Spring 4.2.6 to 4.3.0 and now I'm receiving the following error in Chrome when my web page tries to load static javascript files.
I double-checked the response header (using Spring 4.3.0) and I indeed see
Content-Type:application/octet-stream
. However, when I drop back down to Spring 4.2.6 I seeContent-Type:application/javascript
.The files are included in my page like
and my config looks like
I tried looking at the Spring 4.3.0 release notes, but nothing immediately stood out (maybe #17493).
Any ideas what changes in 4.3.0 are affecting me? How do I tell Spring 4.3.0 to set the correct content type for static javascript files? Let me know if you need more details about configuration, etc. Unfortunately, I don't think I could package up the project - it's quite complex and lots of proprietary info.
Affects: 4.3 GA
Reference URL: http://stackoverflow.com/questions/37822460/upgraded-to-spring-4-3-0-and-static-js-files-are-now-served-as-application-octe
Issue Links:
Referenced from: commits e38623d
0 votes, 5 watchers
The text was updated successfully, but these errors were encountered: