java


java.lang.NoSuchMethodException: java.io.File.<init>()


I have used the code in Read all files in a folder. But when I try to implement the code, it gives me an error - java.lang.NoSuchMethodException: java.io.File.()
Stack Trace:
java.lang.NoSuchMethodException: java.io.File.<init>()
at java.lang.Class.getConstructor0(Class.java:3082)
at java.lang.Class.getDeclaredConstructor(Class.java:2178)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:105)
at
org.springframework.web.method.annotation.ModelAttributeMethodProcessor.createAttribute(ModelAttributeMethodProcessor.java:138)
at org.springframework.web.servlet.mvc.method.annotation.ServletModelAttributeMethodProcessor.createAttribute(ServletModelAttributeMethodProcessor.java:81)
at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:104)
at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:79)
at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:157)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:124)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:683)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1720)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1679)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
I have searched for long.. Most of answers were about setting up a default constructor. But in my case, the file doesnt have a default constructor. I may be looking at this completely wrong.. So here's hoping some one can help me out..
Thanks in advance :)
Code:
#RequestMapping(value="/retrieve", method=RequestMethod.POST)
public ArrayList<String> listFiles() {
ArrayList<String> listOfFiles =new ArrayList<String>() ;
File folder = new File("E:/uploadedFiles/");
File[] files = folder.listFiles();
for (File file : files) {
if (file.isFile()) {
System.out.println(file.getName());
listOfFiles.add(file.getName());
}
}
return listOfFiles;
}

Related Links

Tomcat is not loading new class(compiled version of .java file and not JSP file)
What does this string refer to in the X500Principal constructor?
Java Process management
Spring MVC : Return CSS
Having Trouble Getting a Array to read my text file
How use GSON when JSON doen't have “Name attribute”?
How to close this JavaFX application after showing a message in a text area element
How to stream a JSON object to a HttpURLConnection POST request
How do I get the constructor of a variable?
Problems reading data into an array list from a file in Java
Convert List<Long> to Map<Long, Long> that counts occurrences
Info card prioritizing -java flash card applet
Traffic light application: Implementing ActionListener in its own class
What Java Collection should I use?
how to avoid pressing several time enter affects the input data?
scanner class error while producing an output text file

Categories

HOME
clips
asp.net-core
single-sign-on
lodash
spagobi
read-eval-print-loop
setup-deployment
spring-jdbc
leon
rubygems
electronics
convolution
synchronization
slurm
maude-system
tomcat6
node-pdfkit
modx-revolution
windows-azure-storage
quickfix
clojurescript
opentracing
highlight.js
database-replication
viewport
karma-jasmine
reverse-proxy
scriptcs
google-search-api
kudan
blazemeter
su
apache-commons-io
react-css-modules
social-media
strncpy
facebook-apps
large-file-upload
primitive
skia
yadcf
jspresso
google-qpx-express-api
noraui
lxd
overriding
devextreme
main
dosbox
sharefile
vapor
hilbert-curve
businessworks
hibernate-tools
tropo
nodebb
pg-dump
knpmenubundle
imanage
spring-cache
chord-diagram
heidisql
httplistener
bluegiga
ipconfig
kendonumerictextbox
separator
kcachegrind
embedded-code
drawbitmap
cakephp-3.1
cisco-ios
typekit
socketexception
heisenbug
jubula
expected-exception
pyhdf
oam
farseer
file-locking
shellexecute
android-screen-support
kyotocabinet
itmstransporter
chuck
viewswitcher
online-compilation
jquery-ui-layout
spring-portlet-mvc
asyncfileupload
netdna-api
libc++
external-accessory
hirefire
xmemcached
self-extracting
icanhaz.js
mozilla-prism
routedevent
firefox4
libs
zune
rtml
caching-application-block

Resources

Encrypt Message