0

MuleSoft : Unable to locate file when code moved to CloudHub. Could someone please help. I have read you recommendation but not able to understand that. I have to read one json file in cloudhub. In my local repositories I have kept the .json file in location test/src/main/resources/input.json. And reading this from Java Class

private static final String jsonFilePath = "src\main\resources\input.json";

byte[] jsonFile = Files.readAllBytes(Paths.get(jsonFilePath));

Any help will be appreciated.

Nilesh Kumar
  • 35
  • 1
  • 5

1 Answers1

1

"src/main/resources" is something that you will find in Anypoint Studio only. Since that folder is marked as a source folder, anything that is placed in that folder will be exported at the root of your classpath. To fix this issue simply remove the "src/main/resources" part of your variable.

So the 'jsonFilePath' variable should be:

private static final String jsonFilePath = "input.json"

This should work in Anypoint Studio and CloudHub without any problems.

HTH,

Justin

justin.saliba
  • 724
  • 1
  • 9
  • 17
  • I have moved my "input.json" file in root directory of my project. And changed my jsonFilePath as below String jsonFilePath = "input.json"; I am successfully able to run the code in my local system and getting the response. But when I moved the project Mule Deployable Archive to Cloudhub , it is not able to search the "input.json" file and I am not getting the response. Please reply if you need any more input from my side – Nilesh Kumar May 26 '15 at 14:32
  • Have you tried leaving the file in src/main/resources and simply changing the value of the jsonFilePath variable? – justin.saliba May 26 '15 at 16:32
  • Yes, Justin. I have tried as per your suggestion. But not able to find the input.json file when *MDA* moved to cloud hub and I am getting file not found exception in cloudhub. when I printed all my files in my project directory, I am not able to search any specific files from my project in cloudHub. It seems I am missing some fundamental structure of project when MDA moved to cloud. One more question how can I deploy MDA zip file to my local server such Tcat.? Your help will be appreciated... – Nilesh Kumar May 27 '15 at 02:04