-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I am new to ZK. We will use Zk + Spring Boot in our new project. For convenience, I prefer to run web application directly from eclipse/sts (spring tool suites).
Issue:
In Windows OS, when running Zk + Spring Boot application (github.com/zkoss-demo/zk-spring-boot) using STS, I encounter error "Problems encountered while deleting resources." after I modified a ZUL file (that has been viewed previously). When this happens, i have to stop the server and clean up the project.
(I tested that there is no issue when running normal Zk application in STS.)
Finding:
After some troubleshooting, I found that the zul files are locked from deletion by method getLastModified(..) in ExtendletLoader and ResourceLoader. sun.net.www.protocol.file.FileURLConnection implicitly open input stream when getting the last modified date and hence lock the file in Windows OS. I read from other forum that to workaround this issue, the input stream need to be explicitly closed.
/** Returns the last modified time.
*/
public long getLastModified(String src) {
if (getCheckPeriod() < 0)
return 1; //any value (because it is not dynamic)
try {
final URL url = getExtendletContext().getResource(src);
if (url != null) {
URLConnection urlConnection = url.openConnection();
try {
final long v = urlConnection.getLastModified();
return v != -1 ? v : 0; // not to reload (5.0.6 for better performance)
} finally {
try {
InputStream inputStream = urlConnection.getInputStream();
inputStream.close();
} catch (IOException ioe) {
}
}
}
} catch (Throwable ex) {
}
return -1; //reload (might be removed)
}
I patched the zweb-8.5.0.jar and it resolved the issue. This post may help whoever interested in using zk + spring boot for development.
(for normal Zk application, src.url is null. So the file last modified data is accessed though src.file.lastModified(). I guess that as spring boot has unique package (jar), its resource loader is different.)
thanks for mentioning the problem and patch. Since we are trying to improve the spring boot support I created a JIRA ticket here: http://tracker.zkoss.org/browse/ZK-3973
In case you have additional resource links regarding this issue, please add them here or to the JIRA ticket directly.
Another occasion for this problem I encountered was related to Jetty and the workaround for development was setting a specific jetty init parameter like this:
https://github.com/zkoss-demo/zk-gradle/blob/master/jetty-dev-context.xml#L30
Robert
UPDATE: ZK-3973 will be fixed in 8.5.2 (testable in 8.5.2.FL.20180628-(Eval))
I've read the book and really enjoyed it.
Asked: 2018-06-11 11:24:30 +0800
Seen: 16 times
Last updated: Aug 13 '18
Zk + Spring Security redirect to strange page after login
ZK Spring webflow and flowScope
Spring security doesn't return user inside event listener
ZK Spring 3.1.1 MVVM Use @Scope/@Component or No?
Upgrading from Spring3.1 to 3.1.1 Maven.. pulls in 3.0.x jars... issues
When would I want to use ThreadLocalListener?
ZKoss with springsecurity using database