users@glassfish.java.net

Implementing context intf and instatiating it as an external jndi resource

From: <glassfish_at_javadesktop.org>
Date: Mon, 09 Jun 2008 03:55:30 PDT

Hello,
   I have implemented all the necessary interfaces and created the neeeded classes to create an external jndi resource. I 'm setting it up in the jndi external resource menu. When I browse to application server/general/jndi browsing, it's there.

But when I try to inject it as a resource in the application client main class I get these errors:

9 Ιουν 2008 12:41:02 μμ com.sun.enterprise.resource.ResourceInstaller loadObject
SEVERE: RAR5015:Unexpected exception in loading class [org.context.settingsContext.SettingsFactory] by classloader
9 Ιουν 2008 12:41:02 μμ com.sun.enterprise.resource.ResourceInstaller loadObject
SEVERE: RAR5046:Unexpected exception in loading class by classloader [org.context.settingsContext.SettingsFactory]
Cannot load external-jndi-resource factory-class 'org.context.settingsContext.SettingsFactory'

The client's security manager is off.
The sun-application-client deployment descriptor contains this reference:

<resource-ref>
      <res-ref-name>test/Settings</res-ref-name>
      <jndi-name>test/Settings</jndi-name>
   </resource-ref>

If I include:

<resource-ref>
      <res-ref-name>XLat4cast/Settings</res-ref-name>
   </resource-ref>

in the application-client descriptor, deployment fails with these exceptions:

Exception occured in J2EEC Phasejava.lang.NullPointerException
com.sun.enterprise.deployment.backend.IASDeploymentException: Error loading deployment descriptors for module [flyerEnterprise] -- null
        at com.sun.enterprise.deployment.backend.Deployer.loadDescriptors(Deployer.java:390)
        at com.sun.enterprise.deployment.backend.AppDeployerBase.loadDescriptors(AppDeployerBase.java:358)
        at com.sun.enterprise.deployment.backend.AppDeployer.deploy(AppDeployer.java:226)
        at com.sun.enterprise.deployment.backend.AppDeployer.doRequestFinish(AppDeployer.java:148)
        at com.sun.enterprise.deployment.phasing.J2EECPhase.runPhase(J2EECPhase.java:191)
        at com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:108)
        at com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeploymentService.java:919)
        at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:279)
        at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:788)
        at com.sun.enterprise.management.deploy.DeployThread.deploy(DeployThread.java:187)
        at com.sun.enterprise.management.deploy.DeployThread.run(DeployThread.java:223)
Caused by: java.lang.NullPointerException
        at com.sun.enterprise.deployment.util.EjbBundleValidator.computeRuntimeDefault(EjbBundleValidator.java:892)
        at com.sun.enterprise.deployment.util.EjbBundleValidator.accept(EjbBundleValidator.java:683)
        at com.sun.enterprise.deployment.ApplicationClientDescriptor.visit(ApplicationClientDescriptor.java:649)
        at com.sun.enterprise.deployment.Application.visit(Application.java:1783)
        at com.sun.enterprise.deployment.archivist.ApplicationArchivist.validate(ApplicationArchivist.java:470)
        at com.sun.enterprise.deployment.archivist.ApplicationArchivist.openArchive(ApplicationArchivist.java:790)
        at com.sun.enterprise.deployment.archivist.ApplicationArchivist.openArchive(ApplicationArchivist.java:744)
        at com.sun.enterprise.deployment.backend.Deployer.loadDescriptors(Deployer.java:349)
        ... 10 more


The jar file that includes the classes implementing the context related interfaces is located at ${com.sun.aas.installRoot}/lib and there is a reference pointing to in application server/jvm settings/path settings/Classpath prefix. I have also included the jar as a library in the application client part of my enterprise project (I 'm using netbeans 6.1).

I have checked the application server code (that loads instances of external jndi resources), namely classes com.sun.enterprise.resource.JndiProxyObjectFactory and com.sun.enterprise.resource.ResourceInstaller. The latter first tries to instatiate the factory class using Class.forName(...) in its loadObject method (If I understand correctly, Class.forName(...) uses the calling class's classloader, so which one is that for ResourceInstaller?). When that raises an exception it tries to load it through ClassLoader.getSystemClassLoader().loadClass(...) and again fails.

I'm attaching the related code for anyone to see, it's still embryonic and if you read through the code you 'll see what I 'm trying to achieve.

Any ideas on how to get this thing going?

mfg8876
[Message sent by forum member 'mfg8876' (mfg8876)]

http://forums.java.net/jive/thread.jspa?messageID=279086