Skip to main content

NPE at AbstractModulesRegistryImpl.java:448 with appclient via javaws

9 replies [Last post]
inar
Offline
Joined: 2009-11-09
Points: 0

I have an EAR application consisting of a couple of EJBs, a WAR and an application client. This application deploys and works fine on Glassfish 2.1 and is a prototype for a project that I am working on. I wanted to test this on version 3 and try some of the new JEE v6 features.

However, I am unable to get the application client to work when running under glassfish 3. The EAR deploys (if I use the admin console - it won't from inside eclipse but that is a separate issue) but the application client will not start from either the admin console or using javaws.

Instead I receive the following exception which I have been unable to find any information on (I even tried locating the source for AbstractModulesRegistryImpl but could not find it anywhere).

Any ideas on what is causing this issue?

java.lang.NullPointerException
at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.add(AbstractModulesRegistryImpl.java:448)
at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.add(AbstractModulesRegistryImpl.java:443)
at com.sun.enterprise.module.single.SingleModulesRegistry.(SingleModulesRegistry.java:48)
at com.sun.enterprise.module.single.SingleModulesRegistry.(SingleModulesRegistry.java:30)
at com.sun.enterprise.module.single.StaticModulesRegistry.(StaticModulesRegistry.java:60)
at org.glassfish.appclient.client.acc.ACCModulesManager.prepareHabitat(ACCModulesManager.java:147)
at org.glassfish.appclient.client.acc.ACCModulesManager.initialize(ACCModulesManager.java:81)
at org.glassfish.appclient.client.acc.AppClientContainerBuilder.prepareHabitatAndNaming(AppClientContainerBuilder.java:192)
at org.glassfish.appclient.client.acc.AppClientContainerBuilder.newContainer(AppClientContainerBuilder.java:152)
at org.glassfish.appclient.client.acc.AppClientContainerBuilder.newContainer(AppClientContainerBuilder.java:141)
at org.glassfish.appclient.client.AppClientFacade.createContainerForJWSLaunch(AppClientFacade.java:469)
at org.glassfish.appclient.client.AppClientFacade.createContainer(AppClientFacade.java:428)
at org.glassfish.appclient.client.AppClientFacade.prepareACC(AppClientFacade.java:256)
at org.glassfish.appclient.client.JWSAppClientContainerMain.main(JWSAppClientContainerMain.java:83)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
tjquinn
Offline
Joined: 2005-03-30
Points: 0

AbstractModulesRegistryImpl is part of hk2, the very small kernel on which GlassFish (server and ACC) is based. That is a separate project on java.net from GlassFish itself.

From my quick look at the source code, the NPE at the location in the stack trace should result only if there is also a prior error, including a dump of a stack trace to System.err. (The variable which is null is assigned inside a try block, and the catch block for an IOException prints the stack trace and continues, allowing the null to be passed along.

Was there an earlier stack trace display during the run?

What Java version are you using?

What happens if you deploy the EAR using the "--retrieve localdir" option and then try to launch the app client using the appclient command?

Are you able to share your EAR, either as an attachment to this topic or privately to me in e-mail?

- Tim

inar
Offline
Joined: 2009-11-09
Points: 0

Tim,

I do not get another stack trace. The stacktrace I get appears in a window entitled "Error launching application".

I tried what you suggested and my application starts and then gets an NPE which would indicate that the EJBs have not been injected as I would expect. I though that might be down to authentication issues as I was not prompted for a username / password as I am through Glassfish 2.1 webstart but removing the security annotations from my EJBs did not resolve this.

I would be prepared to send you an EAR file to your private email address. It currently relies on a datasource at deploy time (for JPA) but I think I can remove that dependency easily enough.

Thanks

Ian

tjquinn
Offline
Joined: 2005-03-30
Points: 0

Hi, Ian.

I overlooked one small detail... The additional stack trace will not appear in the dialog box but rather in the Java console and/or the Java Web Start trace file for that application run. You can enable one or both of these by launching the Java Control Panel (the exact mechanism varies by operating system -- one way is to use "javaws -viewer". Close the list of Java Web Start apps if one appears. You should then see a "Java Preferences" dialog box. Choose the Advanced tab, and turn on Java Console->Show Console.)

Now, when you try to run the offending app client you should see a console window open, then I expect you'll see a stack trace similar but not identical to the one you posted earlier displayed in the console window before the error dialog box appears. If that does not give us enough to go on then I'll correspond with you separately to plan our next step.

- Tim

inar
Offline
Joined: 2009-11-09
Points: 0

Hi Tim,

I have managed to the other stack trace and it is below. Not sure what is going wrong though. I will see if I can get my application started using the appclient command. If you want to pursue the cause of this error just let me know what you need.

Thanks,

Ian

java.io.IOException: Failed to read jar:http://localhost:8080/___JWSappclient/___app/DBISpringPrototype/glassfish/modules/gf-client-module.jar!/META-INF/inhabitants/default
at com.sun.enterprise.module.single.ProxyModuleDefinition.readFully(ProxyModuleDefinition.java:112)
at com.sun.enterprise.module.single.ProxyModuleDefinition.(ProxyModuleDefinition.java:83)
at com.sun.enterprise.module.single.ProxyModuleDefinition.(ProxyModuleDefinition.java:73)
at com.sun.enterprise.module.single.SingleModulesRegistry.(SingleModulesRegistry.java:42)
at com.sun.enterprise.module.single.SingleModulesRegistry.(SingleModulesRegistry.java:30)
at com.sun.enterprise.module.single.StaticModulesRegistry.(StaticModulesRegistry.java:60)
at org.glassfish.appclient.client.acc.ACCModulesManager.prepareHabitat(ACCModulesManager.java:147)
at org.glassfish.appclient.client.acc.ACCModulesManager.initialize(ACCModulesManager.java:81)
at org.glassfish.appclient.client.acc.AppClientContainerBuilder.prepareHabitatAndNaming(AppClientContainerBuilder.java:192)
at org.glassfish.appclient.client.acc.AppClientContainerBuilder.newContainer(AppClientContainerBuilder.java:152)
at org.glassfish.appclient.client.acc.AppClientContainerBuilder.newContainer(AppClientContainerBuilder.java:141)
at org.glassfish.appclient.client.AppClientFacade.createContainerForJWSLaunch(AppClientFacade.java:469)
at org.glassfish.appclient.client.AppClientFacade.createContainer(AppClientFacade.java:428)
at org.glassfish.appclient.client.AppClientFacade.prepareACC(AppClientFacade.java:256)
at org.glassfish.appclient.client.JWSAppClientContainerMain.main(JWSAppClientContainerMain.java:83)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.EOFException
at java.io.DataInputStream.readFully(Unknown Source)
at java.io.DataInputStream.readFully(Unknown Source)
at com.sun.enterprise.module.single.ProxyModuleDefinition.readFully(ProxyModuleDefinition.java:105)
... 23 more

inar
Offline
Joined: 2009-11-09
Points: 0

I have had no luck getting the application to run with appclient either. I am consistently getting the error pasted in below. It would suggest that my EJB's are not available to my application client. However, deploying the exact same EAR to Glassfish 2.1 works fine so if there is an error in my ear layout 2.1 is tolerant of it.

Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(Unknown Sou
rce)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(Unknown So
urce)
Caused by: java.lang.NoClassDefFoundError: com/rocketsoftware/leopard/server/pro
totyping/dbi/ejb/DBISessionRemote
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getDeclaredMethods(Unknown Source)
at com.sun.enterprise.deployment.util.DefaultDOLVisitor.acceptWithCL(Def
aultDOLVisitor.java:327)
at com.sun.enterprise.deployment.util.EjbBundleValidator.accept(EjbBundl
eValidator.java:188)
at com.sun.enterprise.deployment.ApplicationClientDescriptor.visit(Appli
cationClientDescriptor.java:657)
at com.sun.enterprise.deployment.archivist.AppClientArchivist.validate(A
ppClientArchivist.java:168)
at org.glassfish.appclient.client.acc.FacadeLaunchable.validateDescripto
r(FacadeLaunchable.java:175)
at org.glassfish.appclient.client.acc.AppClientContainer.completePrepara
tion(AppClientContainer.java:350)
at org.glassfish.appclient.client.acc.AppClientContainer.prepare(AppClie
ntContainer.java:311)
at org.glassfish.appclient.client.AppClientFacade.prepareACC(AppClientFa
cade.java:264)
at org.glassfish.appclient.client.acc.agent.AppClientContainerAgent.prem
ain(AppClientContainerAgent.java:75)
... 6 more
Caused by: java.lang.ClassNotFoundException: com.rocketsoftware.leopard.server.p
rototyping.dbi.ejb.DBISessionRemote
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at org.glassfish.appclient.client.acc.ACCClassLoader.findClass(ACCClassL
oader.java:211)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 18 more
FATAL ERROR in native method: processing of -javaagent failed

tjquinn
Offline
Joined: 2005-03-30
Points: 0

Hi, Ian.

Is the missing class in a library JAR file? Is that JAR at the top-level of the EAR?

If so, that explains things. Java EE 6 prescribes stricter rules about what JARs should and should not be visible to clients, and GlassFish v3 enforces those stricter rules. In v2 top-level JARs (and EJB modules, for that matter) were automatically available to app clients. In v3 the developer must either

1. declare an explicit dependency using the app client JAR's manifest Class-Path setting, or

2. place the library JAR into the EAR's library directory (/lib by default or, if your application.xml specifies
, whatever that is)

3. deploy the app using the --property compatibility=v2 option which, for that deployment of the application, uses the v2 JAR visibility rules. While this might be the quickest option for now, I'd recommend (if this is indeed the problem) that you adopt #1 or #2 fairly soon.

Many people feel that the cleanest design (although it might lead to an extra JAR file) is to place the EJB interfaces into a library JAR that's available to the client and the EJB module, with the EJB implementation classes in the EJB JAR. Then the interface library JAR can be placed into the EAR's library directory and would therefore be available to both the client and the EJB module. But the EJB implementations would not be exposed to the client. Obviously you have a v2 app already in a form that used to work, but as you make changes to it you might think about moving to this approach.

- Tim

inar
Offline
Joined: 2009-11-09
Points: 0

Hi Tim,

That seems to have sorted it - thank you. The missing class file was in my EJB Jar file at the top level of the EAR file. Having added a class-path reference to the manifest of the application client, the client now starts successfully using the appclient command.

However, I am still getting the same NPE and EOFException (see earlier post) when attempting to launch the application client using webstart. Any ideas?

Thanks for all your help,

Ian

tjquinn
Offline
Joined: 2005-03-30
Points: 0

Hi, again, Ian.

Sorry this is not working.

Another user has encountered this problem and opened this issue

https://glassfish.dev.java.net/issues/show_bug.cgi?id=11482

If you wouldn't mind, could you add a note on that issue describing your environment (operating system and version, exactly GlassFish builds you've tried this with, what Java version you have). Also, if possible, could you attach to that issue the EAR you are working with?

Thanks.

- Tim

inar
Offline
Joined: 2009-11-09
Points: 0

Tim,

I have updated the bug as requested. Thanks for all your help.

Ian