My web application has a feature of uploading PDF files to the web that is executed the following proccess:
Create a folder which path is C:/resource/pdf/
Then write a PDF inside the folder
Is it possible for a web application to create a folder then write a PDF file inside it? I tried this and it is working perfectly fine, on my local. But when I deployed the app in the web ( free hosting ) there is an error:
java.io.FileNotFoundException: C:/resource/pdf/Daily News.pdf (No such file or directory)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at com.neu.als.thesis.web.controllers.UploadController.writeFile(UploadController.java:129)
at com.neu.als.thesis.web.controllers.UploadController.uploadPDF(UploadController.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
I know lines 129 and 71. I tested it again in my eclipse and it is working. Is there any restriction on web application when it is deployed or anything similar that preventing me to create a folder?
Depending on your permissions on the server and who's account the server is running under, you may not have permissions to write to that directory. Typically, the safe bet for saving a file to the server locally is to create a temp directory or something inside of your apps directory structure to put the files in. You should have permission to write to that directory as long as it's in your apps file structure.
Related
I am using ImageMagick to crop image file. I am deploying packed WAR with ImageMagick inside. searchForCmd() function of ProcessStarted class is unable to find the files of ImageMagick from WEB-INF/classes i.e.
file:/D:/Project/build/libs/proj-0.0.1-SNAPSHOT.war!/WEB-INF/classes!/ImageMagick-6.6.1-5
how can I access the convert.exe in packed war .
Below is the stacktrace.
org.im4java.core.CommandException: java.io.FileNotFoundException: convert
at org.im4java.core.ImageCommand.run(ImageCommand.java:219)
at com.os.util.helper.ImageCropHelper.cropImageByImageMagic(ImageCropHelper.java:316)
at com.os.util.helper.ImageCropHelper.cropImage(ImageCropHelper.java:375)
at com.os.action.UserAction.mntnUserAvatar(UserAction.java:2566)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:899)
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1544)
at ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:68)
at com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethodWithDebugInfo(XWorkMethodAccessor.java:96)
at com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethod(XWorkMethodAccessor.java:88)
at ognl.OgnlRuntime.callMethod(OgnlRuntime.java:1620)
at ognl.ASTMethod.getValueBody(ASTMethod.java:91)
at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
at ognl.SimpleNode.getValue(SimpleNode.java:258)
at ognl.Ognl.getValue(Ognl.java:470)
at ognl.Ognl.getValue(Ognl.java:434)
WARs normally do no contain EXEs. If you have dependencies on external applications, they must be installed on the server (or in the container) where the WAR is deployed. Also consider that your Springboot can normally run on a Linux or a Windows server and the IM executable would be different for each...
I'm loading a Property file with the following method:
private final String utitt=Paths.get(".").toAbsolutePath().normalize().toString();//
...
properties.load(new FileInputStream(utitt+"/beallitasok/lang.set"));
...
This works fine within NetBeans without problems, but the jar file fails in command prompt:
java.io.FileNotFoundException: C:\java\IKE\dist\beallitasok\lang.set
(A rendszer nem találja a megadott fájlt)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(Unknown Source)
at java.io.FileInputStream.(Unknown Source)
at java.io.FileInputStream.(Unknown Source)
at IKE.IKE.fordit(IKE.java:1519)
at IKE.IKE.access$300(IKE.java:81)
at IKE.IKE$IngatlanokAblak.(IKE.java:9411)
at IKE.IKE.(IKE.java:544)
at IKE.IKE.main(IKE.java:697)
I've copied the "beallitasok" directory there (to c:\java\IKE\dist in my case), so the file is actually there. I'm using some files to translate certain strings and save/read some settings. I've checked whether i'm just blind, so just opened the file with a "more C:\java\IKE\dist\beallitasok\lang.set" command and it works.
Where or how shall i search for a clue? I'm not a pro, so thanks for any help.
PS: (A rendszer nem találja a megadott fájlt) = The System can't find the specified file. Translated from the Hungarian language.
I went through 'Getting Started with Red App Development'. Looks like the Red App cab be run in Sandbox mode when neither CERT nor PROD environment is accessible. We are in the process to get the login credential for CERT and PROD environment. Meanwhile, I wanted to run the RedApp product in the Sandbox mode.
Per the ‘Getting Started with Red App Development’ document, added the following VM argument to the run environment:
Dredapp.fake.session=true
Ran the RedApp product, but could not get through the VPN login page.
I found following exceptions in the log :
SEVERE: Exception occured during copying 'hssp-mapping_SVPNMapping_HSSP_sabre.com.properties' file to the workspace
java.io.FileNotFoundException: C:\Users\jjha\.jsapi\hssp-mapping_SVPNMapping_HSSP_sabre.com.properties (The system cannot find the path specified)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
SEVERE: Exception occured during copying 'hssp-mapping_SVPNMapping_HSSP_sabre.com.properties' file to the workspace
java.io.FileNotFoundException: C:\Jay\runtime-RedAppRun\emulator_files\hostinfo_svpn.txt (The system cannot find the path specified)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
What is the fix for the above issues/exceptions?
Have you tried clicking on the Validate Plugins option, from the Plugins Tab?
http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.pde.doc.user%2Fguide%2Ftools%2Flaunchers%2Fplugins.htm
Below is the fix for the issue:
Launch the Red App
click tools->Options->Sabre System>Connection, and select 'Private network' instead of 'SSL VPN'
I deployed my play framework 2.1 application on appfog(same issue also exists on cloudfoundry since they are essentially the same). My application allow file upload, but I have encountered an error getting the file. It works fine when I run locally with play run.
My code is as follows:
MultipartFormData body = request().body().asMultipartFormData();
FilePart midi = body.getFile("midi");
File file = midi.getFile();
The error message in log is:
play.api.Application$$anon$1: Execution exception[[IOException: No such file or directory]]
at play.api.Application$class.handleError(Application.scala:289) ~[play.play_2.10-2.1.0.jar:2.1.0]
at play.api.DefaultApplication.handleError(Application.scala:383) [play.play_2.10-2.1.0.jar:2.1.0]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$handleAction$1$4$$anonfun$apply$28.apply(PlayDefaultUpstreamHandler.scala:391) [play.play_2.10-2.1.0.jar:2.1.0]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$handleAction$1$4$$anonfun$apply$28.apply(PlayDefaultUpstreamHandler.scala:391) [play.play_2.10-2.1.0.jar:2.1.0]
at scala.Option.map(Option.scala:145) [org.scala-lang.scala-library-2.10.0.jar:na]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$handleAction$1$4.apply(PlayDefaultUpstreamHandler.scala:391) [play.play_2.10-2.1.0.jar:2.1.0]
Caused by: java.io.IOException: No such file or directory
at java.io.UnixFileSystem.createFileExclusively(Native Method) ~[na:1.7.0_11]
at java.io.File.createTempFile(Unknown Source) ~[na:1.7.0_11]
at java.io.File.createTempFile(Unknown Source) ~[na:1.7.0_11]
at play.api.libs.Files$TemporaryFile$.apply(Files.scala:60) ~[play.play_2.10-2.1.0.jar:2.1.0]
at play.api.mvc.BodyParsers$parse$Multipart$$anonfun$handleFilePartAsTemporaryFile$1.apply(ContentTypes.scala:624) ~[play.play_2.10-2.1.0.jar:2.1.0]
at play.api.mvc.BodyParsers$parse$Multipart$$anonfun$handleFilePartAsTemporaryFile$1.apply(ContentTypes.scala:622) ~[play.play_2.10-2.1.0.jar:2.1.0]
It looks like that it's having problem creating a temporary file from the multipartForm. Is there a good way to solve this? My application is stored on AWS, configured through appfog.
I been working on this Servlet project all morning and now suddenly I cannot get eclipse to export the project to a war file. I tried restarting eclipse and cleaning the project but I just get the same result. Any ideas?
org.eclipse.core.runtime.CoreException: Extended Operation failure:
org.eclipse.jst.j2ee.internal.web.archive.operations.WebComponentExportOperation
at org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizard.performFinish(DataModelWizard.java:182)
at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:742)
at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:373)
at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:618)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:227)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:820)
at org.eclipse.jface.window.Window.open(Window.java:796)
at org.eclipse.ui.actions.ExportResourcesAction.run(ExportResourcesAction.java:180)
at org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerAction.java:168)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:546)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:490)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:402)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
org.eclipse.core.runtime.CoreException[0]: org.eclipse.core.commands.ExecutionException: Error exportingWar File
at org.eclipse.jst.j2ee.internal.archive.operations.J2EEArtifactExportOperation.execute(J2EEArtifactExportOperation.java:103)
at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl$1.run(DataModelPausibleOperationImpl.java:376)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1797)
at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.runOperation(DataModelPausibleOperationImpl.java:401)
at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.runOperation(DataModelPausibleOperationImpl.java:352)
at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.doExecute(DataModelPausibleOperationImpl.java:242)
at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.executeImpl(DataModelPausibleOperationImpl.java:214)
at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.cacheThreadAndContinue(DataModelPausibleOperationImpl.java:89)
at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.execute(DataModelPausibleOperationImpl.java:202)
at org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizard$1$CatchThrowableRunnableWithProgress.run(DataModelWizard.java:211)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:113)
Caused by: org.eclipse.jst.j2ee.commonarchivecore.internal.exception.SaveFailureException: IWAE0017E Unable to replace original archive: C:\Users\mark\uploads\myfirstjsp.war
at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.ArchiveImpl.cleanupAfterTempSave(ArchiveImpl.java:322)
at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.ArchiveImpl.saveAsNoReopen(ArchiveImpl.java:1182)
at org.eclipse.jst.j2ee.internal.web.archive.operations.WebComponentExportOperation.export(WebComponentExportOperation.java:54)
at org.eclipse.jst.j2ee.internal.archive.operations.J2EEArtifactExportOperation.execute(J2EEArtifactExportOperation.java:95)
... 10 more
Well I guess I should have read the whole error as it does say that the problem is it can't write to the file. The interesting part was what was causing the file to be locked. Firefox had the file open so eclipse couldn't write to the file. I have no idea why firefox had the file open though I was using it to upload the war file to the server.