[Java lista] ACC
Szomor Attila
aszomor at computertechnika.hu
2010. Feb. 22., H, 14:55:51 CET
Sziasztok,
Próbálkoznék egy Embedded ACC-vel, csak "hello world" szinten, de az
acc.startClient(args);-ra java.lang.IllegalStateException-t kapok.
Mi az amit nem jól teszek?
Attila.
---------
#!/bin/sh
echo STUB
/java/sges-v3/glassfish/bin/asadmin get-client-stubs --appname HelloApp
/java/projects/HelloApp/dist
cd /java/projects/HelloApp/dist
echo ACC
/java/sges-v3/glassfish/bin/appclient -client HelloAppClient.jar -name
HelloApp-app-client
echo Embedded ACC
/java/sges-v3/glassfish/bin/appclient -client HelloAppClient.jar -name
HelloApp-app-clemb
cd /java/projects
------------------
Eredmények
----------
STUB
Authentication failed with password from login store: /root/.asadminpass
Enter admin password for user "admin">
Command get-client-stubs executed successfully.
ACC
2010.02.22. 14:41:16
com.sun.enterprise.transaction.JavaEETransactionManagerSimplified
initDelegates
INFO: Using
com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate as
the delegate
StatelessSession bean says : hello, world!
Embedded ACC
2010.02.22. 14:41:23
com.sun.enterprise.transaction.JavaEETransactionManagerSimplified
initDelegates
INFO: Using
com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate as
the delegate
java.lang.IllegalStateException
at
org.glassfish.appclient.client.acc.AppClientContainer.launch(AppClientContainer.java:414)
at
org.glassfish.appclient.client.acc.AppClientContainer.startClient(AppClientContainer.java:281)
at
enterprise.hello_stateless_client.StatelessJavaClient.main(StatelessJavaClient.java:59)
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:424)
at
org.glassfish.appclient.client.AppClientFacade.launch(AppClientFacade.java:151)
at
org.glassfish.appclient.client.AppClientGroupFacade.main(AppClientGroupFacade.java:64)
ACC
---
package enterprise.hello_stateless_client;
import javax.naming.InitialContext;
import enterprise.hello_stateless_ejb.StatelessSession;
public class StatelessJavaClient {
public static void main(String args[]) {
//System.out.println("returnMessage():" + returnMessage());
System.out.println("StatelessSession bean says : " +
returnMessage());
}
public static 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;
}
}
Embedded ACC
------------
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 AppClientContainer acc = null;
public static void main(String args[]) {
TargetServer[] servers = new TargetServer[1];
servers[0] = new TargetServer("localhost", 3700);
Builder builder = AppClientContainer.newBuilder(servers);
try {
builder.clientCredentials("admin", "".toCharArray());
//builder.logger(myLogger);
acc = builder.newContainer(EmbStatelessJavaClient.class);
acc.startClient(args);
} catch (Exception ex) {
ex.printStackTrace();
} catch (UserError ex) {
ex.printStackTrace();
}
}
public EmbStatelessJavaClient() {
System.out.println("StatelessSession bean says : " +
returnMessage());
}
public static 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;
}
}
EJB
---
package enterprise.hello_stateless_ejb;
import javax.ejb.Stateless;
@Stateless
public class StatelessSessionBean implements StatelessSession {
public String hello() {
return "hello, world!\n";
}
}
REMOTE
------
package enterprise.hello_stateless_ejb;
import javax.ejb.Remote;
@Remote
public interface StatelessSession {
public String hello();
}
További információk a(z) Javalist levelezőlistáról