users@glassfish.java.net

Can't create embeddable AppClientContainer (ACC ) ?

From: <glassfish_at_javadesktop.org>
Date: Sun, 10 Jan 2010 17:03:21 PST

I can't build an embeddable AppClientContainer (ACC).

I followed the documentation:
Using Embeddable ACC:
http://docs.sun.com/app/docs/doc/820-7695/beakt?a=view

So I tried to use the embedded ACC:
public class JavaeeGreeter_EmbeddedAppClient {

        public static void main(String[] args)
        {
                try
                {
                        // one TargetServer for each ORB endpoint for bootstrapping
                        TargetServer[] servers = new TargetServer[]{new TargetServer()};
        
                        // Get a builder to set up the ACC
                        AppClientContainer.Builder builder = AppClientContainer.newBuilder(servers);
        
                        // Fine-tune the ACC's configuration. Note ability to "chain" invocations.
                        //builder.callbackHandler("com.acme.MyHandler").authRealm("myRealm"); // Modify config
        
                        Class mainClass = EmbeddedApp.class;
                        AppClientContainer acc = builder.newContainer(mainClass);
        
                        // In either case, start the client running.
                        String[] appArgs = new String[0];
                        acc.startClient(appArgs); // Start the client
        
                        //...
        
                        //acc.close(); // close the ACC(optional)
                        acc.stop();
                }
                catch (Throwable t)
                {
                        t.printStackTrace();
                }
        }
}


But From the
"AppClientContainer.Builder builder = AppClientContainer.newBuilder(servers);" row
I always get exception:


java.lang.ClassCastException: sun.misc.Launcher$AppClassLoader cannot be cast to org.glassfish.appclient.client.acc.ACCClassLoader
        at org.glassfish.appclient.client.acc.AppClientContainerBuilder.<init>(AppClientContainerBuilder.java:84)
        at org.glassfish.appclient.client.acc.AppClientContainer.newBuilder(AppClientContainer.java:209)
        at javaee5_greeter.Javaee5Greeter_EmbeddedAppClient.main(Javaee5Greeter_EmbeddedAppClient.java:20)


The gs-client.jar is on the classpath.

Please help me, what is the mistake ?
Thank you very much.
[Message sent by forum member 'thim02' (bboros_at_webmail.hu)]

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