Skip to main content

(netbeans,mandriva) error while launching JEE client : javax.naming.AlreadyBoundExcception

10 replies [Last post]
lolveley
Offline
Joined: 2008-12-16
Points: 0

"UID=olivier_DBA;PWD=***;Server=DB_numberOne_srv;DBN=DB_numberOne_db;DBF=/home/olivier/Documents/SQLAnywhere_files/DB_numberOne.db"

java -Dorg.omg.CORBA.ORBInitialHost=localhost\ -Dorg.omg.CORBA.ORBInitialPort=3700\ -classpath /home/olivier/applications/glassfish-3.1/glassfish/lib/appserv-rt.jar:/home/olivier/applications/glassfish-3.1/glassfish/lib/javaee.jar\ -jar /home/olivier/NetBeansProjects/YAPS3_and_another_one/dist/YAPS3_and_another_one.jar

Hello, I created projects from the book of A.Goncalves about javaee5.
j'ai un projet EJB (contient des EJBs, des classes JPA), un projet EAR (Enterprise application, je précise que j'utilise netbeans) qui possède une référence à l'EJB (en fait je ne sais pas si ce projet EAR est nécessaire), un projet class library qui contient les interfaces remote des EJBs (il y en a 3).
I have an EJB project (which contains some EJB, and some JPA classes), an EAR project(for Enterprise Application Project, in netbeans) which contains a reference to the EJB(in fact I do not know if the EAR project is necessary), and a class library project which contains the remote interfaces of the EJBs (there are 3 EJB classes).
a client (see after)have a reference to the class library (for the remote interfaces).

The whole projects must be a sell site(excuse my poor english), a commercial site which sell pets.There are two clients :
- a local client which is the web client, for the CLIENTS
- a swing client, which access to the remote interfaces, for the EMPLOYEES of the shop

I focus on the swing client, which use the InitialContext constructor.

the server is glassfish 3.1, and when I launch my client from netbeans all is good (I mean the JNDI call wich a lookup runs fine) but when I launch the client from the command line I have this error :

<br />
access_to_yaps.ServiceLocatorException: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial<br />
erreur :java.lang.NullPointerException<br />
access_to_yaps.ServiceLocatorException: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial<br />
Exception in thread "main" java.lang.NullPointerException<br />
    at access_to_yaps.CustomerDelegate.findCustomers(CustomerDelegate.java:51)<br />
    at yaps3_and_another_one.YAPS3_and_another_one.main(YAPS3_and_another_one.java:43)<br />
[olivier@localhost dist]$ java -jar "/home/olivier/NetBeansProjects/YAPS3_and_another_one/dist/YAPS3_and_another_one.jar"<br />
Début ...<br />
access_to_yaps.ServiceLocatorException: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial<br />
erreur :java.lang.NullPointerException<br />
access_to_yaps.ServiceLocatorException: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial<br />
Exception in thread "main" java.lang.NullPointerException<br />
    at access_to_yaps.CustomerDelegate.findCustomers(CustomerDelegate.java:51)<br />
    at yaps3_and_another_one.YAPS3_and_another_one.main(YAPS3_and_another_one.java:43)<br />

here is the callers code:

<br />
private ServiceLocator() throws ServiceLocatorException {</p>
<p>                try {<br />
                        Properties props = new Properties();<br />
                        props.load(new FileInputStream("jndi.properties"));</p>
<p>                        initialContext = new InitialContext(props);<br />
                        cache = new HashMap<String, Object>();</p>
<p>                } catch (Exception e) {</p>
<p>                        throw new ServiceLocatorException(e.toString());</p>
<p>                }</p>
<p>        }</p>
<p>        public Object getRemoteInterface(String jndiName)<br />
                throws ServiceLocatorException {</p>
<p>                Object remoteInterface = cache.get(jndiName);</p>
<p>                if (remoteInterface == null) {</p>
<p>                        try {</p>
<p>                                remoteInterface = initialContext.lookup(jndiName);<br />
                                cache.put(jndiName, remoteInterface);</p>
<p>                        } catch (Exception e) {</p>
<p>                                throw new ServiceLocatorException(e.toString());<br />
                        }</p>
<p>                }</p>
<p>                return remoteInterface;</p>
<p>        }<br />
}<br />

The JNDI file is here : http://www.developpez.net/forums/d446460/java/serveurs-conteneurs-java-e...,

here is the glassfish's log:

<br />
[#|2011-04-21T00:00:17.794+0200|SEVERE|glassfish3.1|javax.enterprise.system.tools.deployment.org.glassfish.deployment.common|_ThreadID=55;_ThreadName=Thread-1;|Exception while invoking class org.glassfish.ejb.startup.EjbDeployer load method<br />
java.lang.RuntimeException: EJB Container initialization error<br />
    at org.glassfish.ejb.startup.EjbApplication.loadContainers(EjbApplication.java:246)<br />
    at org.glassfish.ejb.startup.EjbDeployer.load(EjbDeployer.java:290)<br />
    at org.glassfish.ejb.startup.EjbDeployer.load(EjbDeployer.java:101)<br />
    at org.glassfish.internal.data.ModuleInfo.load(ModuleInfo.java:186)<br />
    at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:249)<br />
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:460)<br />
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)<br />
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:370)<br />
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)<br />
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)<br />
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1067)<br />
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)<br />
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1247)<br />
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)<br />
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:465)<br />
    at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:222)<br />
    at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)<br />
    at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)<br />
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:234)<br />
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)<br />
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)<br />
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)<br />
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)<br />
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)<br />
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)<br />
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)<br />
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)<br />
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)<br />
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)<br />
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)<br />
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)<br />
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)<br />
    at java.lang.Thread.run(Thread.java:662)<br />
Caused by: java.lang.RuntimeException: Error while binding JNDI name ejbs.CustomerRemote__3_x_Internal_RemoteBusinessHome__ for EJB : CustomerBean<br />
    at com.sun.ejb.containers.BaseContainer.initializeHome(BaseContainer.java:1550)<br />
    at com.sun.ejb.containers.StatelessSessionContainer.initializeHome(StatelessSessionContainer.java:202)<br />
    at com.sun.ejb.containers.ContainerFactoryImpl.createContainer(ContainerFactoryImpl.java:167)<br />
    at org.glassfish.ejb.startup.EjbApplication.loadContainers(EjbApplication.java:234)<br />
    ... 32 more<br />
Caused by: javax.naming.NameAlreadyBoundException [Root exception is org.omg.CosNaming.NamingContextPackage.AlreadyBound: IDL:omg.org/CosNaming/NamingContext/AlreadyBound:1.0]<br />
    at com.sun.jndi.cosnaming.ExceptionMapper.mapException(ExceptionMapper.java:75)<br />
    at com.sun.jndi.cosnaming.CNCtx.callBindOrRebind(CNCtx.java:595)<br />
    at com.sun.jndi.cosnaming.CNCtx.bind(CNCtx.java:620)<br />
    at com.sun.jndi.cosnaming.CNCtx.bind(CNCtx.java:658)<br />
    at javax.naming.InitialContext.bind(InitialContext.java:400)<br />
    at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.publishCosNamingObject(GlassfishNamingManagerImpl.java:226)<br />
    at com.sun.ejb.containers.BaseContainer$JndiInfo.publish(BaseContainer.java:5606)<br />
    at com.sun.ejb.containers.BaseContainer.initializeHome(BaseContainer.java:1535)<br />
    ... 35 more<br />
Caused by: org.omg.CosNaming.NamingContextPackage.AlreadyBound: IDL:omg.org/CosNaming/NamingContext/AlreadyBound:1.0<br />
    at org.omg.CosNaming.NamingContextPackage.AlreadyBoundHelper.read(AlreadyBoundHelper.java:60)<br />
    at org.omg.CosNaming._NamingContextStub.bind(_NamingContextStub.java:67)<br />
    at com.sun.jndi.cosnaming.CNCtx.callBindOrRebind(CNCtx.java:584)<br />
    ... 41 more<br />
|#]</p>
<p>[#|2011-04-21T00:00:17.798+0200|SEVERE|glassfish3.1|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=55;_ThreadName=Thread-1;|Exception while loading the app|#]</p>
<p>[#|2011-04-21T00:00:17.802+0200|INFO|glassfish3.1|org.eclipse.persistence.session.file:/home/olivier/NetBeansProjects/YAPS3_EAR/dist/gfdeploy/YAPS3_EAR/YAPS3_EJB_jar/_YAPS3_pu|_ThreadID=26;_ThreadName=Thread-1;|file:/home/olivier/NetBeansProjects/YAPS3_EAR/dist/gfdeploy/YAPS3_EAR/YAPS3_EJB_jar/_YAPS3_pu logout successful|#]</p>
<p>[#|2011-04-21T00:00:17.805+0200|SEVERE|glassfish3.1|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=55;_ThreadName=Thread-1;|Exception while loading the app : EJB Container initialization error<br />
java.lang.RuntimeException: Error while binding JNDI name ejbs.CustomerRemote__3_x_Internal_RemoteBusinessHome__ for EJB : CustomerBean<br />
    at com.sun.ejb.containers.BaseContainer.initializeHome(BaseContainer.java:1550)<br />
    at com.sun.ejb.containers.StatelessSessionContainer.initializeHome(StatelessSessionContainer.java:202)<br />
    at com.sun.ejb.containers.ContainerFactoryImpl.createContainer(ContainerFactoryImpl.java:167)<br />
    at org.glassfish.ejb.startup.EjbApplication.loadContainers(EjbApplication.java:234)<br />
    at org.glassfish.ejb.startup.EjbDeployer.load(EjbDeployer.java:290)<br />
    at org.glassfish.ejb.startup.EjbDeployer.load(EjbDeployer.java:101)<br />
    at org.glassfish.internal.data.ModuleInfo.load(ModuleInfo.java:186)<br />
    at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:249)<br />
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:460)<br />
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)<br />
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:370)<br />
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)<br />
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)<br />
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1067)<br />
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)<br />
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1247)<br />
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)<br />
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:465)<br />
    at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:222)<br />
    at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)<br />
    at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)<br />
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:234)<br />
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)<br />
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)<br />
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)<br />
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)<br />
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)<br />
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)<br />
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)<br />
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)<br />
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)<br />
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)<br />
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)<br />
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)<br />
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)<br />
    at java.lang.Thread.run(Thread.java:662)<br />
Caused by: javax.naming.NameAlreadyBoundException [Root exception is org.omg.CosNaming.NamingContextPackage.AlreadyBound: IDL:omg.org/CosNaming/NamingContext/AlreadyBound:1.0]<br />
    at com.sun.jndi.cosnaming.ExceptionMapper.mapException(ExceptionMapper.java:75)<br />
    at com.sun.jndi.cosnaming.CNCtx.callBindOrRebind(CNCtx.java:595)<br />
    at com.sun.jndi.cosnaming.CNCtx.bind(CNCtx.java:620)<br />
    at com.sun.jndi.cosnaming.CNCtx.bind(CNCtx.java:658)<br />
    at javax.naming.InitialContext.bind(InitialContext.java:400)<br />
    at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.publishCosNamingObject(GlassfishNamingManagerImpl.java:226)<br />
    at com.sun.ejb.containers.BaseContainer$JndiInfo.publish(BaseContainer.java:5606)<br />
    at com.sun.ejb.containers.BaseContainer.initializeHome(BaseContainer.java:1535)<br />
    ... 35 more<br />
Caused by: org.omg.CosNaming.NamingContextPackage.AlreadyBound: IDL:omg.org/CosNaming/NamingContext/AlreadyBound:1.0<br />
    at org.omg.CosNaming.NamingContextPackage.AlreadyBoundHelper.read(AlreadyBoundHelper.java:60)<br />
    at org.omg.CosNaming._NamingContextStub.bind(_NamingContextStub.java:67)<br />
    at com.sun.jndi.cosnaming.CNCtx.callBindOrRebind(CNCtx.java:584)<br />
    ... 41 more<br />
|#]<br />

What I understood is that there is something present in the server and due to this there is a conflict.
I saw the EJB 's name in the management page of glassfish, all seems to be fine.

can you help me ?

maybe this could help : http://www.webspheretools.com/sites/webspheretools.nsf/docs/org%20omg%20..., but I don't understand very well this.
I must verify some "resources" but which ones?

also I searched if there not was a classpath's problem, so I tested this :

<br />
java -Dorg.omg.CORBA.ORBInitialHost=localhost\ -Dorg.omg.CORBA.ORBInitialPort=3700\ -classpath /home/olivier/applications/glassfish-3.1/glassfish/lib/appserv-rt.jar:/home/olivier/applications/glassfish-3.1/glassfish/lib/javaee.jar\ -jar /home/olivier/NetBeansProjects/YAPS3_and_another_one/dist/YAPS3_and_another_one.jar<br />

but without success
(look at this help : http://old.nabble.com/Remote-standalone-EJB-client-td20225310.html, here :

olivier

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
fleroy41
Offline
Joined: 2011-04-01
Points: 0

Hi,

first of all I think you cannot use the "-classpath" option while launching a jar. You have to do it in the manifest file. Also I think you are not including the good jar library in your classpath. Your manifest.mf should have a line like :
Class-Path: /path/to/RemoteInterface1 /path/to/RemoteInterface2 /home/olivier/applications/glassfish3.1/glassfish/lib/gf-client.jar
I think including gf-client.jar is enough since this library includes the other ones.
NB : in your IDE if you add a dependancy to gf-client.jar, it will copy this file in a local "lib" folder and try to use this one (check the manifest.mf produced by netbeans). But this will not work since gf-client.jar will fail to include the other jars (because they have not been copied into the local lib folder).

Regards,
Fabien Leroy.

lolveley
Offline
Joined: 2008-12-16
Points: 0

hello,
thanks for your answer.

I wonder why netbeans doesn't add the gf-client.jar in the project's jar...
Here is my modified MANIFEST.MF :
Am I right?
Even if so, tell it to me!
olivier

fleroy41
Offline
Joined: 2011-04-01
Points: 0

Hi olivier,

your manifest is almost good, but I think you can remove 3 dependancies from your classpath :
- /home/..../glassfish/lib/appserv-rt.jar
- /lib/appserv-rt.jar
- /lib/gf-client.jar

This should work if you start your client with :
- java -Dcom.sun.appserv.iiop.endpoints="127.0.0.1:3700" -jar /yourproject/dist/toto.jar

My problem now is I have no clue how I could run it on a different machine. I tried copying the whole "/.../glassfish/lib" folder (containing gf-client.jar) in my project lib folder (with the Class-Path pointing to "/myproject/dist/lib/gf-client.jar") but it does not work, so no way to distribute the jar file even by attaching the whole lib folder. If you manage to do it I am interested :) .

For your question about NetBeans and jar library look at this post : http://www.java-forums.org/netbeans/12582-netbeans-creating-jar-includin... . I did not try but the solution proposed by avh4 should work.

Fabien.

lolveley
Offline
Joined: 2008-12-16
Points: 0

hello,

What a disappointing thing!
no way to make it works!
Indeed:
-I tried to modify the classpath of the manifest file, like this:

Manifest-Version: 1.0

Ant-Version: Apache Ant 1.8.2

Created-By: 1.6.0_24-b07 (Sun Microsystems Inc.)

Class-Path: /home/olivier/NetBeansProjects/YAPS3_container_interfaces/

dist/YAPS3_container_interfaces.jar /home/olivier/applications/glassf

ish3.1/glassfish/lib/gf-client.jar  lib/YAPS3_container_interfaces.ja

r lib/asm-all-2.2.2.jar lib/forms-1.2.0.jar lib/laf-plugin.jar lib/la

f-widget.jar lib/substance-swingx.jar lib/swingx.jar lib/Theme.jar li

b/trident.jar lib/javax.security.auth.message.jar lib/javax.ejb.jar l

ib/javax.transaction.jar lib/javax.servlet.jsp.jar lib/javax.resource

.jar lib/jstl-impl.jar lib/javax.servlet.jar lib/jaxb-api-osgi.jar li

b/javax.jms.jar lib/webservices-api-osgi.jar lib/javax.servlet.jsp.js

tl.jar lib/jaxrpc-api-osgi.jar lib/javax.enterprise.deploy.jar lib/js

f-impl.jar lib/javax.mail.jar lib/jsf-api.jar lib/javax.persistence.j

ar lib/weld-osgi-bundle.jar lib/javax.annotation.jar lib/jersey-core.

jar lib/bean-validator.jar lib/javax.security.jacc.jar lib/    javax.management.j2ee.jar lib/web-core.jar lib/jackson-core-asl.jar li

b/jackson-jaxrs.jar lib/jackson-mapper-asl.jar lib/jersey-client.jar

lib/jersey-gf-server.jar lib/jersey-json.jar lib/jersey-multipart.jar

lib/jettison.jar lib/mimepull.jar

X-COMMENT: Main-Class will be added automatically by build

Main-Class: yaps3_and_another_one.YAPS3_and_another_one

but the result is the same, even with the "java -Dcom.sun ..."command you gave to me
Then, I tried to modify the build.xml file, like this :
&lt;target name=&quot;-post-jar&quot;&gt;
        &lt;jar jarfile=&quot;dist/Combined-dist.jar&quot;&gt;
            &lt;zipfileset src=&quot;${dist.jar}&quot; excludes=&quot;META-INF/*&quot; /&gt;
            &lt;zipfileset src=&quot;lib/gf-client.jar&quot; excludes=&quot;META-INF/*&quot; /&gt;
            &lt;manifest&gt;
                &lt;attribute name=&quot;Main-Class&quot; value=&quot;com.example.mypackage.Main&quot;/&gt;
            &lt;/manifest&gt;
        &lt;/jar&gt;
    &lt;/target&gt;

but netbeans says to me :
The archive gf-client.jar doesn't exist

yet this archive IS in the dist/lib folder...

do you understand something?
olivier

fleroy41
Offline
Joined: 2011-04-01
Points: 0

That is strange.

In netbeans : right-click on project -> properties -> libraries . You should have a dependancy to "/home/olivier/applications/glassfish3.1/glassfish/lib/gf-client.jar" . If you have it then try deleting this dependancy and add it again, if you don't then just add it. Be sure you have no dependancy to "/dist/lib/gf-client.jar"

Maybe it is a fail from netbeans, try deleting your dist folder and restart netbeans.

I guess the manifest file you show is the one from the produced jar file (/dist/toto.jar) ? You can edit the "myproject/manifest.mf" file so that you don't have to edit the jar after every build, I mean if you see something like "/lib/gf-client.jar" replace it by "/home/olivier/applications/glassfish3.1/glassfish/lib/gf-client.jar". (Don't forget to make a copy of the original manifest.mf)

For the moment don't edit the build.xml file since the original one works for me.

Fabien.

lolveley
Offline
Joined: 2008-12-16
Points: 0

It works a bit!
I mean after I changed the classpath in the manifest.mf file of the project in netbeans (by adding : "Class-Path <files .jar to add>") the initialization works and the program is launched (I know this because its first line is "System.out.println("début ...");" and it is displayed in the console.
great success!
but I have this error after :

[olivier@localhost ~]$ java -jar &quot;/home/olivier/NetBeansProjects/YAPS3_and_another_one/dist/YAPS3_and_another_one.jar&quot;
D&eacute;but ...
29 avr. 2011 14:31:33 com.sun.enterprise.v3.server.CommonClassLoaderServiceImpl findDerbyClient
INFO: Cannot find javadb client jar file, derby jdbc driver will not be available by default.
access_to_yaps.ServiceLocatorException: javax.naming.NamingException: Lookup failed for 'ejb/stateless/customer#ejbs.CustomerRemote' in SerialContext[myEnv={org.omg.CORBA.ORBInitialPort=3700, java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory, org.omg.CORBA.ORBInitialHost=localhost, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is javax.naming.NamingException: ejb ref resolution error for remote business interfaceejbs.CustomerRemote [Root exception is java.lang.ClassNotFoundException: ejbs.CustomerRemote]]
Exception in thread &quot;main&quot; java.lang.NoClassDefFoundError: ejbs/CustomerRemote
at access_to_yaps.CustomerDelegate.createCustomer(CustomerDelegate.java:22)
at yaps3_and_another_one.YAPS3_and_another_one.main(YAPS3_and_another_one.java:43)
Caused by: java.lang.ClassNotFoundException: ejbs.CustomerRemote
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:334)
... 2 more

obviously the derby files are in the project and even I have this manifest.mf :
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
Class-Path:  /home/olivier/applications/glassfish-3.1/glassfish/lib/gf-client.jar
/home/olivier/applications/glassfish-3.1/javadb/lib/derby.jar
/home/olivier/applications/glassfish-3.1/javadb/lib/derbyclient.jar

there are two issues :
- 1st : is there an access to the database?
-2nd : the lookup failed.
but here is the bottom lines in netbeans after the start of glassfish:
INFO: Portable JNDI names for EJB CustomerBean : [java:global/YAPS3_EJB/CustomerBean!ejbs.CustomerRemote, java:global/YAPS3_EJB/CustomerBean!ejbs.CustomerLocal]
INFO: Glassfish-specific (Non-portable) JNDI names for EJB CustomerBean : [ejb/stateless/customer, ejb/stateless/customer#ejbs.CustomerRemote]

so I would say the EJBs are fine deployed in glassfish but it is from the client the problem is.
I seem to have problems with the administration of glassfish (I can't load the page http://localhost:4848), I 'm working on it by now.
thank you!
olivier

fleroy41
Offline
Joined: 2011-04-01
Points: 0

I don't know why but I also have this "cannot find javadb .. " message. Anyway don't focus on it since it is not responsible for your JNDI lookup fail.

I also had a lot of trouble to have this jndi lookup succeed, if it can help you this works fine for me :
System.setProperty("com.sun.appserv.iiop.endpoints", "127.0.0.1:3700"); //check your iiop port, default should be 3700
InitialContext ctx = new InitialContext(); //no need to use Properties parameter
MyBeanRemote myBean = (MyBeanRemote) ctx.lookup("jndi portable name here"); //JNDI name found in server.log

Alternatively to the line "System.setProperty(...);" you can specify this parameter while starting your jar :
java -Dcom.sun.appserv.iiop.endpoints="...." - jar yourapp.jar

Fabien.

lolveley
Offline
Joined: 2008-12-16
Points: 0

well, I don(t know why but I can't access to the administration page of glassfish.
yet the client works from netbeans (it puts an entity in the database and retrieves all the records from the database).
it don't works from the command line.
even with your suggestion (System.setProperty...).
here is the error message :

[olivier@localhost ~]$ java -jar &quot;/home/olivier/NetBeansProjects/YAPS3_and_another_one/dist/YAPS3_and_another_one.jar&quot;<br />D&eacute;but ...<br />29 avr. 2011 17:46:36 com.sun.enterprise.v3.server.CommonClassLoaderServiceImpl findDerbyClient<br />INFO: Cannot find javadb client jar file, derby jdbc driver will not be available by default.<br />29 avr. 2011 17:46:36 org.glassfish.enterprise.iiop.impl.GlassFishORBManager getCorbalocURL<br />INFO: list[i] ==&gt; 127.0.0.1:3700<br />29 avr. 2011 17:46:36 org.glassfish.enterprise.iiop.impl.GlassFishORBManager getCorbalocURL<br />INFO: corbaloc url ==&gt; iiop:1.2@127.0.0.1:3700<br />access_to_yaps.ServiceLocatorException: javax.naming.NamingException: Lookup failed for 'java:global/YAPS3_EJB/CustomerBean!ejbs.CustomerRemote' in SerialContext[myEnv={org.omg.CORBA.ORBInitialPort=3700, java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory, java.naming.corba.orb=com.sun.corba.ee.impl.orb.ORBImpl@1c6745b9, org.omg.CORBA.ORBInitialHost=localhost, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, com.sun.appserv.ee.iiop.endpointslist=corbaloc:iiop:1.2@127.0.0.1:3700} [Root exception is javax.naming.NamingException: ejb ref resolution error for remote business interfaceejbs.CustomerRemote [Root exception is java.lang.ClassNotFoundException: ejbs.CustomerRemote]]<br />Exception in thread &quot;main&quot; java.lang.NoClassDefFoundError: ejbs/CustomerRemote<br />at access_to_yaps.CustomerDelegate.createCustomer(CustomerDelegate.java:22)<br />at yaps3_and_another_one.YAPS3_and_another_one.main(YAPS3_and_another_one.java:43)<br />Caused by: java.lang.ClassNotFoundException: ejbs.CustomerRemote<br />at java.net.URLClassLoader$1.run(URLClassLoader.java:217)<br />at java.security.AccessController.doPrivileged(Native Method)<br />at java.net.URLClassLoader.findClass(URLClassLoader.java:205)<br />at java.lang.ClassLoader.loadClass(ClassLoader.java:321)<br />at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)<br />at java.lang.ClassLoader.loadClass(ClassLoader.java:266)<br />at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:334)<br />... 2 more

any idea?

lolveley
Offline
Joined: 2008-12-16
Points: 0

hi fabien,
A long time has elapsed without news!
I succeeded in launching my program!
In a latter message, I told you I was'nt able to launch the adminisztration page of glassfish, in port 4848.
so, I decided to use huge attack : I changed of OS, from mandriva to opensuse, because I thought the system was surely badly "ill" to have glassfish launched (because the program created in netbeans used to work when launched from netbeans) and not to be able to launch the administration page.

so I created backups of my netbeans projects and migrated.
and finally it worked, with even a LAF manager (tinyLAF), but with its jar put in the manifest.mf yet, like you said to me.
it works, launched from the command line.

thanks again!

lolveley
Offline
Joined: 2008-12-16
Points: 0

well, it was nearly the thing I said : the path to the gf-client.jar is dist/lib.

but the results are the same.