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 156658

Summary: glassfish.javaee needs dependency on java.j2seplatform
Product: serverplugins Reporter: davisn <davisn>
Component: GlassFishAssignee: issues@serverplugins <issues>
Status: RESOLVED FIXED    
Severity: blocker CC: jtulach, tzezula, vkraemer
Priority: P2 Keywords: API_REVIEW_FAST
Version: 6.x   
Hardware: Sun   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:
Attachments: messages.log
Provides/requires between glassfish.javaee and java.j2seplatform

Description davisn 2009-01-13 01:47:24 UTC
java.lang.IllegalArgumentException occurs after download V3 and select domain1 to register

Steps To Reproduce:
1. Start Netbean IDE Dev 09112 build on a Solaris x86b machine
2. Select to activate Glassfish V3 plugin 
3. Select to add server > select Download V3 now > select domain1 > click Finish
BUG
    java.lang.IllegalArgumentException: Trying to add a library of unknown type: j2se
	at org.netbeans.api.project.libraries.LibraryManager.createLibrary(LibraryManager.java:274)
	at org.netbeans.modules.glassfish.javaee.JavaEEServerModuleFactory.ensureCometSupport(JavaEEServerModuleFactory.java:274)
	at org.netbeans.modules.glassfish.javaee.JavaEEServerModuleFactory$1.run(JavaEEServerModuleFactory.java:121)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:573)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1005)
Comment 1 davisn 2009-01-13 01:51:18 UTC
Created attachment 75732 [details]
messages.log
Comment 2 Vince Kraemer 2009-01-14 03:48:20 UTC
just to clarify... was this the 7.0 dev build or the nbjavaee6 dev build?
Comment 3 davisn 2009-01-14 17:27:15 UTC
It's a nbjavaee6 dev build. I build its myself 
Comment 4 Vince Kraemer 2009-01-22 15:43:19 UTC
issue 157287 seems like it is a related problem.

so does issue 150486
Comment 5 Vince Kraemer 2009-01-22 20:44:49 UTC
The v3 module does not depend on the java cluster (since it is in the ide cluster).

The j2se library type is in the java cluster...

This allows the user to follow this path and end up with the result described here.

if we make glassfish.javaee depend on java.j2seplatform the issue clears up... but that doesn't seem like the right fix.

Comment 6 Jesse Glick 2009-01-23 01:35:48 UTC
JavaEEServerModuleFactory.ensureCometSupport should be prepared for there to be no j2se library type defined. This would
happen if the java cluster were not enabled.

Perhaps the Java functionality is disabled due to the ergonomics cluster? If so, add ERGONOMICS keyword.
Comment 7 Vince Kraemer 2009-01-23 04:04:40 UTC
Hmmm.

on exception... add a property change listener to the library manager to try to create the library later on.  the theory
is that the j2se type will get defined and some other module will register a j2se library successfully. Once that
happens, this library should register successfully.
Comment 8 Vince Kraemer 2009-01-23 22:06:31 UTC
if I build the IDE and then clean the ergonomics jar from the build I cannot reproduce this issue.

Following jglick's advice about the keyword.  I will keep the issue assigned to me since there is still a problem with
the plugin code.
Comment 9 Jaroslav Tulach 2009-01-24 09:31:55 UTC
Probably the library is registered before the right declaration is parsed.
Comment 10 Vince Kraemer 2009-01-28 00:05:49 UTC
checked in fix for symptom... but it doesn't address the fact that the j2se library type should be available at the
point where the code to create the libraries is called.

http://hg.netbeans.org/main/rev/4ce9ca68e094
Comment 11 Jaroslav Tulach 2009-01-28 09:34:27 UTC
Tomáši, we have a problem. The IAE from 
org.netbeans.api.project.libraries.LibraryManager.createLibrary(LibraryManager.java:274)
is correct. The j2se library type is unknown. Of course, because j2se library type is defined in Java and Java is 
still disabled.

Shall the IAE be changed to warning only? I can do that, if you tell me.
Shall the code in glassfish.javaee.JavaEEServerModuleFactory be modified?

Thanks in advance for your valuable insight.
Comment 12 Vince Kraemer 2009-01-28 15:42:06 UTC
One thing that I noticed while working on this...

There are a number of modules activated when the GF v3 module is activated... but java.j2seplatform is not one of them.

When I looked at some of the project info in java.j2seplatform, I noticed that it is only expose apis to the two import
projects...

So, it kind of makes sense that the module isn't activated...  
Comment 13 Jaroslav Tulach 2009-01-28 16:53:44 UTC
If you can modify the module "glassfish.javaee" to have dependency on "java.j2seplatform", then I guess this problem 
will also be fixed.
Comment 14 Vince Kraemer 2009-01-28 17:08:19 UTC
java.j2seplatform only exports to friends... so we would need to change both projects.

I have already changed the serverplugin to avoid triggering the IAE... but that 'fix' is really kind of a hack.
Comment 15 Quality Engineering 2009-01-28 22:49:36 UTC
Integrated into 'main-golden', will be available in build *200901281643* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/4ce9ca68e094
User: Vince Kraemer <vkraemer@netbeans.org>
Log: #156658 : don't throw exception if j2se library type isn't registered yet... try later
Comment 16 Jesse Glick 2009-01-29 16:18:20 UTC
"java.j2seplatform only exports to friends... so we would need to change both projects" - no, you need a runtime dep,
not a compile-time dep. Friend packages apply only to compile-time deps. Any module can declare a runtime-only dep on
any other module if it wants.

Somewhat better style would be for java.j2seplatform to declare that it provides a token, say
'org.netbeans.spi.project.libraries.LibraryTypeProvider.j2se', and for glassfish.javaee (and any other module which
needs to create j2se-type libraries) to require this token.
Comment 17 Jaroslav Tulach 2009-01-29 16:24:12 UTC
Created attachment 76348 [details]
Provides/requires between glassfish.javaee and java.j2seplatform
Comment 18 Jesse Glick 2009-01-29 16:34:30 UTC
Works. BTW I picked the name 'org.netbeans.spi.project.libraries.LibraryTypeProvider.j2se' because the prefix is the
actual FQN of the service which is provided. Such a convention would help make token names less arbitrary.
Comment 19 Vince Kraemer 2009-02-03 17:27:32 UTC
I agree with Jesse's name choice for the token.
Comment 20 Jaroslav Tulach 2009-02-03 18:18:24 UTC
I agree as well (I prepared my patch before seeing Jesse's comment). Can you please integrate this patch, then? 
Thanks.
Comment 21 Jaroslav Tulach 2009-02-03 18:19:13 UTC
/s/this/such/
Comment 22 Vince Kraemer 2009-02-03 19:59:30 UTC
I do not own java.j2seplatform, so that module's owner should export the token before I start to use it, right?

Obviously, there needs to be changes to the architecture documents in both modules, too.  The owner of java.j2seplatform
would need to publish changes to the apichanges doc, too.
Comment 23 Jesse Glick 2009-02-03 20:33:11 UTC
Should be made as one Hg changeset. If you do not feel comfortable patching java.j2seplatform, assign to jjancura,
jtulach, jglick, or just prepare a final patch including recommended token and arch.xml and ask for final review of impl.
Comment 24 Vince Kraemer 2009-02-11 00:31:49 UTC
The DEFECT part of this is resolved... so I am going to convert this to an ENHANCEMENT.
Comment 25 Jaroslav Tulach 2009-02-11 10:05:00 UTC
Are you sure there is no remaining defect? The exception is not thrown anymore, but the glassfish library is not going 
to be available in Library Manager, imho.
Comment 26 Vince Kraemer 2009-12-08 15:00:43 UTC
closing