airavata-courses / TeamZenith

Team Zenith Repository for Spring 2016 I590 Class
2 stars 4 forks source link

Maven buildpath #5

Closed anujbhan closed 8 years ago

anujbhan commented 8 years ago

Maven build not recognizing the file path in resources directory.

  1. The issue seems naive but has forced us to rethink our design choice of not using the a framework, ex: Java Spring.
  2. To summarize by examples,
    • As suggested by instructors, we have created a resource directory "src/main/resources".
    • we are unable to work with directory paths, URL url = this.getClass().getResource("/keyFile.ppk"); Error : FileNotFoundException
    • By some research on web, we found a way to bypass this and rather use InputStream is = this.getClass().getResourceAsStream("/KeyFile.ppk");
    • The above method is working just fine, if we are reading a file from resource director, But a part of our code generates the pbs.sh script file on the fly, for which we have to provide the directory address for file creation, Unless the directory path is accessible, this is not possible. We have already made a lot changes to our code design to incorporate these changes, But any further change would break the design and which will be a hit to sustainable code.
  3. If we stick to just meeting the goals of the assignment, we have drop quite a few design features. Time is flying , we have to submit the assignment by tomorrow.
arpiagariu commented 8 years ago

Few points :

  1. There is this class in Jsch api - Util.class which uses FileInputStream to open a file which indeed is causing the problem. So when we are doing jsch.addIdentity(privateKeyPath) this class(Util.class) is used.

image image

  1. Can we use another build tool like Ant or it won't help ??

Please let me know what I can do from my side.

anujbhan commented 8 years ago

I have managed to bypass that above stated problem by using this.getClass().getResourceAsStream()

Now the problem is generating scripts, I am unable to create new script files in "src/main/resource' folder.

marpierc commented 8 years ago

Your example MavenTest works for me, so I'm not sure what problem you are reporting.

You should be careful about the Java IO methods you are using and why. Some look for files in the classpath and some look in the regular file system. Your example, as you know, needs a full file system path.

a2l007 commented 8 years ago

Hello Marlon, I've made some additional changes in the Manager.java file to include file write operation to the resource file. Would you be able to check if this prints the output that is being written to the file?

a2l007 commented 8 years ago

We have modified our design such that the user needs to specify the directory in the filesystem where the config files would be copied. We had earlier attempted to package the config files in the jar in the previous design.

marpierc commented 8 years ago

That's fine. Remember the main goal of the assignment. If I have to edit a property file or config file, that is not a problem.