Hi,
First sorry my terrible English!
Second my stupid questions, but I just started to learning Java at May 2009 and too many the new ideas for me.
I started to learning Java with JEE5/NB6.7/GFv2/TopLink and EclipseLinkv1.2 and now I would like to explore JEE6/NB6.8/GFv3/EclipseLinkv2.
I would like to known about diferences between ACC and Embedded ACC, which situation I should use the Embedded ACC instead ACC.
I wrote a litle test from HelloApp of JEE6 demos, the standalone and the application clients are working fine, but the application client with embedded ACC is throw an error:
"Caused by: java.lang.Error: factory already defined"
Can anyone help to me?
Thanks, Attila.
EmbStatelessJavaClient.java
---------------------------
package enterprise.hello_stateless_client;
import javax.naming.InitialContext;
import org.glassfish.appclient.client.acc.config.TargetServer;
import org.glassfish.appclient.client.acc.AppClientContainer.Builder;
import org.glassfish.appclient.client.acc.AppClientContainer;
import org.glassfish.appclient.client.acc.UserError;
import enterprise.hello_stateless_ejb.StatelessSession;
public class EmbStatelessJavaClient {
private static String appArgs[] = null;
private static TargetServer[] servers = null;
private static Builder builder = null;
private static AppClientContainer acc = null;
public static void main(String args[]) {
appArgs = new String[args.length];
for (int c = 0; c < args.length;c++) {
appArgs[c] = new String(args[c]);
}
new EmbStatelessJavaClient();
}
public EmbStatelessJavaClient() {
servers = new TargetServer[1];
servers[0] = new TargetServer("localhost", 3700);
builder = AppClientContainer.newBuilder(servers);
try {
//builder.authRealm("admin-realm");
//builder.clientCredentials("admin", "".toCharArray());
//builder.logger(myLogger);
acc = builder.newContainer(EmbStatelessJavaClient.class);
acc.startClient(appArgs);
for (int c=0; c<10; c++) {
System.out.println("StatelessSession bean says : " + returnMessage());
}
acc.stop();
} catch (Exception ex) {
ex.printStackTrace();
} catch (UserError ex) {
ex.printStackTrace();
}
}
private String returnMessage() {
try {
InitialContext ic = new InitialContext();
StatelessSession sless = (StatelessSession)
ic.lookup("enterprise.hello_stateless_ejb.StatelessSession");
//ic.lookup("java:global/EnterpriseApplication/EnterpriseApplication-ejb/StatelessSessionBean");
return (sless.hello());
} catch(Exception e) {
e.printStackTrace();
}
return null;
}
}
hellostub_and_testacc.sh
------------------------
#!/bin/sh
echo "get STUB"
/java/glassfishv3/glassfish/bin/asadmin get-client-stubs --appname HelloApp /java/projects/HelloApp/dist
echo "start STD"
cd /java/projects/HelloApp/HelloApp-std-client/dist
java -cp /java/glassfishv3/glassfish/modules/gf-client.jar:/java/projects/HelloApp/HelloApp-std-client/dist/lib/HelloApp-com.jar:/java/projects/HelloApp/HelloApp-std-client/dist/HelloApp-std-client.jar enterprise.hello_stateless_client.StandaloneStatelessJavaClient
echo "start ACC"
cd /java/projects/HelloApp/dist
/java/glassfishv3/glassfish/bin/appclient -client HelloAppClient.jar -name HelloApp-app-client
echo "start EmbeddedACC"
cd /java/projects/HelloApp/dist
/java/glassfishv3/glassfish/bin/appclient -client HelloAppClient.jar -name HelloApp-app-clemb
cd /java/projects
RESULT:
-------
root_at_aszomor:/java/projects# ./hellostub_and_testacc.sh
get STUB
Authentication failed with password from login store: /root/.asadminpass
Enter admin password for user "admin">
Command get-client-stubs executed successfully.
start STD
2010.03.30. 12:04:56 com.sun.enterprise.transaction.JavaEETransactionManagerSimplified initDelegates
INFO: Using com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate as the delegate
StatelessSession bean says : hello, world!
StatelessSession bean says : hello, world!
StatelessSession bean says : hello, world!
StatelessSession bean says : hello, world!
StatelessSession bean says : hello, world!
StatelessSession bean says : hello, world!
StatelessSession bean says : hello, world!
StatelessSession bean says : hello, world!
StatelessSession bean says : hello, world!
StatelessSession bean says : hello, world!
start ACC
2010.03.30. 12:05:00 com.sun.enterprise.transaction.JavaEETransactionManagerSimplified initDelegates
INFO: Using com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate as the delegate
StatelessSession bean says : hello, world!
StatelessSession bean says : hello, world!
StatelessSession bean says : hello, world!
StatelessSession bean says : hello, world!
StatelessSession bean says : hello, world!
StatelessSession bean says : hello, world!
StatelessSession bean says : hello, world!
StatelessSession bean says : hello, world!
StatelessSession bean says : hello, world!
StatelessSession bean says : hello, world!
start EmbeddedACC
2010.03.30. 12:05:09 com.sun.enterprise.transaction.JavaEETransactionManagerSimplified initDelegates
INFO: Using com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate as the delegate
java.lang.reflect.InvocationTargetException
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 org.glassfish.appclient.client.acc.AppClientContainer.launch(AppClientContainer.java:425)
at org.glassfish.appclient.client.AppClientFacade.launch(AppClientFacade.java:151)
at org.glassfish.appclient.client.AppClientGroupFacade.main(AppClientGroupFacade.java:64)
Caused by: java.lang.Error: factory already defined
at java.net.URL.setURLStreamHandlerFactory(URL.java:1077)
at org.glassfish.appclient.client.acc.AppClientContainer$3.run(AppClientContainer.java:702)
at java.security.AccessController.doPrivileged(Native Method)
at org.glassfish.appclient.client.acc.AppClientContainer.prepareURLStreamHandling(AppClientContainer.java:698)
at org.glassfish.appclient.client.acc.AppClientContainer.completePreparation(AppClientContainer.java:381)
at org.glassfish.appclient.client.acc.AppClientContainer.prepare(AppClientContainer.java:312)
at org.glassfish.appclient.client.acc.AppClientContainer.startClient(AppClientContainer.java:281)
at enterprise.hello_stateless_client.EmbStatelessJavaClient.<init>(EmbStatelessJavaClient.java:70)
at enterprise.hello_stateless_client.EmbStatelessJavaClient.main(EmbStatelessJavaClient.java:58)
... 7 more
root_at_aszomor:/java/projects#
[Message sent by forum member 'aszomor']
http://forums.java.net/jive/thread.jspa?messageID=394448