Hello everyone, I am pretty new with Jackrabbit, so kindly excuse me if something does not make sense. I am trying to save an excel file that a user uploads using a web browser, but i am getting an error "*javax.jcr.pathnotfoundexception" * When I try the class alone to upload the file from a specific location in the disk it works. When I try to upload the file from the browser to a disk , it still works.
But when I combine both of them together it does not work. I really appreciate if someone could help me. I have attached the servlet code below for the reference public class FileUp extends HttpServlet { private static final long serialVersionUID = 1L; public String Client; String clientName=""; public static String grid_version="success"; public FileUp() { super(); } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub System.out.println("Hello"); boolean isMultipart = ServletFileUpload.isMultipartContent(request); if(!isMultipart) { } else { //Vector v = new Vector(); FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); List items = null; try { items = upload.parseRequest(request); System.out.println(items); } catch (FileUploadException e) { e.printStackTrace(); } Iterator itr = items.iterator(); while (itr.hasNext()) { FileItem item = (FileItem) itr.next(); if (item.isFormField()) { String fieldName = item.getFieldName(); String value = item.getString(); //v.add(value); System.out.println("Form value "+value); } else { try { //String itemName =request.getParameter("frmpnlNewFormpanel"); String itemName = item.getName(); System.out.println("this is Item name"+itemName); File savedFile = new File("E:\\16_nov\\TrafficSoftware\\repository\\workspaces\\eFerns new traffic\\"+itemName); item.write(savedFile); System.out.println("You file has been saved at the loaction:"+savedFile.getName()); System.out.println(itemName); /*-----------saving cods to jack-------*/ Repository masterRepository = new TransientRepository(); Session session = masterRepository.login(new SimpleCredentials("username", "password".toCharArray())); try { Node root = session.getRootNode(); /*-----------saving cods to jack-------*/ String fileName = "traffic.xlsx"; InputStream fileStream = new FileInputStream("E:\\16_nov\\TrafficSoftware\\repository\\workspaces\\eFerns new traffic\\traffic.xlsx"); Node folder = session.getRootNode(); Node upld=folder.getNode("Traffic Software").getNode("Client Node").getNode("Bookings"); Node file = upld.addNode(fileName, "nt:file"); Node resNode = file.addNode ("jcr:content", "nt:resource"); file.addMixin(JcrConstants.MIX_VERSIONABLE); Node fileContent = file.getNode("jcr:content"); fileContent.setProperty("jcr:data", fileStream); session.save(); System.out.println("Files are saved :"+fileContent.getProperty("jcr:data")); /* Node sesion=root.getNode("Traffic Software").getNode("Client Node").getNode("Bookings").getNode("Original"); sesion.setProperty ("jcr:data",fileStream); //System.out.println("Current "+ sesion.getProperty("curntsession").getString()); System.out.println("Current "+ sesion.getPath()); System.out.println("Current "+ sesion.getProperty("jcr:data").getStream()); */ } finally { session.logout(); } /*-----------saving cods to jack-------*/ } catch (Exception e) { e.printStackTrace(); } } } } } }