Spring MVC + Thymeleaf java.io.IOException: The filename, directory name or volume label syntax is incorrect -
i'm building web app on spring mvc framework , using thymeleaf template engine.
i had working app before adding new rest controller. ioexception thrown
java.io.ioexception: filename, directory name or volume label syntax incorrect
java.io.ioexception: filename, directory name or volume label syntax incorrect @ java.io.winntfilesystem.canonicalize0(native method) @ java.io.win32filesystem.canonicalize(win32filesystem.java:414) @ java.io.file.getcanonicalpath(file.java:618) @ org.eclipse.jetty.util.resource.fileresource.getalias(fileresource.java:195) @ org.eclipse.jetty.server.handler.contexthandler.checkalias(contexthandler.java:1599) @ org.eclipse.jetty.server.handler.contexthandler.getresource(contexthandler.java:1583) @ org.eclipse.jetty.webapp.webappcontext.getresource(webappcontext.java:360) @ org.mortbay.jetty.plugin.jettywebappcontext.getresource(jettywebappcontext.java:338) @ org.eclipse.jetty.webapp.webappcontext$context.getresource(webappcontext.java:1325) @ org.springframework.web.context.support.servletcontextresource.geturl(servletcontextresource.java:153) @ org.springframework.web.servlet.resource.pathresourceresolver.isresourceunderlocation(pathresourceresolver.java:177) @ org.springframework.web.servlet.resource.pathresourceresolver.checkresource(pathresourceresolver.java:148) @ org.springframework.web.servlet.resource.pathresourceresolver.getresource(pathresourceresolver.java:121) @ org.springframework.web.servlet.resource.pathresourceresolver.getresource(pathresourceresolver.java:92) @ org.springframework.web.servlet.resource.pathresourceresolver.resolveresourceinternal(pathresourceresolver.java:76) @ org.springframework.web.servlet.resource.abstractresourceresolver.resolveresource(abstractresourceresolver.java:46) @ org.springframework.web.servlet.resource.defaultresourceresolverchain.resolveresource(defaultresourceresolverchain.java:57) @ org.springframework.web.servlet.resource.resourcehttprequesthandler.getresource(resourcehttprequesthandler.java:271) @ org.springframework.web.servlet.resource.resourcehttprequesthandler.handlerequest(resourcehttprequesthandler.java:208) @ org.springframework.web.servlet.mvc.httprequesthandleradapter.handle(httprequesthandleradapter.java:51) @ org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:943) @ org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:877) @ org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:966) @ org.springframework.web.servlet.frameworkservlet.doget(frameworkservlet.java:857) @ javax.servlet.http.httpservlet.service(httpservlet.java:735) @ org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:842) @ javax.servlet.http.httpservlet.service(httpservlet.java:848) @ org.eclipse.jetty.servlet.servletholder.handle(servletholder.java:684) @ org.eclipse.jetty.servlet.servlethandler.dohandle(servlethandler.java:503) @ org.eclipse.jetty.server.handler.scopedhandler.handle(scopedhandler.java:137) @ org.eclipse.jetty.security.securityhandler.handle(securityhandler.java:557) @ org.eclipse.jetty.server.session.sessionhandler.dohandle(sessionhandler.java:231) @ org.eclipse.jetty.server.handler.contexthandler.dohandle(contexthandler.java:1086) @ org.eclipse.jetty.servlet.servlethandler.doscope(servlethandler.java:429) @ org.eclipse.jetty.server.session.sessionhandler.doscope(sessionhandler.java:193) @ org.eclipse.jetty.server.handler.contexthandler.doscope(contexthandler.java:1020) @ org.eclipse.jetty.server.handler.scopedhandler.handle(scopedhandler.java:135) @ org.eclipse.jetty.server.handler.contexthandlercollection.handle(contexthandlercollection.java:255) @ org.eclipse.jetty.server.handler.handlercollection.handle(handlercollection.java:154) @ org.eclipse.jetty.server.handler.handlerwrapper.handle(handlerwrapper.java:116) @ org.eclipse.jetty.server.server.handle(server.java:370) @ org.eclipse.jetty.server.abstracthttpconnection.handlerequest(abstracthttpconnection.java:494) @ org.eclipse.jetty.server.abstracthttpconnection.headercomplete(abstracthttpconnection.java:971) @ org.eclipse.jetty.server.abstracthttpconnection$requesthandler.headercomplete(abstracthttpconnection.java:1033) @ org.eclipse.jetty.http.httpparser.parsenext(httpparser.java:644) @ org.eclipse.jetty.http.httpparser.parseavailable(httpparser.java:235) @ org.eclipse.jetty.server.asynchttpconnection.handle(asynchttpconnection.java:82) @ org.eclipse.jetty.io.nio.selectchannelendpoint.handle(selectchannelendpoint.java:696) @ org.eclipse.jetty.io.nio.selectchannelendpoint$1.run(selectchannelendpoint.java:53) @ org.eclipse.jetty.util.thread.queuedthreadpool.runjob(queuedthreadpool.java:608) @ org.eclipse.jetty.util.thread.queuedthreadpool$3.run(queuedthreadpool.java:543) @ java.lang.thread.run(thread.java:745)
it's happening when browser attempts fetch css, js or other static resources taoconnection-servlet.xml. same occurs on both jetty , tomcat7 deployments. after couple of hours searching can't find similar problem.
edit: i'm making call /account request mapping happens request mapping access static resources. if try access resources directly in browser e.g. http://localhost:8080/css/bootstrap.min.css or http://localhost:8080/js/sb-admin-2.js exception thrown.
alternatively if try access fake resource e.g. http://localhost:8080/js/fake.js still standard http 404 expected ioexception not thrown.
project structure
-src -main -java -*controller -maincontroller.java -restaccountcontroller.java -resources -meta-inf -spring -applicationcontext.xml -webapp -css -font-awesome-4.1.0 -js -less -pages -web-inf -taoconnection-servlet.xml -web.xml
taoconnection-servlet.xml
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> <import resource="classpath*:meta-inf/spring/applicationcontext*.xml" /> <context:component-scan base-package="com.quadrimular.nts.results.connection.*" /> <context:component-scan base-package="com.quadrimular.nts.results.connection" /> <mvc:annotation-driven/> <mvc:resources mapping="/css/**" location="/css/**" /> <mvc:resources mapping="/js/**" location="/js/**" /> <mvc:resources mapping="/font-awesome-4.1.0/**" location="/font-awesome-4.1.0/**" /> <mvc:resources mapping="/pages/**" location="/pages/**" /> <bean id="templateresolver" class="org.thymeleaf.templateresolver.servletcontexttemplateresolver"> <property name="prefix" value="/pages/" /> <property name="suffix" value=".html" /> <property name="templatemode" value="html5" /> <property name="cacheable" value="false" /> </bean> <bean id="templateengine" class="org.thymeleaf.spring4.springtemplateengine"> <property name="templateresolver" ref="templateresolver" /> </bean> <bean class="org.thymeleaf.spring4.view.thymeleafviewresolver"> <property name="templateengine" ref="templateengine" /> <property name="order" value="1" /> </bean> <!-- configure plugin json request , response in method handler --> <bean class="org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter"> <property name="messageconverters"> <list> <ref bean="jsonmessageconverter"/> </list> </property> </bean> <!-- configure bean convert json pojo , vice versa --> <bean id="jsonmessageconverter" class="org.springframework.http.converter.json.mappingjackson2httpmessageconverter"></bean> </beans>
maincontroller.java
package com.quadrimular.nts.results.connection.controller; import org.springframework.beans.factory.annotation.autowired; import org.springframework.stereotype.controller; import org.springframework.ui.modelmap; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.requestmethod; import com.quadrimular.fyfe.fulfillment.service.accountservice; @controller public class maincontroller { @autowired private accountservice accountservice; @requestmapping(value = "/account", method = requestmethod.get) public string getallaccounts(modelmap model){ try{ model.addattribute("accountlist", accountservice.getallaccounts()); }catch(exception e){ model.addattribute("error", true); model.addattribute("errmsg", e.getmessage()); } return "account"; } @requestmapping(value = "/main", method = requestmethod.get) public string main(modelmap model){ return "main"; } @requestmapping(value = "/account", method = requestmethod.put) public string addaccount(modelmap model){ return "account"; } }
restaccountcontroller.java
package com.quadrimular.nts.results.connection.controller; import java.util.list; import org.springframework.beans.factory.annotation.autowired; import org.springframework.http.httpstatus; import org.springframework.web.bind.annotation.exceptionhandler; import org.springframework.web.bind.annotation.requestbody; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.requestmethod; import org.springframework.web.bind.annotation.responsestatus; import org.springframework.web.bind.annotation.restcontroller; import com.quadrimular.fyfe.fulfillment.account; import com.quadrimular.fyfe.fulfillment.service.accountservice; @restcontroller @requestmapping(value = "/api") public class restaccountcontroller { accountservice accountservice; @autowired public restaccountcontroller(accountservice accountservice){ this.accountservice = accountservice; } @requestmapping(value="/account", method= requestmethod.get, headers = "accept=application/json") public list<account> getallaccounts(){ list<account> accounts = accountservice.getallaccounts(); return accounts; } @requestmapping(value="/account", method=requestmethod.post, headers = "accept=application/json") public account addaccount(@requestbody account act) throws exception{ return accountservice.addaccount(act); } @exceptionhandler(exception.class) @responsestatus(value = httpstatus.bad_request) public string handleexception(exception e) { return "error: " + e.getmessage(); } }
web.xml
<?xml version="1.0" encoding="iso-8859-1" standalone="no"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" version="3.0" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <servlet> <servlet-name>taoconnection</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>taoconnection</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app>
try this:
<mvc:resources mapping="/css/**" location="/css/" /> <mvc:resources mapping="/js/**" location="/js/" /> <mvc:resources mapping="/font-awesome-4.1.0/**" location="/font-awesome-4.1.0/" /> <mvc:resources mapping="/pages/**" location="/pages/" />
Comments
Post a Comment