Skip to main content

Glassfish V3 + Standalone client lookup session bean JNDI

25 replies [Last post]
fbaudino
Offline
Joined: 2009-11-14

First sorry by my english, i'm spanish.

After search and search for a tip or documentation to know how lookup a session bean with GF V3 from standalone remote client i work hardly to find the minimal required JARS to lookup session bean.

I attach a PNG with the jars that the standalone client must reference and have in the classpath.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ansis
Offline
Joined: 2006-08-11

Dear Attila,

did you also try your solution in an Eclipse Plugin? Things work a bit differently there, because of its OSGI foundation. There is no global (class)path and you cannot pass arguments in the command line. Instead you have to specify all these settings in the Plugin (bundle) MANIFEST.MF.

If you can connect to GFv3, then please let us know. We've been stuck for weeks now.

Thanks,
Andreas (Budapest)

aszomor
Offline
Joined: 2009-08-06

Dear Andreas,

We have the same problem with Eclipse RCP.
Fortunatly (I hope) NetBeans 9 RC1 and GFv3.1_M1 are issued and the NB9 is support the RCP developing thus possible we find a solution there that we can adopt in Eclipse.

Attila (Pécs)

ansis
Offline
Joined: 2006-08-11

Attila,

I downloaded yesterday GFv3.1M1(latest) and tried to connect from Eclipse - even less success than with GFv3!! And no Jar called gf-acc.jar :- (

Perhaps we could cooperate on finding a solution. My skype name is ankozma - can you please contact me?

- Andreas

tjquinn
Offline
Joined: 2005-03-30

Andreas,

gf-acc.jar?

GlassFish does not include such a JAR. It does include gf-client.jar. Is that what you meant, and is that missing from your download?

Also, people following this thread might also want to follow this one:

http://forums.java.net/jive/thread.jspa?threadID=73133&start=0&tstart=0

- Tim

ansis
Offline
Joined: 2006-08-11

Attila,

as I mentioned previously, the JavaSE situation works for as you are describing, there are no problems.

Where we have our problems is when we want to do a lookup to a remote GFv3 server from an ECLIPSE RCP client.

Do you have a working configuration there?

Thanks,
- Andreas

ansis
Offline
Joined: 2006-08-11

Tim

I followed your instructions. In point 3) I just added the gf-client.jar to the plugin classpath, so the MANIFEST.MF part read:

Bundle-ClassPath: lib/aef-util.jar, lib/timetracker.jar, modules/gf-client.jar

However, I immediately got a ClassDefNotFound exception for some class in one of the Jars. This leads me to believe that I need to list all Jars in the bundle-classpath, it is not enough if they are referenced through the MANIFEST.MF of the gf-client.jar, presumably because gf-client.jar is not an OSGI bundle.

When I added all Jars in ${clientInstallRoot}/appclient/glassfish/modules to the bundle-classpath, I got the following exception:

java.lang.LinkageError: Failed to inject class com.sun.enterprise.v3.server.ServerContextImpl from org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@8824ae2
at org.jvnet.hk2.component.InjectionManager.inject(InjectionManager.java:163)
at com.sun.hk2.component.AbstractWombImpl.inject(AbstractWombImpl.java:170)
at com.sun.hk2.component.ConstructorWomb$1.run(ConstructorWomb.java:87)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.hk2.component.ConstructorWomb.initialize(ConstructorWomb.java:84)
at com.sun.hk2.component.AbstractWombImpl.get(AbstractWombImpl.java:77)
at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:58)
at com.sun.hk2.component.LazyInhabitant.get(LazyInhabitant.java:107)
at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:60)
at org.jvnet.hk2.component.Habitat.getByContract(Habitat.java:594)
at com.sun.enterprise.naming.impl.SerialContext.(SerialContext.java:243)
at com.sun.enterprise.naming.impl.SerialContext.(SerialContext.java:253)
at com.sun.enterprise.naming.impl.SerialInitContextFactory.createInitialContext(SerialInitContextFactory.java:121)
at com.sun.enterprise.naming.impl.SerialInitContextFactory.getInitialContext(SerialInitContextFactory.java:116)
at com.sun.enterprise.naming.SerialInitContextFactory.getInitialContext(SerialInitContextFactory.java:65)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.(InitialContext.java:197)
at com.ansis.timetracker.server.util.ConnectionDetails.getInitialContext(ConnectionDetails.java:164)
at com.ansis.timetracker.client.ClientActivator.getActivityTrackerBean(ClientActivator.java:921)
at com.ansis.timetracker.client.ClientActivator.lookup(ClientActivator.java:902)
at com.ansis.timetracker.client.ClientActivator.access$12(ClientActivator.java:896)
at com.ansis.timetracker.client.ClientActivator$6.executeServerCommand(ClientActivator.java:767)
at com.ansis.timetracker.client.core.Operation.run(Operation.java:59)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.lang.NoClassDefFoundError: org/jvnet/hk2/config/ConfigBeanProxy
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:183)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(ClasspathManager.java:576)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(ClasspathManager.java:546)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:477)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass_LockClassLoader(ClasspathManager.java:465)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:445)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:211)
at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:381)
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:457)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:398)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getDeclaredMethods(Class.java:1791)
at org.jvnet.hk2.component.InjectionManager.inject(InjectionManager.java:111)
... 25 more
Caused by: java.lang.ClassNotFoundException: org.jvnet.hk2.config.ConfigBeanProxy
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:494)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:398)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 45 more

When I added back all the Jars from the GF/modules dir, my first lookup was successful, but on the second and all subsequent lookups, I received the java.lang.LinkageError listed in my earlier post.

What could be the problem here? This blocker is keeping us from adapting GFv3.

It would save a LOT of time, if the GF team could publish concrete guidelines for Eclipse, NetBeans-based RCP clients.

Many thanks,
- Andreas

tjquinn
Offline
Joined: 2005-03-30

The original poster did not mention Eclipse or OSGi, just a Java SE client. The directions I mentioned should work just fine for that use case.

Eclipse is a different story as you point out. We'll see if there is some definitive explanation we can offer. Let me point the right people to this (and some other related and active) topics.

- Tim

ansis
Offline
Joined: 2006-08-11

Tim, that would be absolutely fantastic.

Unfortunately I have to say that RMI/IIOP as a client access method is by far not as well supported/documented as access through a web application. We migrated from JBoss to GFv2.1 a bit more than a year ago and overall we are very happy.

But the area of standalone java client access and on top of that from an OSGI-based Eclipse architecture has always been very difficult, because it's extremely hard to find any information other than posts from peers, who are also trying to proceed through trial and error. I am sure there are many other struggling developers out there like us.

It would a great help, if you could give us some Eclipse specific best practice examples for GFv3 including authentication (is ProgrammaticLogin really the best solution?) and size-optimization of required Jars, etc. These are all important matters when one tries to create a usable entreprise system. We would very happy to contribute to perhaps updating the EJB-FAQ with such a section.

- Andreas

aszomor
Offline
Joined: 2009-08-06

Hi,

You must copy all of glassfish/modules and glassfis/lib into the client pc and you must put them with global path into the starter line thus will work.

See example in HelloApp_LoginModule.zip.
hellostub_and_testacc.sh
--------------------------------------
java -cp /java/sges-v3/glassfish/modules/gf-client.jar:/java/sges-v3/glassfish/modules/security.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

I read that nearly will be GFv3.1 M' downloadabled and that will contain a special gf-acc.jar for this reason.

Best Regards, Attila.

Martin Gainty

...you should mention this is NOT browser based...

Martin Gainty
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.

Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.

> Date: Sun, 23 May 2010 01:20:38 -0700
> From: glassfish@javadesktop.org
> To: users@glassfish.dev.java.net
> Subject: Re: Glassfish V3 + Standalone client lookup session bean JNDI
>
> Hi,
>
> You must copy all of glassfish/modules and glassfis/lib into the client pc and you must put them with global path into the starter line thus will work.
>
> See example in HelloApp_LoginModule.zip.
> hellostub_and_testacc.sh
> --------------------------------------
> java -cp /java/sges-v3/glassfish/modules/gf-client.jar:/java/sges-v3/glassfish/modules/security.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
>
> I read that nearly will be GFv3.1 M' downloadabled and that will contain a special gf-acc.jar for this reason.
>
> Best Regards, Attila.
> [Message sent by forum member 'aszomor']
>
> http://forums.java.net/jive/thread.jspa?messageID=471095
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>

_________________________________________________________________
The New Busy is not the old busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:...
[att1.html]

lft
Offline
Joined: 2010-04-07

Our stand-alone client application need to be transferred through java web start. So I figured out my libs list that working with java standalone client and ProgrammaticLogin authentication mechanism. Using this list of libs you can follow instructions posted here: https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#StandaloneRemoteEJB.
appclient.security.jar
auto-depends.jar
common-util.jar
config-api.jar
config.jar
config-types.jar
connectors-admin.jar
connectors-inbound-runtime.jar
connectors-internal-api.jar
connectors-runtime.jar
container-common.jar
deployment-common.jar
dol.jar
ejb-container.jar
ejb-internal-api.jar
ejb.security.jar
glassfish-api.jar
glassfish-corba-asm.jar
glassfish-corba-codegen.jar
glassfish-corba-csiv2-idl.jar
glassfish-corba-newtimer.jar
glassfish-corba-omgapi.jar
glassfish-corba-orbgeneric.jar
glassfish-corba-orb.jar
glassfish.jar
glassfish-naming.jar
gmbal.jar
hk2-core.jar
internal-api.jar
javax.ejb.jar
kernel.jar
management-api.jar
orb-connector.jar
orb-enabler.jar
orb-iiop.jar
security.jar
tiger-types-osgi.jar

The only problem is that using ProgrammaticLogin, the first invocation of secure bean's method is very slow.

best regards

ansis
Offline
Joined: 2006-08-11

Dear fbaudino,

I am struggling with the same problem that I wouldn't like to copy ALL jars in GFv3/modules dir to my remote standalone java client (in my case an Eclipse RCP client) to avoid the big size.

I tried your short list, but I got a misterious CORBA_NO_PERMISSION exception when looking up my first session bean. When putting all jars from modules dir onto plugin class path, the exception didn't appear.

Do you know which other jar(s) is/are missing still?

Everybody: we are struggling a lot and I see many others struggling as well in connecting a REMOTE standalone java client to GFv3. It would be EXTREMELY useful, if those who managed to connect to GFv3 successfully could post their configurations and we could together determine the smallest number of required Jars required.

I attach my MANIFEST.MF listing all jars from module menu. I know not all are necessary, but I don't know which ones are unnecessary.

- Andreas

ritzjp
Offline
Joined: 2010-01-04

Hello
I had the same problem and did a lot of research finally I resolved it by adding the following jar's. If I remove one of the package I had a lookup failure. Try to ad it in a folder and add it to the classpath

auto-depends.jar
common-util.jar
config.jar
config-api.jar
config-types.jar
connectors-internal-api.jar
deployment-common.jar
dol.jar
ejb.security.jar
ejb1.jar
ejb-container.jar
ejb-internal-api.jar
gf-client-module.jar
glassfish-api.jar
glassfish-corba-asm.jar
glassfish-corba-codegen.jar
glassfish-corba-csiv2-idl.jar
glassfish-corba-newtimer.jar
glassfish-corba-omgapi.jar
glassfish-corba-orb.jar
glassfish-corba-orbgeneric.jar
glassfish-naming.jar
gmbal.jar
hibernate3.jar
hk2-core.jar
internal-api.jar
javax.ejb.jar
kernel.jar
management-api.jar
orb-connector.jar
orb-iiop.jar
security.jar
tiger-types-osgi.jar

than try this code per default it search on localhost server

try {
System.out.println("lookup");
ejb = (RemoteCustomer) new InitialContext()
.lookup("java:global/jeprEJBCustomer/EJBCustomer");
System.out.println("context intizialisated");
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

ansis
Offline
Joined: 2006-08-11

Thanks for your reply. I tried your list and I get the following exception:

com.ansis.timetracker.server.exception.TTRuntimeException: Error looking up ActivityTrackerBeanRemote:
at com.ansis.timetracker.client.ClientActivator.getActivityTrackerBean(ClientActivator.java:923)
at com.ansis.timetracker.client.ClientActivator.lookup(ClientActivator.java:902)
at com.ansis.timetracker.client.ClientActivator.access$12(ClientActivator.java:896)
at com.ansis.timetracker.client.ClientActivator$6.executeServerCommand(ClientActivator.java:767)
at com.ansis.timetracker.client.core.Operation.run(Operation.java:59)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: javax.naming.NamingException: Lookup failed for 'java:global/com.ansis.timetracker.server/timetracker-ejb/ActivityTrackerBean' in SerialContext targetHost=localhost,targetPort=30037,orb'sInitialHost=localhost,orb'sInitialPort=3700 [Root exception is javax.naming.NamingException: ejb ref resolution error for remote business interfacecom.ansis.timetracker.server.session.remote.ActivityTrackerBeanRemote [Root exception is java.lang.RuntimeException: Could not invoke defineClass!]]
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:442)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.ansis.timetracker.client.ClientActivator.getActivityTrackerBean(ClientActivator.java:921)
... 5 moreLog [Thu May 20 20:52:19 CEST 2010]: 1delay value in delayNextTry: 60000

Caused by: javax.naming.NamingException: ejb ref resolution error for remote business interfacecom.ansis.timetracker.server.session.remote.ActivityTrackerBeanRemote [Root exception is java.lang.RuntimeException: Could not invoke defineClass!]
at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:430)
at com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:70)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance(SerialContext.java:472)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:437)
... 7 more
Caused by: java.lang.RuntimeException: Could not invoke defineClass!
at com.sun.corba.ee.impl.orbutil.codegen.CodeGeneratorUtil.makeClass(CodeGeneratorUtil.java:98)
at com.sun.corba.ee.spi.orbutil.codegen.Wrapper._generate(Wrapper.java:1102)
at com.sun.corba.ee.spi.orbutil.codegen.Wrapper._generate(Wrapper.java:1086)
at com.sun.ejb.EJBUtils.generateAndLoad(EJBUtils.java:586)
at com.sun.ejb.EJBUtils.loadGeneratedGenericEJBHomeClass(EJBUtils.java:538)
at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:399)
... 11 more
Caused by: 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 com.sun.corba.ee.impl.orbutil.codegen.CodeGeneratorUtil.makeClass(CodeGeneratorUtil.java:95)
... 16 more
Caused by: java.lang.LinkageError: loader (instance of org/eclipse/core/runtime/internal/adaptor/ContextFinder): attempted duplicate class definition for name: "com/sun/ejb/codegen/GenericEJBHome_Generated"
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
... 21 more

If I add transaction-internal-api.jar, then I get CORBA.NO_PERMISSION for the first lookup, then same as above. It's really quite strange.

Is you standalone client running on Eclipse or NetBeans or just Java SE?

ritzjp
Offline
Joined: 2010-01-04

My standalone client run under eclipse

What did you give in as jndi name can you give the code

ansis
Offline
Joined: 2006-08-11

Here is the code that we use to connect from Eclipse RCP client to GFv3 (this worked fine for GFv2.1.1):

1.) First we create the properties for the InitialContext:

final Properties props = new Properties();
props.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
props.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");

// Only needed if server is running on a different host than localhost:
if (!StringUtils.isEmpty(getServer()))
props.setProperty("org.omg.CORBA.ORBInitialHost", getServer());
// Optional. Defaults to 3700. Only needed if target orb port is not 3700.
if (!StringUtils.isEmpty(getPortNumber()))
props.setProperty("org.omg.CORBA.ORBInitialPort", getPortNumber());

2.) then we create the InitialContext using ProgrammaticLogin for proper permission handling:

// --------------------- -----------------------

Configuration.setConfiguration(new Configuration() {

@Override
public AppConfigurationEntry[] getAppConfigurationEntry(final String name) {

final Map options = new HashMap();
options.put("debug", new Boolean(false));

if ("default".equals(name))
return new AppConfigurationEntry[] {new AppConfigurationEntry("com.sun.enterprise.security.auth.login.ClientPasswordLoginModule", LoginModuleControlFlag.REQUIRED, options)};
if ("certificate".equals(name))
return new AppConfigurationEntry[] {new AppConfigurationEntry("com.sun.enterprise.security.auth.login.ClientCertificateLoginModule", LoginModuleControlFlag.REQUIRED, options)};

throw new TTRuntimeException("New Configuration was asked for: " + name + ", but it should have been default or certificate!");
}

@Override
public void refresh() {
// we don't need to refresh anything!
}

});

final ProgrammaticLogin pm = new ProgrammaticLogin();
final boolean success = pm.login(getUser(), getPassword());
if (!success)
log.warn("Setup of login unsuccessful!");

try {
context = new InitialContext(createPropertiesExisting());
} catch (final NamingException e) {
throw new TTRuntimeException("Error while logging in", e);
}

3.) Then we execute the lookup:

try {
activityTrackerBean = (ActivityTrackerBeanRemote) context.lookup(ActivityTrackerBeanRemote.JNDIName);
} catch (final NamingException e) {
throw new RuntimeException("Error looking up ActivityTrackerBeanRemote: ", e);
}

JNDI Name:
ActivityTrackerBeanRemote.JNDIName
= "java:global/com.ansis.timetracker.server/timetracker-ejb/ActivityTrackerBean"

This is written out by GFv3 at deployment as portable JNDI name.

This code works properly when executed from a unit test environment, ie. javaSE on same machine, with all GFv3/modules Jars on class path.

However, as described earlier, when running within our Eclipse plugin, it produces the above described exceptions when looking up the SECOND session bean. The order of lookup doesn't matter, the first is always looked up. When we try to lookup the second, we hit the exception.

What is the plugin architecture you are using? Could you post your structure and your MANIFEST.MF's of your plugins?

pichur
Offline
Joined: 2010-10-11

I avoid the same problem by put following code:

Class clazz = Class.forName(this.getClass().getName());
Thread thread = Thread.currentThread();
ClassLoader classLoaderThread = thread.getContextClassLoader();
System.out.println("ClassLoader for Thread : " + classLoaderThread);
ClassLoader classLoaderClass = clazz.getClassLoader();
System.out.println("ClassLoader for Class : " + classLoaderClass);
thread.setContextClassLoader(classLoaderClass);

before the "context.lookup".
This change:
ClassLoader for Thread : org.eclipse.core.runtime.internal.adaptor.ContextFinder@1970ae0
to:
ClassLoader for Class : org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@d19bc8
and works (at least in my case).

Best regards
Piotrek

aszomor
Offline
Joined: 2009-08-06

Hi,

You will find some examples in these threads:

Standalone client of GlassFish v3:
----------------------------------
http://forums.java.net/jive/thread.jspa?messageID=390832&#390832
--SimpleTestSA.zip (818.0 K)
--HelloApp.zip (45.5 K)

JDBCRealm from Swing GUI:
--------------------------
http://forums.java.net/jive/thread.jspa?messageID=398210&#398210
--HelloApp.zip (836.2 K)
--HelloAppJDBCRealmSetup.txt (3.0 K)

GFv3 Custom Principal:
-----------------------
http://forums.java.net/jive/message.jspa?messageID=470144#470144
--HelloApp_LoginModule.zip (118.0 K)

appclient doesn't work:
-----------------------
http://forums.java.net/jive/thread.jspa?messageID=394132&#394132

Best Regards, Attila.
--
Hungary, Pécs is the European Capital of Culture in 2010

ansis
Offline
Joined: 2006-08-11

Dear Attila

we are a team working out of Budapest. We develop on GFv2.1.1 and would like to migrate to GFv3. Have you managed to connect a REMOTE standalone client to GFv3 and if yes, which jars were on your classpath?

perhaps we could share some ideas. Thanks.

tjquinn
Offline
Joined: 2005-03-30

Everyone,

Note that for GlassFish 3 remote connectivity for Java SE clients, you should:

1. Use the package-appclient script on the server. This creates a JAR which contains all the files the remote client system will need.

2. Take that JAR to the remote system and expand it into the directory of your choice. Call it ${clientInstallRoot}.

3. Add ${clientInstallRoot}/appclient/glassfish/modules/gf-client.jar to your runtime class path.

You do not need to - and should not try - to figure out the full list of JARs and add them to your application's Class-Path manifest setting. The list might change over time but gf-client.jar will always have the correct Class-Path setting for all the required JARs.

If you follow these steps and still have trouble, please let us know.

- Tim

ansis
Offline
Joined: 2006-08-11

Tim,

I understand your point, but in Eclipse it is not enough to just put the gf-client.jar onto the classpath of the plugin, because of its OSGI based architecture. All Jars need to be listed explicitly as it seems based on our tests.

It would extremely useful if you (or somebody from the GFv3 team) could publish guidelines for Eclipse RCP clients, ie. what plugin(s) is/are required and the MANIFEST.MF of each plugin.

Many thanks in advance,
- Andreas

tjquinn
Offline
Joined: 2005-03-30

Please see this entry in the EJB FAQ:

https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#StandaloneRemoteEJB

Make sure to follow the directions for GlassFish 3. (They are different for GlassFish 2.)

Briefly, just include in your class path the gf-client.jar file from the modules directory of the GlassFish 3 installation. Make sure to read the other suggestions in the FAQ to look up the bean correctly.

Good luck.

- Tim

fbaudino
Offline
Joined: 2009-11-14

Thanks Tim, the FAQ is a more simple way than the other.

However, i think that way (only reference the gf-client.jar) only works if Glassfish is in the same machine as the standalone client, that's ok? (because if the client are remote is not posible to reference glassfish installation folder)

tjquinn
Offline
Joined: 2005-03-30

You can use the package-appclient script that comes with GlassFish to create a JAR containing all the JARs needed on a remote client, whether for launching a Java EE app client or a Java SE client (as you are doing).

It's still a longer list than we'd like, but it does capture all you'll need.

It is important to note that once you expand the JAR you should not move the JARs around on the remote client system -- unless you move them all together and keep them in the same relative relationship with each other. The gf-client.jar contains a long Class-Path which uses relative references to the other JARs.

- Tim

richierich
Offline
Joined: 2006-06-15

Hi

I followed these instructions for a Tomcat 7 client and when I add gf-client.jar to the Tomcat classpath, either via the script mentioned or directly referenced in the GF 3.1 install directory, I get this Tomcat startup error (and TC fails to start):

23-Nov-2012 13:08:17 org.apache.tomcat.util.digester.Digester startElement
SEVERE: Begin event threw exception
java.lang.ClassNotFoundException: org.apache.catalina.core.AprLifecycleListener
at java.net.URLClassLoader$1.run(Unknown Source)

This is for a project which worked fine under GF 5 albeit with EJB access from GF not Tomcat (moving to TC for other reasons for web apps, but they also fail now to deploy to GF 3).

Is there anything wrong with using the standard Tomcat provider classes to do this rather than bolting on the GF provider, e.g. as below ? I haven't been able to get this to work, having said that, which is why I've been trying the GF provider classes out, but no luck with those either as yet
jndiprops.setProperty("java.naming.factory.initial","org.apache.naming.java.javaURLContextFactory");
jndiprops.setProperty("java.naming.provider.url","localhost:52464");
jndiprops.setProperty("java.naming.factory.url.pkgs","org.apache.catalina.util.naming");
jndiprops.setProperty("java.naming.factory.state","com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
jndiprops.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
jndiprops.setProperty("org.omg.CORBA.ORBInitialPort", "52466");

where my webservice wsdl is available on http://localhost:52464/Clickvision/UserService?wsdl

Note, I configured 52466 above since I have a line in my GF domain.xml under config for server-config which shows this port but I tried this and 3700 and neither work for me
<iiop-listener port="52466" id="orb-listener-1" address="0.0.0.0" lazy-init="true"></iiop-listener>