Skip to main content

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

No replies
lolveley
Offline
Joined: 2008-12-16

"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.

olivier