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 182258 - Unable to add/change datasource in Web Application
Summary: Unable to add/change datasource in Web Application
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Persistence (show other bugs)
Version: 6.x
Hardware: All All
: P2 normal (vote)
Assignee: Sergey Petrov
URL:
Keywords:
: 181159 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-03-17 19:37 UTC by bashley
Modified: 2010-04-02 11:03 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
suggested patch (16.42 KB, patch)
2010-03-30 11:34 UTC, Sergey Petrov
Details | Diff
patch with usage of nb api to save xml (16.69 KB, application/octet-stream)
2010-03-30 12:26 UTC, Sergey Petrov
Details
reattached with proper content type and some cleanup (15.83 KB, text/plain)
2010-03-30 12:30 UTC, Sergey Petrov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bashley 2010-03-17 19:37:39 UTC
When creating a new Web application from scratch, all appears fine, for example, when doing the Create Entity Classes from database. I am able to add a MySQL database as a data source and get some work done on the class and JSF files.

However, I have tried to add a second persistent unit for a second database on this project, this one being a connection to SQLServer (not that it should matter).  

I created and verified a connection to the database using the services tab.  When I try to add an entity class from the new database, the following occurs:
-Select select New Data Source.... from the Data Source drop-down list.
-In the Create Data Source dialog, I am able to see the existing connection and give it a name, e.g., "jdbc/tm"
-When I select OK, the Create Data Source dialog disappears and nothing happens - the new JNDI name does not appear in the Data Source drop-down.

I have not found any way to make this work.  

I have tried independently adding a new persistence unit, same result.

I have done the exact same steps above from a new project and it adds the data source that failed (jdbc/tm) just fine.  In that new project, I can also see the earlier added data source (jdbc/hf_ids), but not vice versa.

I am unable to find a workaround, or even any good documentation on how to hand code the persistence.xml file to make this work.  That will be my final option if, as it appears so far, the automatic code generation is too delicate to get any real work done.  Or maybe it is time to just give up and use ASP.NET.  After just one weekend I have a handful of obnoxious bugs that need repair for Netbeans, but this is the first show stopper.

If it matters, I am using Build 2009120441610, Glassfish v3 server, Java EE 6 (1.6.0_02), JSF 2.0, EclispseLink(JPA 2.0) persistence provider. 

Thanks
Comment 1 Sergey Petrov 2010-03-17 20:58:22 UTC
As I got it the main issue is "the new JNDI name does not appear in the Data Source drop-down" not in real "can't create second pu". Am I right?
Comment 2 Sergey Petrov 2010-03-22 09:32:42 UTC
may need to try on windows7, all seems to work fine on ubuntu, I can create any number of datasources and all appears in drop down immediatly.
as a workaround you can try to add datasource manually  to sun-resources.xml located at your_project_dir/setup/ folder.

do you see first created datasource in this file? you can use first one as a sample, will it appear in drop down after addition to this file?
Comment 3 Sergey Petrov 2010-03-22 09:33:21 UTC
is there any exceptions in message.log?
Comment 4 Sergey Petrov 2010-03-29 08:51:14 UTC
may be somehow related with some characters in password (like '&' etc)
Comment 5 Sergey Petrov 2010-03-29 10:46:34 UTC
if resource is added with new|glassfish|jdbc resource, then value will be encoded (i.e. will be "test1&" but in case of addition with new resource in entity from db wizard, value for password is not encoded
<property name="Password" value="test1&"/>
Comment 6 Sergey Petrov 2010-03-30 11:34:24 UTC
Created attachment 96319 [details]
suggested patch
Comment 7 Sergey Petrov 2010-03-30 11:56:07 UTC
patch have some indentation issues, I'm looking for resolving now but any ideas are welcomed
Comment 8 Sergey Petrov 2010-03-30 12:26:36 UTC
Created attachment 96326 [details]
patch with usage of nb api to save xml

nb api have already realized xml saving with proper formatting
Comment 9 Sergey Petrov 2010-03-30 12:30:25 UTC
Created attachment 96328 [details]
reattached with proper content type and some cleanup
Comment 10 Sergey Petrov 2010-03-30 14:25:53 UTC
decide to push last patch, as it's better if more people will try in daily, it's always possible to update/rolbaclk later
http://hg.netbeans.org/web-main/rev/8af5dfa04bc1
Comment 11 Quality Engineering 2010-04-02 04:59:07 UTC
Integrated into 'main-golden', will be available in build *201004020200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/8af5dfa04bc1
User: Sergey B. Petrov <sj-nb@netbeans.org>
Log: fix #182258 create Document  instead of plain String and save
Comment 12 Sergey Petrov 2010-04-02 11:03:46 UTC
*** Bug 181159 has been marked as a duplicate of this bug. ***