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 119870 - NPE in EncodingUtil
Summary: NPE in EncodingUtil
Status: VERIFIED FIXED
Alias: None
Product: xml
Classification: Unclassified
Component: API (show other bugs)
Version: 6.x
Hardware: All All
: P1 blocker (vote)
Assignee: Sonali Kochar
URL:
Keywords:
: 120105 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-10-24 09:04 UTC by sreimers
Modified: 2007-10-30 17:53 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Stacktrace of NPE (7.14 KB, text/plain)
2007-10-24 09:05 UTC, sreimers
Details
Project to reproduce with (6.86 MB, application/octet-stream)
2007-10-25 23:59 UTC, tonybeckham
Details

Note You need to log in before you can comment on or make changes to this bug.
Description sreimers 2007-10-24 09:04:11 UTC
During creating a new XML document inside a freeform java project, I get the attached NPE on the console. This stops me
from creating new XML documents from the IDE. Since there is no visible feedback and freeform projects may not set this
correctly this should be fixed in 6.0 timeframe.
Comment 1 sreimers 2007-10-24 09:05:59 UTC
Created attachment 51551 [details]
Stacktrace of NPE
Comment 2 Mikhail Matveev 2007-10-24 15:59:24 UTC
What do you mean under freeform project? Is it JavaApplication project? Also, please specify your platform and IDE
version  (just copy/paste from Help|About window). As now I can't reproduce it.
Comment 3 Sonali Kochar 2007-10-24 21:35:06 UTC
When you say free form java project, do you mean Java project with existing Ant script? How did you create the XML
document? was it DTD constrained or xsd constrained?

I created a Java project with existing Ant script, and was able to create a new XML document based on a xsd.

If your java project isnt to big, can you attach it to the bug? Also, is there any steps we missed?
Comment 4 sreimers 2007-10-24 22:05:36 UTC
I try to be a bit more specific. The build in use is NetBeans 6.0 Beta 2 running on JDK 1.6.0_03. The project is a
freeform project based on an existing build.xml. I have admit that we are generating the NetBeans project files, so that
we can keep them in sync with the changes in our build infrastructure. This worked up to now without any problems, but
today I tried to create a XML file (just wellformed), but got the exception. It may be a problem, that our generated
nbproject infrastructure is missing the required encoding property, but I think that NetBeans should be able to detect
this, not just throwing a NPE if the encoding can not be resolved (as indicated via the NPE I think). I hope this sheds
some more light on the problem.

If really necessary I think I can come up with an example project to trigger the exception. 
Comment 5 Sonali Kochar 2007-10-24 22:21:44 UTC
I agree and I can fix the code to have a default encoding whenever the project encoding cannot be resolved. However, I
cannot test my fix unless I have a reproducible case nor can the QA verify the fix. It would really be great if you
could attach an example project. If the project is too big, you can email me directly.

I tested on latest trunk build with JDK150_12 on Win XP
Comment 6 Sonali Kochar 2007-10-25 22:55:41 UTC
I was able to reproduce it by creating a free form java project and setting the encoding to <No Encoding>
Comment 7 Sonali Kochar 2007-10-25 23:27:27 UTC
*** Issue 120105 has been marked as a duplicate of this issue. ***
Comment 8 tonybeckham 2007-10-25 23:58:11 UTC
Product Version: NetBeans IDE 6.0 Beta 2 (Build 200710212201)
Java: 1.6.0_03; Java HotSpot(TM) Client VM 1.6.0_03-b05
System: Linux version 2.6.22-14-generic running on i386; UTF-8; en_US (nb)

Following these steps I can hit the NPE.
Steps:
1) Unzip the attached file
2) In the IDE, select File -> New Project -> Java -> Java project with Existing Ant Script
3) In the Name and Location Panel, for Location , Browse and select <ur_unzipped_file>/lucene-2.2.0
4) The Build script text field should be automatically populated with:<ur_unzipped_file>/lucene-2.2.0/build.xml
5) In the Build and Run Actions panel, go with default values
6) In the Source Package Folders panel,  click on Add Folder button of Source Package Folders. Select "src"
7) Make sure you have the right JDK 1.6 in the Source Level: text filed
8) For Encoding, Select <no Encoding>
9) Press finish

A project called "core" will be created. Select core and create a new XML document. Create a well formed document. When
you click Finsh, you should see the NPE 
Comment 9 tonybeckham 2007-10-25 23:59:18 UTC
Created attachment 51735 [details]
Project to reproduce with
Comment 10 Mikhail Matveev 2007-10-26 13:52:48 UTC
I'm unable to perform step 7. Only JDK 1.3, JDK 1.4 and JDK 1.5 exist in Source Level combobox. With JDK 1.5 setting,
the bug is nor reproducible for me using this scenario. WinXP, Beta2.
Comment 11 Mikhail Matveev 2007-10-26 18:58:57 UTC
Sorry, I have been mistaken. I really can't select JDK 1.6 setting, but the bug is _reproducible_ for me with JDK 1.5
setting. WinXP< Beta2, JDK1.6.
Comment 12 Sonali Kochar 2007-10-26 19:25:16 UTC
Fixed
Checking in Bundle.properties;
/cvs/xml/core/src/org/netbeans/modules/xml/api/Bundle.properties,v  <--  Bundle.properties
new revision: 1.2; previous revision: 1.1
done
Checking in EncodingUtil.java;
/cvs/xml/core/src/org/netbeans/modules/xml/api/EncodingUtil.java,v  <--  EncodingUtil.java
new revision: 1.7; previous revision: 1.6
done
Comment 13 tonybeckham 2007-10-30 17:53:55 UTC
Fix verified.

Product Version: NetBeans IDE Dev (Build 200710290000)
Java: 1.6.0_03; Java HotSpot(TM) Client VM 1.6.0_03-b05
System: Linux version 2.6.22-14-generic running on i386; UTF-8; en_US (nb)