This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 269982 - getClass().getResource() bug
Summary: getClass().getResource() bug
Status: RESOLVED WORKSFORME
Alias: None
Product: java
Classification: Unclassified
Component: Classpath (show other bugs)
Version: 8.2
Hardware: PC Windows 10
: P1 normal (vote)
Assignee: Tomas Zezula
URL:
Keywords:
: 269981 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-03-04 17:32 UTC by FORLoop
Modified: 2017-05-09 06:46 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
IDE log (48.63 KB, text/plain)
2017-03-04 17:32 UTC, FORLoop
Details

Note You need to log in before you can comment on or make changes to this bug.
Description FORLoop 2017-03-04 17:32:41 UTC
Product Version = NetBeans IDE 8.2 (Build 201609300101)
Operating System = Windows 10 version 10.0 running on amd64
Java; VM; Vendor = 1.8.0_112
Runtime = Java HotSpot(TM) 64-Bit Server VM 25.112-b15

Reproducibility: Happens every time

Dear developers,

This is my first repprt here i dunno how should fill the rest fields.

So the bug iis:
Create a maven project.
Create a package com.test.application
Create a Test.java in application package
Create an another package com.test.view
Create an FXML file in view package
Then from Test.java try to acces to get the FXML file in view package with getClass().getResource()
For result u get null thats the bug

I couldd solve the problem by creating a random .java class in view package then delete it
after u created a random .java fiile there the compiler will find the package.

Best wishes,
David Kecskemeti

dxdy421@gmail.com
+36709771591
Comment 1 FORLoop 2017-03-04 17:32:46 UTC
Created attachment 163761 [details]
IDE log
Comment 2 Tomas Zezula 2017-05-09 06:45:06 UTC
The report is filled perfectly.

The problem here is in how the Maven handles resources which is very different from the Ant. The "Source Packages" should contain only sources. Maven passes these files to the java compiler, by default it does not copy resources from "Source Packages" into build artefact. The resources should be placed in the "src/main/resources" ("Other Sources"/"src/main/resources"). The maven copies the files from the "src/main/resources" into build artefact.

To resolve the problem move the "com/test/view/*.fxml" into the "src/main/resources/com/test/view/".
Comment 3 Tomas Zezula 2017-05-09 06:46:21 UTC
*** Bug 269981 has been marked as a duplicate of this bug. ***