Discussion:
[google-appengine] Invalid Static JS Content Type on Google AppEngine Standard Environment
Ali Koc
2018-12-06 11:49:09 UTC
Permalink
I have a simple java application running on Google App Engine Standard
environment, which along with servlets, also contains static html, css and
js files.


It seems js files are always served with "content-type: text/plain". Even
when I create a new Hello App Engine application (doing this in Eclipse
through GCP plugin) and add a simple js file to the project and deploy. The
js file is served as content-type: text/plain.


Note that when I debug locally, the files is served as
application/javascript as expected. The issue only occurs on the deployed
version.


Here is the link to the file in the hello world application:

https://test2-dot-baruch-221323.appspot.com/test.js


This is using Java 8. Here is what web.xml file look like:


<?xml version="1.0" encoding="utf-8"?><web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<mime-mapping>
<extension>js</extension>
<mime-type>application/javascript</mime-type>
</mime-mapping></web-app>


What am I missing here? Other static files such as html and css come with
correct content type, js seems to be the only one with issue. Can you give
me some pointers on how to debug this?
--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine+***@googlegroups.com.
To post to this group, send email to google-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/bda7a435-c5fa-4c46-bd1c-51851264b9f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
'George (Cloud Platform Support)' via Google App Engine
2018-12-07 01:58:49 UTC
Permalink
Hello Ali,

You seem to want to deploy a Java app. If this is the case, you must put
your static served files within your app's webapp directory. After you
choose a location for the static files, you must define their location in
the appengine-web.xml file, using the <static-files> element. More detail
can be gathered from the "Getting Started: Serving Static Content"
documentation page. [1]

App Engine can serve static content such as HTML pages and media such as
images. Static content is anything that will not be executed as JSPs or
Servlets.

How do you deploy your app? Is it with gcloud app deploy, Maven, or Gradle?
A procedural description, in step-by-step fashion, would be appreciated.

[1] https://cloud.google.com/appengine/docs/standard/java/building-app/static-content
--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine+***@googlegroups.com.
To post to this group, send email to google-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/c3abff72-d163-4df3-9359-e471d5720cea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Ali Koc
2018-12-07 13:06:36 UTC
Permalink
Hello, George!

1- Sure all static files are in webapp folder. (see attached zip file) All
I am doing is creating a new Java Standard environment hello world app.

2- I didn't know using <static-files> element to define static files was a
must. I was going with this documentation which says it is optional and in
fact works without it as long as the static file is inside webapp folder
(public-root). But I added the static files section with no help.

appengine-web.xml:

<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">

<threadsafe>true</threadsafe>
<sessions-enabled>false</sessions-enabled>
<runtime>java8</runtime>

<system-properties>
<property name="java.util.logging.config.file"
value="WEB-INF/logging.properties"/>
</system-properties>

<static-files>
<include path="/**.js" >
</include>
</static-files>

</appengine-web-app>

web.xml

<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<mime-mapping>
<extension>js</extension>
<mime-type>application/javascript</mime-type>
</mime-mapping>
</web-app>

the js file is still served as text/plain. you can check it on this link:

https://test4-dot-baruch-221323.appspot.com/test.js

The whole hello world project is added for your reference (attached zip
file). I deploy from within Eclipse using Eclipse GCP plugin. See below
screenshot. This was working fine before September 14 and it broke before
September 7 and September 14 -- the version of the app that was deployed on
September 7 has js files served as application/javascript where as starting
September 14 version, the same files are served as text/plain. Between
these dates, there has been no change to the build or deployment, just
modifications to the contents of static files. But we regularly update the
google cloud sdk on the deployment machine. So I suspect this is a bug
introduced in one of the sdks.

[image: screenshot.png]



- ali

On Thursday, December 6, 2018 at 8:58:50 PM UTC-5, George (Cloud Platform
Post by 'George (Cloud Platform Support)' via Google App Engine
Hello Ali,
You seem to want to deploy a Java app. If this is the case, you must put
your static served files within your app's webapp directory. After you
choose a location for the static files, you must define their location in
the appengine-web.xml file, using the <static-files> element. More detail
can be gathered from the "Getting Started: Serving Static Content"
documentation page. [1]
App Engine can serve static content such as HTML pages and media such as
images. Static content is anything that will not be executed as JSPs or
Servlets.
How do you deploy your app? Is it with gcloud app deploy, Maven, or
Gradle? A procedural description, in step-by-step fashion, would be
appreciated.
[1]
https://cloud.google.com/appengine/docs/standard/java/building-app/static-content
--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine+***@googlegroups.com.
To post to this group, send email to google-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/6dc601da-dfe3-466d-9afa-30b168034834%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
'George (Cloud Platform Support)' via Google App Engine
2018-12-07 22:18:29 UTC
Permalink
Hi Ali,

You mention Eclipse GCP plugin. Do you actually use the proper Eclipse GCP
Plugin? Do you refer to the Tools for Eclipse? If you still use the
unsupported GCP Plugin, it is advisable to migrate to the Tools, as
indicated in the "Migrating from the Google Plugin for Eclipse" online
document <https://cloud.google.com/eclipse/docs/migrating-gpe>. Results may
differ if you deploy through approved channels. If the error still
persists, we'll investigate further.
--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine+***@googlegroups.com.
To post to this group, send email to google-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/6728ab44-17a4-4596-9fa0-c218b99f5036%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Ali Koc
2018-12-08 11:59:48 UTC
Permalink
I am using the Google Cloud Tools for Eclipse -- which technically still
accessed through Eclipse plugin but I know what you mean -- there should
really be better naming for these.

For your reference, see below screenshot:

[image: eclipse.png]

At your end, are you able to:
- download latest eclipse,
- install Google Cloud Tools for Eclipse,
- create hello world application (add a dummy js file)
- deploy to app engine standard environment.

Do you js files being served as text/plain or application/javascript?

- Ali


On Friday, December 7, 2018 at 5:18:29 PM UTC-5, George (Cloud Platform
Post by 'George (Cloud Platform Support)' via Google App Engine
Hi Ali,
You mention Eclipse GCP plugin. Do you actually use the proper Eclipse GCP
Plugin? Do you refer to the Tools for Eclipse? If you still use the
unsupported GCP Plugin, it is advisable to migrate to the Tools, as
indicated in the "Migrating from the Google Plugin for Eclipse" online
document <https://cloud.google.com/eclipse/docs/migrating-gpe>. Results
may differ if you deploy through approved channels. If the error still
persists, we'll investigate further.
--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine+***@googlegroups.com.
To post to this group, send email to google-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/f2ffeb48-5256-42f6-9f07-3c0ca4215790%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...