users@glassfish.java.net

Re: How to add automated testing to client application ...

From: <forums_at_java.net>
Date: Tue, 17 May 2011 06:48:03 -0500 (CDT)

Thank you for reply.

I can run my client application using appclient command without problems.

I' ve tried two ways, how to initialize the session connection from client:

1. For testing, manual set the field, which is normally injected. This works,
when I run the application normal way, but not from the testing framework.
Code:

Properties jndiProps = new Properties();

jndiProps.put("java.naming.factory.initial",
"com.sun.enterprise.naming.impl.SerialInitContextFactory");
jndiProps.put("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
jndiProps.put("java.naming.factory.state",
"com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
jndiProps.setProperty("org.omg.CORBA.ORBInitialHost", "127.0.0.1");
jndiProps.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
try {
   Context ctx = new InitialContext(jndiProps);
   homeSessionBean =
(HomeSessionBeanRemote)ctx.lookup("com.xxx.yyy.HomeSessionBeanRemote");
} catch (Exception e) {
     e.printStackTrace();
}

2. Using embedded acc api. My code:

public static void main(String args[]) {
        TargetServer[] servers = new TargetServer[]{new
TargetServer("localhost", 3700)};
        AppClientContainer.Builder builder =
AppClientContainer.newBuilder(servers);
        try {
            URI clientURI = new
URI("file:///c://...//TestClient.jar"); 
            AppClientContainer acc =
builder.newContainer(clientURI);  // also tried with the main class
            acc.prepare(null);
            acc.startClient(new String[0]);
        } catch (Exception ex) {
           
Logger.getLogger(ClientApplication.class.getName()).log(Level.SEVERE, null,
ex);
        } catch (UserError ex) {
           
Logger.getLogger(ClientApplication.class.getName()).log(Level.SEVERE, null,
ex);
        }
}

Both of these methods throw very similar exception (error):

Caused by: java.lang.LinkageError: injection failed on class
org.glassfish.appclient.client.acc.ACCAppClientArchivist from
sun.misc.Launcher$AppClassLoader_at_1a16869
    at
org.jvnet.hk2.component.InjectionManager.inject(InjectionManager.java:254)

...

Caused by: java.lang.LinkageError: injection failed on class
com.sun.enterprise.deployment.annotation.factory.SJSASFactory from
sun.misc.Launcher$AppClassLoader_at_1a16869
    at
org.jvnet.hk2.component.InjectionManager.inject(InjectionManager.java:254)

...

Caused by: java.lang.LinkageError: injection failed on class
org.glassfish.ejb.deployment.annotation.handlers.TransactionAttributeHandler
from sun.misc.Launcher$AppClassLoader_at_1a16869
    at
org.jvnet.hk2.component.InjectionManager.inject(InjectionManager.java:254)

...

Caused by: java.lang.ClassFormatError: Absent Code attribute in method that
is not native or abstract in class file javax/ejb/TransactionAttributeType
    at java.lang.ClassLoader.defineClass1(Native Method)

 

I've found, that this can involve a problem with javaee library, so I've
played with the libraries, but without success...

Code from test file is simple:

@Before
public void setUp() {
    
org.fest.swing.launcher.ApplicationLauncher.application(TestClientApplication.class).start();       
}

I've created another application, which uses embedded acc api to run my
client and this works, so it doesn't work only for the testing framework...

Any idea?

Thank you very much


--
[Message sent by forum member 'anaq']
View Post: http://forums.java.net/node/802612