nus-cs2103-AY1718S2 / forum

0 stars 1 forks source link

Issue with running MainApp.main() #34

Closed ghost closed 6 years ago

ghost commented 6 years ago

Hi, anyone also having issue with this NullPointerException "input stream must not be null" being thrown when you try to run MainApp.main()??

image

It's weird because my ICON_APPLICATION should be pointing correctly to the relative path of address_book_32.png which is /images/address_book_32.png (I also checked and verified that file is indeed under src\main\resources\images.

image

And moreover please refer to this link: https://github.com/nus-cs2103-AY1718S2/addressbook-level4/blob/master/src/main/resources/images/address_book_32.png

Any help would be appreciated! Thank you very much! :)

Zhiyuan-Amos commented 6 years ago

Upstream dev here. I sometimes get this too, I think deleting the repo and re-cloning it should do the trick.

Edit: maybe try running gradlew processResources? I can't exactly remember how I fixed this, but this was something I recall that I tried doing

ghost commented 6 years ago

Hi I tried the gradlew processResources but it still does not work (edit: actually it solves the "input stream must not be null" problem but another problem now in other areas of the project).

image

I think there was a former issue similar to this which was created before? I will go check it out!

Just checking, run/debug configurations for the MainApp should be like this below right? image

Should the classpath of the module be main, GitHub-main or main_main? image

The folder I put all my GitHub projects is called "GitHub" i.e. inside contains addressbook-level1, addressbook-level2, addressbook-level3. I named the repo of my addressbook-level4 as "main" and I put that inside a folder called "main" inside too. image

image

Zhiyuan-Amos commented 6 years ago

I'll let someone else reply for this issue :p

ghost commented 6 years ago

Actually the "input stream must not be null" issue is still there even after gradlew processResources

Zhiyuan-Amos commented 6 years ago

Have you tried deleting your project and re-cloning it?

ghost commented 6 years ago

You mean deleting my local "main" repo which is a clone of the forked remote "main" repo (which is on my GitHub profile) which is forked from the upstream aka AY1718S2-address book level 4 only?

Or delete my remote fork even too?

(I am scared that if I have to delete my remote fork, previous commits I made to my group's project and shown in the PR of our group to the level 4 address book, they will say they are commits from an "unknown repo")

Zhiyuan-Amos commented 6 years ago

Ok I've taken a further look into this issue, so you also need address_book_32.png in addressbook-level4\out\production\resources\images.

I forgot how to generate it automatically, but I'll take a look into it :) One way is to simply delete the addressbook-level4\out folder, and just run the app again, it will auto-generate the folder with address_book_32.png inside.

This method is easier than deleting your project :P

Edit: The out folder is generated by IntelliJ. I think when IntelliJ first builds your project (i.e. the out folder does not yet exist), IntelliJ will generate the out folder.

ghost commented 6 years ago

Hi Amos,

Okay that does make sense. I will try that out soon later as my laptop is not currently at my side.

Hoping to share good news soon! 🙂

ghost commented 6 years ago

Hmm,

I've done what you said and it doesn't seem to solve the issue. One thing I didn't do after that was the graddlew processResources though.

Perhaps deleting my local repo and recloning it from my remote on my GitHub account is the only way now? (with necessary setup settings such as the aforementioned gradlew processResources too and etc)

image

ghost commented 6 years ago

This is how the contents inside the generated out folder looks like (there isn't even an image folder generated inside main\out\production\main\seedu\address):

image

image

Zhiyuan-Amos commented 6 years ago

You went to out\production\main, but it should be out\production\resources\images. I'm using a Mac though, not sure whether it affects the directory. Can you check if out\production\resources\images exists for you?

Perhaps deleting my local repo and recloning it from my remote on my GitHub account is the only way now? (with necessary setup settings such as the aforementioned gradlew processResources too and etc)

Yup, this is the worst case scenario I guess. :(

ghost commented 6 years ago

Good evening Amos,

In reply to your question, there is no out\production\resources\images folder at all and only out\production\main i.e. there is only a main folder inside out\production but no resources folder inside for some weird reason, after I ran MainApp.main() in IntelliJ IDEA.

image

Maybe I will just do the worst-case scenario solution if all else fails, haha..

ghost commented 6 years ago

Hi,

I have deleted and re-cloned my local repo.

Call me noob, but I realize there is no out\production folder in the first place when I cloned the remote from GitHub XD This is how it looks like (when I have not ran the MainApp.main() yet)

image image

Build was successful also when I ran the command gradlew clean checkstyleMain checkstyleTest headless allTests coverage coveralls asciidoctor in terminal too :)

image

Next step is to actually try running MainApp.main() to see if the AddressBook can open up as intended

EDIT: I realized, by default, when you have not ran a project yet, the edit configurations will look like this when you open it up: image image

so yeah... even though I guess I am learning a bit slow, I still learn more and more things every time! =)

Zhiyuan-Amos commented 6 years ago

@HEARTOFAL1ON I'll try running on my Windows PC and see how my out directory looks like.

there is no out\production folder in the first place when I cloned the remote from GitHub XD

That's right, the folder is only created when IntelliJ builds your project. IntelliJ uses the files in the out folder for the program execution. Gradle doesn't create the out folder and the files inside the out folder because it doesn't use it for program execution I think.

ghost commented 6 years ago

GOOD NEWS!!

IT WORKS AS INTENDED!

image

I think this issue may be closed now. Thank you so much for your help rendered so far!

Yes, maybe this is a funny bug which even upstream developers like yourself occur! Haha.. Or maybe I used the wrong term, maybe not bug but glitch or whatever instead?

P.S. If there are any further issues (that are not specific to my project and require downstream developers i.e. my team members and myself) to debug ourselves, there is no harm raising issues in this forum right? :):)

I'll try running on my Windows PC and see how my out directory looks like.

wow @Zhiyuan-Amos you must be very proficient to be able to alternate between both Windows and Mac efficiently, HAHA..

Zhiyuan-Amos commented 6 years ago

Yay great!!! ^^ Can you check if you have the directory out\production\resources\images?

P.S. If there are any further issues (that are not specific to my project and require downstream developers i.e. my team members and myself) to debug ourselves, there is no harm raising issues in this forum right? :):)

Haha idk, I'm not a TA :p I'm just a student taking CS3282 and working on AddressBook-Level4 now.

even though I guess I am learning a bit slow, I still learn more and more things every time! =)

Haha yup, after working on this project for quite some time, there's still bugs / glitches like this one that you raised that I still don't know how to resolve XD

ghost commented 6 years ago

I'm just a student taking CS3282

Wow, what mod is that? checks NUSMods I'm not a computing/infosec student so yeah ><. Don't ever have to take such high level CS mod, HAHA..

But other faculties one, have to lah... :/ OH WELL, such is life man.... =)

Actually is it okay to sometimes have casual convos like this even on a particular issue in this forum? Hahaha... Yeah, maybe someone like Akshay close this issue soon :)

Zhiyuan-Amos commented 6 years ago

Wow, what mod is that?

It's the follow-up Software Engineering module from CS2103, so if you have UEs, you can try taking this mod :)

Actually is it okay to sometimes have casual convos like this even on a particular issue in this forum?

You are the first to be so casual on the forum in this semester and the past semester HAHA XD