Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot save .html file in eclipse

I'm working on a javascript project in eclipse. The static html and javascript files need to access my service's restful end points, so I put those in the java project with those end-points, so I could access them without cross domain issues.

All of a sudden, though, if I try to save a change to my html file, I can't unless I stop the java application from running.

The sequence of events is like this:

Run java web app with Jetty

Can save changes to html file.

Open html file in chrome with url: http://127.0.0.1:8901/myapp/myapp-admin.html

Cannot save changes to html file.

Close chrome.

Still can't save changes.

Stop jetty running in eclipse.

Can save changes.

When I try to save it gives the following error:

Save could not be completed. Try File > Save As... if the problem persists.

Reason:
Could not write file:
C:\{path to file}\myapp-admin.html

(The requested operation cannot be performed on a file with a user-mapped section open)

If I try to use save as to overwrite that file, it still does not work, with the error:

Save could not be completed. Could not write file: {etc.}

Here's the html file:

<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>


<title>myapp Admin</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
    <h1>myapp</h1>

</body>
</html>

The only thing I changed was how these were mapped in the web.xml. Basically, before I was rendering them the spring-way using a spring controller, etc.

Now I'm rendering them statically, using:

<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.html</url-pattern>
    <url-pattern>*.js</url-pattern>
    <url-pattern>*.css</url-pattern>
</servlet-mapping>

But I don't know why that would cause this kind of issue.

Spring is mapped like so:

<!-- Declare a Spring MVC DispatcherServlet as usual -->
<servlet>
    <servlet-name>spring</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <!-- Configure DispatcherServlet to use AnnotationConfigWebApplicationContext 
        instead of the default XmlWebApplicationContext -->
    <init-param>
        <param-name>contextClass</param-name>
        <param-value>
          org.springframework.web.context.support.AnnotationConfigWebApplicationContext
      </param-value>
    </init-param>
</servlet>

<servlet-mapping>
    <servlet-name>spring</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>
<session-config>
    <session-timeout>
        30
    </session-timeout>
</session-config>

Can anyone help me figure out what's wrong here, and if there's a way to get it working like I want it to?

like image 906
CorayThan Avatar asked Jul 12 '26 08:07

CorayThan


1 Answers

You are experiencing the classic file locking issue on Windows. (this does not occur on any flavor of unix, linux, or osx)

Try following the guidelines in the troubleshooting locked files on windows to disable the advanced performance features of Jetty for your specific webapp.

(linking to the Jetty 9 Documentation, since you didn't specify which version of Jetty you are using)

like image 53
Joakim Erdfelt Avatar answered Jul 15 '26 00:07

Joakim Erdfelt