users@glassfish.java.net

Injection into WebStart Client not working?

From: Markus KARG <markus.karg_at_gmx.net>
Date: Sun, 23 Mar 2008 12:32:25 +0100

Hi,

in reaction to a posting in this forum, I wanted to try out Swing
clients deployed by WebStart and it actually seem it is not working. I
am using Java 6uN and Java EE 5 SDK to deploy an EAR consisting of two
JARs (EAR and ClientJar).

Server Code:

package statistics.server;
import javax.ejb.Stateless;
@Stateless
public class StatisticsServer {
    public final double average(final double x, final double y) {
        return (x + y) / 2.0;
    }
}

Client Code:

package statistics.client;

import javax.ejb.EJB;

import statistics.server.StatisticsServer;

public final class StatisticsClient {
    public final static void main(final String... arguments) {
        new StatisticsClient().run(arguments);
    }
    @EJB
    private static StatisticsServer statisticsServer;
    public final void run(final String... arguments) {
        final double x = Double.parseDouble(arguments[0]);
        final double y = Double.parseDouble(arguments[1]);
        final double average =
StatisticsClient.statisticsServer.average(x, y);
        System.out.println(String.format("The average of %f and %f is
%f.", x, y, average));
    }
}

No deployment descriptors are used. This is the sole code.

Web Start crashs at client start with the following exception that
prevents it from injecting the dependency:

...
Caused by: javax.naming.NameNotFoundException:
statistics.server.StatisticsServer#statistics.server.StatisticsServer
not found
...

(complete stack trace attached below).

In fact, I do not understand what my fault is. Can you give me some tips
where I go wrong? Why is the client not finding the server?

Thanks a lot!
Markus

Here is the complete stack trace:

java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at
com.sun.enterprise.appclient.jws.boot.JWSACCMain.run(JWSACCMain.java:221)
    at
com.sun.enterprise.appclient.jws.boot.JWSACCMain.main(JWSACCMain.java:182)
    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.lang.RuntimeException:
com.sun.enterprise.InjectionException: Exception attempting to inject
Unresolved Ejb-Ref
statistics.client.StatisticsClient/statisticsServer_at_jndi:
statistics.server.StatisticsServer_at_null@statistics.server.StatisticsServer_at_Session@null
into class statistics.client.StatisticsClient
    at
com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:487)
    ... 15 more
Caused by: com.sun.enterprise.InjectionException: Exception attempting
to inject Unresolved Ejb-Ref
statistics.client.StatisticsClient/statisticsServer_at_jndi:
statistics.server.StatisticsServer_at_null@statistics.server.StatisticsServer_at_Session@null
into class statistics.client.StatisticsClient
    at
com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:387)
    at
com.sun.enterprise.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:206)
    at
com.sun.enterprise.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:144)
    at
com.sun.enterprise.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:136)
    at
com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:420)
    ... 15 more
Caused by: javax.naming.NameNotFoundException:
statistics.server.StatisticsServer#statistics.server.StatisticsServer
not found
    at
com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:216)
    at
com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:188)
    at
com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:74)
    at
com.sun.enterprise.naming.RemoteSerialContextProviderImpl.lookup(RemoteSerialContextProviderImpl.java:129)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at
com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:154)
    at
com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:687)
    at
com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:227)
    at
com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1846)
    at
com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1706)
    at
com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:1088)
    at
com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:223)
    at
com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:806)
    at
com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:563)
    at
com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2567)
    at
com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)


-- 
http://www.xing.com/go/invita/58469