Skip to main content

Standalone client of GlassFish v3

19 replies [Last post]
aszomor
Offline
Joined: 2009-08-06
Points: 0

Hi All,

I would like to ask you to send me a working GFV3 and JDK6 example or an URL where exactly detailed the solution. Just a "Hello world!" more enough!!!

I have working example on GFv2 and JDK5 and spent more than one week to adopt it, but not succeded.

Thanks a lot, Attila.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
adamgo
Offline
Joined: 2014-04-08
Points: 0

I copied the code to notepad, saved as disjava.vbs and "all files" (not text), ran it and got this error

C:\Junk\disjava.vbs(43, 15) Microsoft VBScript compilation error: Expected 'Then'

Am I doing something wrong?

Thanks,
Adam Gottbetter

aszomor
Offline
Joined: 2009-08-06
Points: 0

Hi,

I downloaded the latest-glassfish.zip (which recomended by Tin in "appclient doesn't work" thread) and tried it, it was OK!
http://forums.java.net/jive/thread.jspa?messageID=394433&#394433

And now everything are working on all platform that we use (Linux and Windows).

Thanks a lot Tim!
Attila.

aszomor
Offline
Joined: 2009-08-06
Points: 0

Hi,

Do not work on Windows OS, just on Unix or Linux!!!

"get STUB"
call G:\java\sges-v3\glassfish\bin\asadmin get-client-stubs --appname HelloApp G:/java/projects/HelloApp/dist

Command get-client-stubs executed successfully.

"start STD"
java -cp g:/java/sges-v3/glassfish/modules/gf-client.jar;g:/java/projects/HelloApp/HelloApp-std-client/dist/lib/HelloApp-com.jar;g:/java/projects/HelloApp/HelloApp-std-client/dist/HelloApp-std-client.jar enterprise.hello_stateless_client.StandaloneStatelessJavaClient

The system cannot find the path specified.
java.lang.NoClassDefFoundError: enterprise/hello_stateless_client/StandaloneStatelessJavaClient
Caused by: java.lang.ClassNotFoundException: enterprise.hello_stateless_client.StandaloneStatelessJavaClient
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: enterprise.hello_stateless_client.StandaloneStatelessJavaClient. Program will exit.
Exception in thread "main"

I think this is the same error as "appclient doesn't work" thread
http://forums.java.net/jive/message.jspa?messageID=394132#394132

Attila.

aszomor
Offline
Joined: 2009-08-06
Points: 0

Hi Tim,

It is the correct answer, it is the best answer, it is the working example, you are the best !!!

Thanks a lot, Attila.

Here is the solution for everyone in the attached the HelloApp.zip.

THE hellostub_and_testacc.sh
----------------------------
#!/bin/sh
#asadmin deploy --generatermistubs --retrieve /home/user1/clientstubdir fooapp.ear
echo "get STUB"
/java/sges-v3/glassfish/bin/asadmin get-client-stubs --appname HelloApp /java/projects/HelloApp/dist
echo "start ACC"
cd /java/projects/HelloApp/dist
/java/sges-v3/glassfish/bin/appclient -client HelloAppClient.jar -name HelloApp-app-client
echo "start STD"
cd /java/projects/HelloApp/HelloApp-std-client/dist
java -cp /java/sges-v3/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
cd /java/projects

AND THE TEST
------------
root@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 ACC
2010.03.11. 9:32:01 com.sun.enterprise.transaction.JavaEETransactionManagerSimplified initDelegates
INFO: Using com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate as the delegate
StatelessSession bean says : hello, world!

start STD
2010.03.11. 9:32:12 com.sun.enterprise.transaction.JavaEETransactionManagerSimplified initDelegates
INFO: Using com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate as the delegate
StatelessSession bean says : hello, world!

root@aszomor:/java/projects#

aszomor
Offline
Joined: 2009-08-06
Points: 0

Hi,

My original problem was running the HelloApp in NB6.8/GFv3, this application is runnable on NB6.7/GFv2!
I will try everything what you recommend to me, but I would like to get an answer for my original problem if possible.

Thanks, Attila.

tjquinn
Offline
Joined: 2005-03-30
Points: 0

I am not sure what your original problem was - maybe I missed exactly what NetBeans problem you were running into.

I have attached a zip file containing an example that works for me with NetBeans 6.8 and a very current build of GlassFish 3.1. The example simply gets a Date object for the current date and time from the server's stateless session bean and then the client displays the string equivalent.

The zip contains three projects:

SimpleTest - an EAR with an EJB submodule and an app client submodule (although the app client is not really needed for your use case)

SimpleTestCommon - a library JAR containing the EJB's remote interface

SimpleTestSA - a Java SE project containing the Java SE client

I added SimpleTestCommon as a library to the SimpleTest EJB submodule and to the SimpleTestSA Java SE client project. I also added the gf-client.jar from my GlassFish installation as a library to SimpleTestSA.

NetBeans copied the two library JARs into the SimpleTestSA/dist/lib folder - and added Class-Path references to them to the SimpleTestSA manifest.

[b]Note that we cannot rely on that copy of gf-client.jar, because of its own relative references to other GlassFish JARs which NetBeans does not copy into the dist/lib folder.[/b]

I was able to run the Java SE client from inside NetBeans normally. I could also run it successfully from outside NetBeans by using

java -classpath (path-to-my-gf-client.jar):(path-to-SimpleTestSA/dist/SimpleTestSA.jar) simpletestsa.Main

It is only by adding my installation's gf-client.jar to the runtime classpath that I made all those JARs referenced from gf-client's manifest available.

Lastly, note that I used the Java EE 6 portable JNDI name to look up the resource, as suggested by the EJB FAQ which Ken pointed to earlier.

Hope this helps.

- Tim

aszomor
Offline
Joined: 2009-08-06
Points: 0

Hi,

I looked into the MANIFEST.MF
Class-Path:
../lib/install/applications/jmsra/imqjmsra.jar
../modules/woodstox-osgi.jar
../modules/glassfish-naming.jar

which is the base directory where from these relatives, glassfish/bin or what ?

How can I resolve this, exists anyone who known it ?

Attila

tjquinn
Offline
Joined: 2005-03-30
Points: 0

Folks, the situation with the JARs is not all that complicated.

To run a client, whether it's a Java EE app client or a Java SE client that does its own look-ups, etc., you need to have the necessary GlassFish JARs physically present on the client system and logically accessible via the runtime classpath.

[b]Getting the JARs Present[/b]

If you are running on a system with GlassFish installed then that's already done. If not, then read about the package-appclient script. Its function is to gather up the files required for launching Java EE app clients, but that includes the same JARs you need to launch a Java SE client. In either case you are in control of where the files get installed and so you are in control of where the gf-client.jar file will reside.

[b]Getting the Runtime Classpath Correct[/b]

Yes, the Class-Path setting in gf-client.jar's manifest is long and intricate - but you don't have to worry about it. The paths are relative because using relative paths will work on every installation of GlassFish, regardless of where each user chooses to install it, as long as you don't move the installed files to different places after you install them.

To resolve relative paths in a JAR's Class-Path, Java SE uses the directory where the JAR file being processed resides. So, for gf-client.jar's Class-Path, the base directory is the directory where you find the gf-client.jar file - which is the modules directory in your GlassFish installation. But again, as long as you just refer to the gf-client.jar where it was installed everything works.

Now, as for getting the runtime class path set correctly, there is nothing magic about this. Long-standing Java SE behavior is that if you launch a Java app using java -jar then any -classpath setting on the command line is ignored. (see, for example, the discussion of the -jar option at http://java.sun.com/javase/6/docs/technotes/tools/solaris/java.html)

So that's why

java -classpath ${glassfish-install-dir}/modules/gf-client.jar:${path-to-your-jar} your-main-class

(all on one line, of course) will work but

java -classpath ${glassfish-install-dir}/modules/gf-client.jar -jar ${path-to-your-jar}

will not.

Does that help?

- Tim

aszomor
Offline
Joined: 2009-08-06
Points: 0

Hi,

I put the complete HelloApp NB6.8 project into previous comment, can you or anyone make a workable model from that? I think it is the most minimal project that could be, please help me resolve this problem.
I saw on the google about thousand request for help in this situation, I do not believe and unable to accept that no solution of a standalone client. If it is possible the GFv3 an unusable and uncomfortable AS for me!

Attila.

HERE IS THE "hellostub_and_testacc.sh"
-------------------------------------------------------------
#!/bin/sh
#asadmin deploy --generatermistubs --retrieve /home/user1/clientstubdir fooapp.ear
echo "get STUB"
/java/sges-v3/glassfish/bin/asadmin get-client-stubs --appname HelloApp /java/projects/HelloApp/dist
echo "start ACC"
cd /java/projects/HelloApp/dist
/java/sges-v3/glassfish/bin/appclient -client HelloAppClient.jar -name HelloApp-app-client
#echo "start EmbeddedACC"
#/java/sges-v3/glassfish/bin/appclient -client HelloAppClient.jar -name HelloApp-app-clemb
echo "start STD"
cd /java/projects/HelloApp/HelloApp-std-client/dist
GF_LIB=/java/sges-v3/glassfish/modules
export GF_LIB
CLASSPATH=$CLASSPATH:$GF_LIB
export CLASSPATH
java -cp $GF_LIB/gf-client.jar:./lib/HelloApp-com.jar -jar HelloApp-std-client.jar
cd /java/projects

HERE IS THE RESULT
----------------------------------
root@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 ACC
2010.03.10. 10:35:01 com.sun.enterprise.transaction.JavaEETransactionManagerSimplified initDelegates
INFO: Using com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate as the delegate
StatelessSession bean says : hello, world!

start STD
javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enterprise.naming.SerialInitContextFactory [Root exception is java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.(InitialContext.java:175)
at enterprise.hello_stateless_client.StandaloneStatelessJavaClient.returnMessage(StandaloneStatelessJavaClient.java:50)
at enterprise.hello_stateless_client.StandaloneStatelessJavaClient.main(StandaloneStatelessJavaClient.java:44)
Caused by: java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:46)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
... 5 more
StatelessSession bean says : null
root@aszomor:/java/projects#

aszomor
Offline
Joined: 2009-08-06
Points: 0

Hi,

The "java -jar HelloApp-std-client.jar" command is correct because the MANIFEST.MF contains the Class-Path.

One library that I made for the standalone mode and called it "SunGFv3" is contained these jars:
acc-config.jar
gf-client.jar
gf-client-module.jar
gf-connectors-connector.jar
gf-ejb-connector.jar
gf-jruby-connector.jar
gf-web-connector.jar

Here is the code, environment and the result what you ask from me.

Attila.

COMMON CODE
-------------------------
package enterprise.hello_stateless_ejb;

import javax.ejb.Remote;

@Remote
public interface StatelessSession {

public String hello();

}

SERVER CODE
------------------------
package enterprise.hello_stateless_ejb;

import javax.ejb.Stateless;

@Stateless
public class StatelessSessionBean implements StatelessSession {

public String hello() {
return "hello, world!\n";
}

}

APPLICATION CLIENT CODE
--------------------------------------------
package enterprise.hello_stateless_client;

import javax.ejb.EJB;
import enterprise.hello_stateless_ejb.StatelessSession;

public class StatelessJavaClient {

@EJB
private static StatelessSession sless;

public static void main(String args[]) {
System.out.println("StatelessSession bean says : " + returnMessage());
}

public static String returnMessage() {

try {
return (sless.hello());

} catch(Exception e) {
e.printStackTrace();
}

return null;
}

}

STANDALONE CLIENT CODE
---------------------------------------------
package enterprise.hello_stateless_client;

import javax.naming.InitialContext;
import enterprise.hello_stateless_ejb.StatelessSession;

public class StandaloneStatelessJavaClient {

public static void main(String args[]) {
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/HelloApp/HelloApp-ejb/StatelessSessionBean");
return (sless.hello());

} catch(Exception e) {
e.printStackTrace();
}

return null;
}

}

0, My Ubuntu 9.10 (64bit)'s environment is
--------------------------------------------------------------
ANT_HOME=/java/netbeans-6.8/java3/ant
ANT_PATH=/java/netbeans-6.8/java3/ant/bin
BASH=/bin/bash
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="4" [1]="0" [2]="33" [3]="1" [4]="release" [5]="x86_64-pc-linux-gnu")
BASH_VERSION='4.0.33(1)-release'
CLASSPATH=/java/jdk1.6.0_18/jre/lib:/java/jdk1.6.0_18/lib:.:./lib:./ext
COLORTERM=gnome-terminal
COLUMNS=158
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-P6TtNgDYMt,guid=6cd657eab1badc652005b6324b960e0c
DESKTOP_SESSION=gnome
DIRSTACK=()
DISPLAY=:0.0
EUID=0
GDK_NATIVE_WINDOW=1
GDMSESSION=gnome
GDM_KEYBOARD_LAYOUT=$'us\tintl'
GDM_LANG=hu_HU.UTF-8
GF_HOME=/java/sges-v3/glassfish
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
GNOME_KEYRING_PID=1954
GNOME_KEYRING_SOCKET=/tmp/keyring-mMj1zn/socket
GPG_AGENT_INFO=/tmp/seahorse-m8ocUh/S.gpg-agent:2037:1
GROUPS=()
GTK_MODULES=canberra-gtk-module
GTK_RC_FILES=/etc/gtk/gtkrc:/root/.gtkrc-1.2-gnome2
HISTCONTROL=ignorespace
HISTFILE=/root/.bash_history
HISTFILESIZE=500
HISTSIZE=500
HOME=/root
HOSTNAME=aszomor
HOSTTYPE=x86_64
IFS=$' \t\n'
JAVA_HOME=/java/jdk1.6.0_18
JAVA_PATH=/java/jdk1.6.0_18/bin
LANG=hu_HU.UTF-8
LESSCLOSE='/usr/bin/lesspipe %s %s'
LESSOPEN='| /usr/bin/lesspipe %s'
LINES=43
LOGNAME=root
LS_COLORS='rs=0:di=01;34:ln=01;36:hl=44;37:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:'
MACHTYPE=x86_64-pc-linux-gnu
MAILCHECK=60
MC_SID=4428
MC_TMPDIR=/tmp/mc-root
OLDPWD=/
OPTERR=1
OPTIND=1
ORBIT_SOCKETDIR=/tmp/orbit-root
OSTYPE=linux-gnu
PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/java/jdk1.6.0_18/bin:/java/netbeans-6.8/java3/ant/bin:~/bin'
PIPESTATUS=([0]="0")
PLUGIN_HOME=/java/jre1.6.0_18/plugin
PPID=4426

1, Deploy HelloApp into GlassFish v3 Domain1
--------------------------------------------------------------------
INFO: Security startup service called
INFO: SEC1143: Loading policy provider com.sun.enterprise.security.provider.PolicyWrapper.
INFO: Realm admin-realm of classtype com.sun.enterprise.security.auth.realm.file.FileRealm successfully created.
INFO: Realm file of classtype com.sun.enterprise.security.auth.realm.file.FileRealm successfully created.
INFO: Realm certificate of classtype com.sun.enterprise.security.auth.realm.certificate.CertificateRealm successfully created.
INFO: Security service(s) started successfully....
INFO: JTS5014: Recoverable JTS instance, serverId = [3700]
INFO: Portable JNDI names for EJB StatelessSessionBean : [java:global/HelloApp/HelloApp-ejb/StatelessSessionBean!enterprise.hello_stateless_ejb.StatelessSession, java:global/HelloApp/HelloApp-ejb/StatelessSessionBean]
INFO: Glassfish-specific (Non-portable) JNDI names for EJB StatelessSessionBean : [enterprise.hello_stateless_ejb.StatelessSession, enterprise.hello_stateless_ejb.StatelessSession#enterprise.hello_stateless_ejb.StatelessSession]
INFO: WELD-000900 1.0.0 (SP4)
INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
INFO: nullID: /java/projects-6.8/HelloApp/dist/gfdeploy/HelloApp/HelloApp-app-client_jar/ CLASSES: [class enterprise.hello_stateless_client.StatelessJavaClient]
ID: /java/projects-6.8/HelloApp/dist/gfdeploy/HelloApp/HelloApp-app-clemb_jar/ CLASSES: [interface enterprise.hello_stateless_ejb.StatelessSession, class enterprise.hello_stateless_client.EmbStatelessJavaClient] ID: /java/projects-6.8/HelloApp/dist/gfdeploy/HelloApp/HelloApp-ejb_jar/ CLASSES: [class enterprise.hello_stateless_ejb.StatelessSessionBean]ID: /java/projects-6.8/HelloApp/dist/gfdeploy/HelloApp/HelloApp-app-clemb_jar/ CLASSES: [interface enterprise.hello_stateless_ejb.StatelessSession, class enterprise.hello_stateless_client.EmbStatelessJavaClient]
ID: /java/projects-6.8/HelloApp/dist/gfdeploy/HelloApp/HelloApp-app-client_jar/ CLASSES: [class enterprise.hello_stateless_client.StatelessJavaClient] ID: /java/projects-6.8/HelloApp/dist/gfdeploy/HelloApp/HelloApp-ejb_jar/ CLASSES: [class enterprise.hello_stateless_ejb.StatelessSessionBean]ID: /java/projects-6.8/HelloApp/dist/gfdeploy/HelloApp/HelloApp-ejb_jar/ CLASSES: [class enterprise.hello_stateless_ejb.StatelessSessionBean]
ID: /java/projects-6.8/HelloApp/dist/gfdeploy/HelloApp/HelloApp-app-client_jar/ CLASSES: [class enterprise.hello_stateless_client.StatelessJavaClient] ID: /java/projects-6.8/HelloApp/dist/gfdeploy/HelloApp/HelloApp-app-clemb_jar/ CLASSES: [interface enterprise.hello_stateless_ejb.StatelessSession, class enterprise.hello_stateless_client.EmbStatelessJavaClient]
INFO: ACDEPL103: Java Web Start services started for the app client HelloApp/HelloApp-app-clemb.jar (contextRoot: /HelloApp/HelloApp-app-clemb)
INFO: ACDEPL103: Java Web Start services started for the app client HelloApp/HelloApp-app-client.jar (contextRoot: /HelloApp/HelloApp-app-client)
INFO: HelloApp was successfully deployed in 9 892 milliseconds.

2, Generate stub for HelloAppClient
---------------------------------------------------
/java/sges-v3/glassfish/bin/asadmin get-client-stubs --appname HelloApp /java/projects/HelloApp/dist
THE RESULT IS:
--------------------------
Authentication failed with password from login store: /root/.asadminpass
Enter admin password for user "admin">

Command get-client-stubs executed successfully.

3, Start HelloAppClient
---------------------------------
cd /java/projects/HelloApp/dist
/java/sges-v3/glassfish/bin/appclient -client HelloAppClient.jar -name HelloApp-app-client
THE RESULT IS:
-------------------------
2010.03.10. 8:45:28 com.sun.enterprise.transaction.JavaEETransactionManagerSimplified initDelegates
INFO: Using com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate as the delegate
StatelessSession bean says : hello, world!

4a, HelloApp Standalone Client environment
-----------------------------------------------------------------
/java/projects/HelloApp/HelloApp-std-client/dist/lib
acc-config.jar
gf-client.jar
gf-client-module.jar
gf-connectors-connector.jar
gf-ejb-connector.jar
gf-jruby-connector.jar
gf-web-connector.jar
HelloApp-com.jar
javaee-api-6.0.jar
/java/projects/HelloApp/HelloApp-std-client/dist
HelloApp-std-client.jar

4b, The MANIFEST.MF in HelloApp-std-client.jar
-----------------------------------------------------------------------
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: 16.0-b13 (Sun Microsystems Inc.)
Main-Class: enterprise.hello_stateless_client.StandaloneStatelessJavaC
lient
Class-Path: lib/javaee-api-6.0.jar lib/acc-config.jar lib/gf-client-mo
dule.jar lib/gf-client.jar lib/gf-connectors-connector.jar lib/gf-ejb
-connector.jar lib/gf-jruby-connector.jar lib/gf-web-connector.jar li
b/HelloApp-com.jar

4c, Start HelloApp Standalone Client
-----------------------------------------------------
cd /java/projects/HelloApp/HelloApp-std-client/dist
java -jar HelloApp-std-client.jar
THE RESULT IS:
-------------------------
javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enterprise.naming.SerialInitContextFactory [Root exception is java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.(InitialContext.java:175)
at enterprise.hello_stateless_client.StandaloneStatelessJavaClient.returnMessage(StandaloneStatelessJavaClient.java:50)
at enterprise.hello_stateless_client.StandaloneStatelessJavaClient.main(StandaloneStatelessJavaClient.java:44)
Caused by: java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:46)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
... 5 more
StatelessSession bean says : null

Witold Szczerba

2010/3/10 :
> Hi,
>
> The "java -jar HelloApp-std-client.jar" command is correct because the MANIFEST.MF contains the Class-Path.
>
> One library that I made for the standalone mode and called it "SunGFv3" is contained these jars:
>  acc-config.jar
>  gf-client.jar
>  gf-client-module.jar
>  gf-connectors-connector.jar
>  gf-ejb-connector.jar
>  gf-jruby-connector.jar
>  gf-web-connector.jar
>
> Here is the code, environment and the result what you ask from me.
>
> Attila.

Try this: get rid of all the above JARs from MANIFEST.MF and launch
application with:

GF_LIB=/path/to/gf3/glassfish/modules
java -cp $GF_LIB/gf-client.jar -jar HelloApp-std-client.jar

and see if that works. The problem with Glassfish v3 client JARs is
that one JAR references another, the another references dozen others
and those others bla bla bla....
So, pointing to gf-client.jar in Glassfish v3 directory is not the
same as copying that file to another location, because that one tiny
gf-client.jar references dozens of another tiny JARs in relative
locations.

Just take a look at gf-client.jar's manifest:
unzip -p gf-client.jar META-INF/MANIFEST.MF
you will see the real hell :/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

aszomor
Offline
Joined: 2009-08-06
Points: 0

Hi,

The code is the HelloApp code which is borrowed from javaee6-samples-1.0-b03-installer.jar!
You can see it into my today's "Unusable Stateless EJB after GFv3 update" forum article.

THE ACC COMMANDS and RESULTS
-------------------------------------------------------
/java/sges-v3/glassfish/bin/asadmin get-client-stubs --appname HelloApp /java/projects/HelloApp/dist
--- Command get-client-stubs executed successfully
/java/sges-v3/glassfish/bin/appclient -client HelloAppClient.jar -name HelloApp-app-client
--- 2010.03.09. 15:21:35 com.sun.enterprise.transaction.JavaEETransactionManagerSimplifiedinitDelegates
--- INFO: Using com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate as the delegate
--- StatelessSession bean says : hello, world!

THE STAND-ALONE COMMAND
-----------------------------------------------
java -jar HelloAppStandalone.jar
--- The exception is com.sun.enterprise.naming.SerialInitContextFactory not found, becouse the gf-*.jar do not implement it !

I will send you the complet source of project tomorrow from my workplace.

Attila.

ksak
Offline
Joined: 2005-05-20
Points: 0

The stand-alone command "java -jar HelloAppStandalone.jar" is wrong. The classpath needs to refer to gf-client.jar or appserv-rt.jar from the glassfish installation directory (Step 3 of the EJB FAQ entry)

Deepu Syamaladevi Janardhananachary (UST, IND)

What about this one?

Glassfish>bin>appclient -client HelloAppStandalone.jar

Regards,

Deepu Janardhananachary

-----Original Message-----
From: glassfish@javadesktop.org [mailto:glassfish@javadesktop.org]
Sent: Wednesday, March 10, 2010 2:32 AM
To: users@glassfish.dev.java.net
Subject: Re: Standalone client of GlassFish v3

The stand-alone command "java -jar HelloAppStandalone.jar" is wrong. The classpath needs to refer to gf-client.jar or appserv-rt.jar from the glassfish installation directory (Step 3 of the EJB FAQ entry)

[Message sent by forum member 'ksak' (kenneth.saks@sun.com)]

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

---------------------------------------------------------------------

To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net

For additional commands, e-mail: users-help@glassfish.dev.java.net

[att1.html]

aszomor
Offline
Joined: 2009-08-06
Points: 0

Hi

I readed this article uncountable times, but not helped fro me.
This article very good for GFv2.1 and JEE5 on this platform the stand-alone client vorking fine.
I the GFv3 the com.sun.enterprise.naming.SerialInitContextFactory does not implemented in client side, thus the stand-alone clients unable to connect to the server, I tried the Application Client too that is working fine and from the webcontainer working fine too because glassfish-naming.jar contains the SerialInitContextFactory.
I would like to connect to the server from Swing or RCP client which are not implemented the ACC yet thus impossible do this.
I readed an article from GFv3.1 which will be implement the appsrv-rt.jar for this reason, but I do not known is it a right article or not.

Please who known about from it tell it us.

Thanks, Attila.

ksak
Offline
Joined: 2005-05-20
Points: 0

Can you please post the java command you're using to start the Java SE client and the source code of the lookup(), as well as the full stack trace of the error.

ksak
Offline
Joined: 2005-05-20
Points: 0

Instructions for stand-alone client access are detailed here : https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#StandaloneRemoteEJB

catman
Offline
Joined: 2003-06-12
Points: 0

I've read that and it's unworkable. My clients do NOT have an installed glassfish, the jar list inside the gf-client.jar is ridiculous!!!! It includes 145 jars, including things like Derby jars which I know I have no need for. It includes enough jars to run a server, not satisfy just the clients needs. What jars do I need for a Stand Alone client to connect to a Cluster JMS and to access clustered EJB on glassfish, the absolute thinnest possible?

David Zhao

Please read this document to set up your environment for jms client. http://docs.oracle.com/cd/E26576_01/doc.312/e24945/overview.htm#aeqar

 

Table 1-1 .jar Files Needed in CLASSPATH

Type of Code

To Compile

To Run

Remarks

JMS client

jms.jar imq.jar jndi.jar

jms.jar imq.jar jndi.jar

Directory containing compiled Java application or '.'

See discussion of JNDI .jar files, following this table.

 

 

Thanks,

David Zhao

 

> -----Original Message-----

> From: forums@java.net [mailto:forums@java.net]

> Sent: Monday, March 25, 2013 10:01 PM

> To: users@glassfish.java.net

> Subject: Re: Standalone client of GlassFish v3

>

> I've read that and it's unworkable. My clients do NOT have an installed

> glassfish, the jar list inside the gf-client.jar is ridiculous!!!! It

> includes 145 jars, including things like Derby jars which I know I have

> no need for. It includes enough jars to run a server, not satisfy just

> the clients needs. What jars do I need for a Stand Alone client to

> connect to a Cluster JMS and to access clustered EJB on glassfish, the

> absolute thinnest possible?

>

> --

>

> [Message sent by forum member 'catman']

>

> View Post: http://forums.java.net/node/701865

>

>