JNDI Lookup in JSP fails for EJB 3.0
I am new to Java technology. I read the EJB FAQ, NetBeans docs and may forum discussions and I am still confused with the error I am having.
Background:
I have developed a persistance bean and related sessions beans (similar to the customer-cmp-ear application in the Java App Server samples). Now I am trying to access this bean using a JSP. After deploying the war file in the App Server and try to access the page, I get the following error.
javax.naming.NameNotFoundException: No object bound to name java:comp/env/ConsumerSessionLocal
After reading many articles, I understood that I dont have to prepare any descriptors, or JAR files for EJB 3.0.
Environment Details:
Java App Server Ver 9.0
NetBeans 5.5
I normally build the war files using NetBeans.
I use App Server Admin console to deploy the web applications using the above war file.
EJB details:
Persistance EJB : person.java
Session Objects
Consumer.java (this implements ConsumerSessionLocal, ConsumerSessionRemote). This Stateless bean accesses the methods in person.java.
ConsumerSessionLocal.java - local interface
ConsumerSessionRemote.java - remote interface
SearchConsumer.jsp
This JSP page is calling the ConsumerSessionLocal using the JNDI lookup through InitialContext.
Here is the Code snippet:
try {
InitialContext ic = new InitialContext();
Object o = ic.lookup("java:comp/env/ConsumerSessionLocal");
ConsumerSessionLocal consSession = (ConsumerSessionLocal) o;
I am able to see the jsp page in the browser, however, after a submit action, I get the Java Naming Exception error.
javax.naming.NameNotFoundException: No object bound for java:comp/env/ConsumerSessionLocal
I would appreciate your help/any of your thoughts.
Thanks in advance.
-Ram
I did not really solve it. Instead I used some of the tutorials that used JNDI lookup and modified those as my way forward. I did not really find out exactly what I was doing wrong.
/Anders
Similar Messages
-
Hi all,
When i try to run more than one servelt of the Quick Start samples that using Livecycle Java APIs and i get an error of "Remote EJBObject lookup failed for ejb/Invocation provider" from any servelt i run.
I try some Quick samples which is not servelts (java class) and it works fine, which makes me sure that my connection properties is true.
Environment:
The LiveCycle is based on "Websphere v6.1", and i use "Eclipse Platform
Version: 3.4.1".
i install "tomcat 5.5.17" to test the servelts in developing time through Eclipse.(only for test in developing time not for deploy on )
The Jars i added in the classpath:
adobe-forms-client.jar
adobe-livecycle-client.jar
adobe-usermanager-client.jar
adobe-utilities.jar
ejb.jar
j2ee.jar
ecutlis.jar
com.ibm.ws.admin.client_6.1.0.jar
com.ibm.ws.webservices.thinclient_6.1.0.jar
server.jar
utlis.jar
wsexception.jar
My code is :
Properties ConnectionProps = new Properties();
ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_EJB_ENDPOINT, "iiop://localhost:2809");
ConnectionProps.setProperty ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_ EJB_PROTOCOL);
ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE,ServiceClientFa ctoryProperties.DSC_WEBSPHERE_SERVER_TYPE);
ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "Administrator");
ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");
ConnectionProps.setProperty("java.naming.factory.initial", "com.ibm.ws.naming.util.WsnInitCtxFactory");
//Create a ServiceClientFactory object
ServiceClientFactory myFactory = ServiceClientFactory.createInstance(ConnectionProps);
//Create a FormsServiceClient object
FormsServiceClient formsClient = new FormsServiceClient(myFactory);
//Get Form data to pass to the processFormSubmission method
Document formData = new Document(req.getInputStream());
//Set run-time options
RenderOptionsSpec processSpec = new RenderOptionsSpec();
processSpec.setLocale("en_US");
//Invoke the processFormSubmission method
FormsResult formOut = formsClient.processFormSubmission(formData,"CONTENT_TYPE=application/pdf&CONTENT_TYPE=app lication/vnd.adobe.xdp+xml&CONTENT_TYPE=text/xml", "",processSpec);
List fileAttachments = formOut.getAttachments();
Iterator iter = fileAttachments.iterator();
int i = 0 ;
while (iter.hasNext()) {
Document file = (Document)iter.next();
file.copyToFile(new File("C:\\Adobe\\tempFile"+i+".jp i++;
short processState = formOut.getAction();
...... (To the end of the sample)
My Error was:
com.adobe.livecycle.formsservice.exception.ProcessFormSubmissionException: ALC-DSC-031-000: com.adobe.idp.dsc.net.DSCNamingException: Remote EJBObject lookup failed for ejb/Invocation provider
at com.adobe.livecycle.formsservice.client.FormsServiceClient.processFormSubmission(FormsSer viceClient.java:416)
at HandleData.doPost(HandleData.java:62)
at HandleData.doGet(HandleData.java:31)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j ava:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
aI assume here that your application is deployed on a different physical machine of where LCES is deployed and running.
Do the following test:
- Say that LCES is deployed on machine1 and your application is deployed on machine2. Ping machine1 from machine2 and note the ip address.
- Ping machine1 from machine1 and note the ip address.
The two pings should match.
- Ping machine2 from machine1 and note the ip address.
- Ping machine2 from machine2 and note the ip address.
The two pings should match.
Usually this kind of error would happen if your servers have internal and external ip addresses. -
Distributed Queue/JMX - JNDI lookup on startup fails
Hi,
I have a problem starting up Camel routes on a cluster via JMX. Although I have a NotificationListener registered that tries to startup the routes when the server sends a STATE=RUNNING lifecycle event, I cannot start the all Camel routes due to a "JMSException, Destination not found".
But, when I remote debug the application and put a breakpoint in, wait let's say 5 secs, then the JNDI lookup works and everything is fine.
I have unsuccessfully tried to play with the deployment order or my ear (by default the JMSServer is started with a priority of 1000), no luck. I have also put a poll method in, that waits until the JMSServer and the Destinations (=queues) are available, again no luck.
Anyone able to assist with that issue?
Best Regards,
SebastianI found the reason for the late binding. We are using "migratable target" in our cluster. When I remove the migratable target I have no issue whatsoever. Is there a way to either tweak the config or configure the Migratable targets in a way to by-pass this issue?
Regards,
Seb -
JNDI lookup of DataSource fails
I'm trying to create a DataSource as follows:
Connection connection = null;
String ACCOUNT_DATASOURCE = "weblogic.jdbc.AccountDB";
try {
Context ctx = new InitialContext(System.getProperties());
DataSource ds = (DataSource)ctx.lookup(ACCOUNT_DATASOURCE);
connection = ds.getConnection();
catch (Exception e) {
The client window reveals:
javax.ejb.CreateException: java.lang.NullPointerException
at weblogic.rmi.internal.BasicOutboundRequest.sendReceive(BasicOutboundR
equest.java:85)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteR
ef.java:274)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteR
ef.java:243)
at weblogic.rmi.internal.ProxyStub.invoke(ProxyStub.java:90)
at $Proxy1.create(Unknown Source)
at helloWorld.Client.main(Client.java:22)
Destroying account..
The server window reveals:
javax.naming.NameNotFoundException: Unable to resolve weblogic.jdbc.AccountDB.
R
esolved: 'weblogic.jdbc' Unresolved:'AccountDB' ; remaining name ''
<<no stack trace available>>
Via the console GUI I created a connection pool, which frequently disappears -
I do not understand at all why this pool seems so transient but it doesn't sound
good, and a data source, which does seem to persist, whose JNDI name corresponds
exactly to the name used for the lookup above. I've seen some usage of the form
java:comp/env/jdbc/... is this simply an arbitrary and therefore optional prefix,
or does it have some arcance meaning of which I am unaware?
Finally, the weblogic-ejb-jar.xml file defines the BMP entity bean and its associated
JNDI name for the database connection.
I've also created the cloudscape database via a .ddl file and copied it across
to the ~/wlserver6.1_beta/samples/eval/cloudscape/data directory (this might not
be the correct place)
Any ideas or suggestions most welcome - I've currently come to a grinding halt
with this.Did you make sure the DataSource (and the underlying connection pool were
actually "deployed" to a target server after you created them? That bit me
for a while...
If you open up the console and open up the "Servers" folder on the left and
right click on your server (myserver) and select "View JNDI Tree", do you
see your DataSource under the jdbc node?
greg
"David Franklin" <[email protected]> wrote in message
news:[email protected]...
>
I'm trying to create a DataSource as follows:
Connection connection = null;
String ACCOUNT_DATASOURCE = "weblogic.jdbc.AccountDB";
try {
Context ctx = new InitialContext(System.getProperties());
DataSource ds = (DataSource)ctx.lookup(ACCOUNT_DATASOURCE);
connection = ds.getConnection();
catch (Exception e) {
The client window reveals:
javax.ejb.CreateException: java.lang.NullPointerException
atweblogic.rmi.internal.BasicOutboundRequest.sendReceive(BasicOutboundR
equest.java:85)
atweblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteR
ef.java:274)
atweblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteR
ef.java:243)
at weblogic.rmi.internal.ProxyStub.invoke(ProxyStub.java:90)
at $Proxy1.create(Unknown Source)
at helloWorld.Client.main(Client.java:22)
Destroying account..
The server window reveals:
javax.naming.NameNotFoundException: Unable to resolveweblogic.jdbc.AccountDB.
R
esolved: 'weblogic.jdbc' Unresolved:'AccountDB' ; remaining name ''
<<no stack trace available>>
Via the console GUI I created a connection pool, which frequentlydisappears -
I do not understand at all why this pool seems so transient but it doesn'tsound
good, and a data source, which does seem to persist, whose JNDI namecorresponds
exactly to the name used for the lookup above. I've seen some usage ofthe form
java:comp/env/jdbc/... is this simply an arbitrary and therefore optionalprefix,
or does it have some arcance meaning of which I am unaware?
Finally, the weblogic-ejb-jar.xml file defines the BMP entity bean and itsassociated
JNDI name for the database connection.
I've also created the cloudscape database via a .ddl file and copied itacross
to the ~/wlserver6.1_beta/samples/eval/cloudscape/data directory (thismight not
be the correct place)
Any ideas or suggestions most welcome - I've currently come to a grindinghalt
with this. -
JNDI Lookup of ConnectionFactory fails from inside Glassfish application
This may very well end up being a glassfish specific question.
I've got a stand-alone WAR using JSF, where I have a backing bean use some helper objects that will send a JMS message. When this WAR is running from inside of Glassfish, it fails to do the lookup of the ConnectionFactory.
The application pulls the Queue JNDI and the Provider URL from a database, and uses a env Hashtable to do the JNDI InitialContext (which succeeds.) Using this Context, the ConnectionFactory lookup fails.
The remote server in this instance is WebLogic 9.2 (the JNDI is publically available with no user authentication, verified with a JMS developer tool we use internally.)
Here's the stacktrace...
2007-10-15 19:48:04,514 ERROR [net.acadiasoft.shared.jms.util.JMSSenderHelper:130] NamingException: messageFactory not found
javax.naming.NameNotFoundException: messageFactory not found
at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:216)
at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:188)
at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:74)
at com.sun.enterprise.naming.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:111)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:339)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at net.acadiasoft.shared.jms.util.JMSSenderHelper.getConnectionFactory(JMSSenderHelper.java:128)
at net.acadiasoft.shared.jms.util.JMSSenderHelper.init(JMSSenderHelper.java:58)
at net.acadiasoft.shared.jms.util.JMSSenderHelper.<init>(JMSSenderHelper.java:36)
at net.acadiasoft.web.shared.jms.util.AdminJmsHelper.<init>(AdminJmsHelper.java:19)
at net.acadiasoft.web.server.pages.SchedulerBackingBean.deleteJobs(SchedulerBackingBean.java:75)I've found the problem, and it's something I simply overlooked. I don't know why I didnt realize, but i was setting the java.naming.factory.initial env variable to what Glassfish uses, not WebLogic.
-
Does BEA provide an EJB specific JSP Tag library with WebLogic? I know of at least one other EJB Server that does.
What version is your tag library and what version is your deployment descriptor?
-
JNDI lookup fails for client applications
I am currently porting our j2ee application to weblogic 7.0. The application already
runs successfully on Orion and Jboss. I have got everything working now except
for our client applications, which all fail with a JNDI lookup error. The exception
is:
javax.naming.NameNotFoundException: Unable to resolve 'java:comp.env/ejb/QualiferInstance'
Resolved: '' Unresolved:'java:comp' ; remaining name 'java:comp.env
/ejb/QualifierInstance'
at weblogic.rmi.internal.BasicOutboundRequest.sendReceive(BasicOutbound
equest.java:109)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemote
ef.java:262)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemote
ef.java:229)
at weblogic.jndi.internal.ServerNamingNode_WLStub.lookup(Unknown Source
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:338)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:333)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at BatchIndexer.main(BatchIndexer.java:89)
I have looked up numerous postings on various mailing lists describing similar
problems, but none of them give an explanation which helps me.
I am convinced that I have the ejb deployment descriptors correct because all
our JSPs, servlets and session beans successfully lookup and use the EJBs.
I am also convinced that I have the correct code for the JNDI lookup in our client
applications, because they work perfectly well on Orion and Jboss and use syntax
which is described as correct in the jsee specification, i.e. "java:comp/env/..."
Here is the descriptor from weblogic-ejb-jar.xml for the EJB mentioned in the
example exception above:
<weblogic-enterprise-bean>
<ejb-name>QualifierInstance</ejb-name>
<jndi-name>comp/env/ejb/QualifierInstance</jndi-name>
</weblogic-enterprise-bean>
And here is the descriptor in the application-client.xml file:
<ejb-ref>
<ejb-ref-name>ejb/QualifierInstance</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type> <home>com.espritsoutron.xengine.ejb.metamodel.QualifierInstanceHome</home>
<remote>com.espritsoutron.xengine.ejb.metamodel.QualifierInstance</remote>
<ejb-link>QualifierInstance</ejb-link>
</ejb-ref>
And here is the code in the client application that attempts to perform the lookup:
qiHome = (QualifierInstanceHome)PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/QualifierInstance"),
QualifierInstanceHome.class);
The annoying thing is that I know I can make this work if I change the code to
omit the "java:" prefix, but I don't want to do this because then it would no
longer work on either Orion and Jboss.
P.S. I have also tried changing the jndi-name in the weblogic-ejb-jar descriptor
to "ejb/QualifierInstance" and just "QualifierInstance", but neither of these
make any difference. I even tried chaning it to "java:comp/env/ejb/QualifierInstance"
but that totally breaks the server.
Can anyone can please help with this?you can find the JNDI name in the JNDI tree from the admin console
right click on your server and choose "view jndi tree".
if you bind your ejb to ejb/QualifierInstance
you look it up with that exact same name ejb/QualifierInstance
Julian Fawcett wrote:
I am currently porting our j2ee application to weblogic 7.0. The application already
runs successfully on Orion and Jboss. I have got everything working now except
for our client applications, which all fail with a JNDI lookup error. The exception
is:
javax.naming.NameNotFoundException: Unable to resolve 'java:comp.env/ejb/QualiferInstance'
Resolved: '' Unresolved:'java:comp' ; remaining name 'java:comp.env
/ejb/QualifierInstance'
at weblogic.rmi.internal.BasicOutboundRequest.sendReceive(BasicOutbound
equest.java:109)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemote
ef.java:262)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemote
ef.java:229)
at weblogic.jndi.internal.ServerNamingNode_WLStub.lookup(Unknown Source
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:338)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:333)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at BatchIndexer.main(BatchIndexer.java:89)
I have looked up numerous postings on various mailing lists describing similar
problems, but none of them give an explanation which helps me.
I am convinced that I have the ejb deployment descriptors correct because all
our JSPs, servlets and session beans successfully lookup and use the EJBs.
I am also convinced that I have the correct code for the JNDI lookup in our client
applications, because they work perfectly well on Orion and Jboss and use syntax
which is described as correct in the jsee specification, i.e. "java:comp/env/..."
Here is the descriptor from weblogic-ejb-jar.xml for the EJB mentioned in the
example exception above:
<weblogic-enterprise-bean>
<ejb-name>QualifierInstance</ejb-name>
<jndi-name>comp/env/ejb/QualifierInstance</jndi-name>
</weblogic-enterprise-bean>
And here is the descriptor in the application-client.xml file:
<ejb-ref>
<ejb-ref-name>ejb/QualifierInstance</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type> <home>com.espritsoutron.xengine.ejb.metamodel.QualifierInstanceHome</home>
<remote>com.espritsoutron.xengine.ejb.metamodel.QualifierInstance</remote>
<ejb-link>QualifierInstance</ejb-link>
</ejb-ref>
And here is the code in the client application that attempts to perform the lookup:
qiHome = (QualifierInstanceHome)PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/QualifierInstance"),
QualifierInstanceHome.class);
The annoying thing is that I know I can make this work if I change the code to
omit the "java:" prefix, but I don't want to do this because then it would no
longer work on either Orion and Jboss.
P.S. I have also tried changing the jndi-name in the weblogic-ejb-jar descriptor
to "ejb/QualifierInstance" and just "QualifierInstance", but neither of these
make any difference. I even tried chaning it to "java:comp/env/ejb/QualifierInstance"
but that totally breaks the server.
Can anyone can please help with this? -
JAVA client JNDI lookup for EJB session in cluster in WLS 5.1
The documentation says :
to obtain a Context for JNDI lookup do the following :
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL, "t3://mycluster:7001");
try {
Context ctx = new InitialContext(ht);
// Do the client's work
catch (NamingException ne) {
// A failure occurred
finally {
try {ctx.close();}
catch (Exception e) {
// a failure occurred
where "mycluster" is the DNS name of my cluster. My DNS server (Windows 200
DNS server) use round robin
to call alernatively all the wls server node in "mycluster" and it's OK. The
two servers of my cluster
are called alternatively for my EJB session stateless.
Now I unplug one of the two nodes of my cluster and the remaining server is
called only 2 times
and not after.
Questions :
-is the load balancing between the nodes of mycluster only rely on DNS or
is there an internal
mecanism in EJB sub to try one server then an other ?
- do I need to obtain a new reference on JNDI Context for each call ?
Thank's a lot.
Farid Bellameche.
I too have the same problem. My scenario is :
I have the web tier architecture away from cluster. All ejbs are in cluster
running in two seperate machines. We have a factory class running in
webtier(we use servlet in this tier) which obtains home interface only once
and stores it for future reference. When ever we need the remoteobject stub,
we ask the factory class and which in turn uses the stored home interface to
get the same.
In the webtier, I list all the servers in the cluster as a part of url as
mentioned by you.
I started the web tier as well as Object tier cluster. I could see the
request coming in both the machines in the cluster for the ejb. But When I
bring one the server in the cluster,
1. Web tier throws an exception saying that it could not connect
to server using t3.
2. The other machine which is running the server, also says
'failed to create socket to : -32323234324 sever name
using protocol t3.
It looks like I am able to get load balance. But I am not able to get the
fail over to be working.
In the weblogic-ejb-jar.xml, I added the following.
<clustering-descriptor>
<home-is-clusterable>true</home-is-clusterable>
<home-load-algorithm>round-robin</home-load-algorithm>
</clustering-descriptor>
I compiled and added the .jar file. So the jar file now has replica aware
stubs.
Could any one of you help me for why the fail over is not working?
Suersh
"Giri Alwar" <[email protected]> wrote in message
news:[email protected]...
> Farid,
> (1) Yes, the stub has the logic to perform load-balancing and
fail-over.
> (2) In almost all cases, no. You can get the context once, store it
and
> use it thereafter. Please refer to
> http://www.weblogic.com/docs51/cluster/concepts.html#1025061 for more
info.
>
> A couple of notes on your situation. From what you are describing, your
> Windows DNS server is setup to serve only one IP from the cluster (using
> round-robin) as opposed to a list of all IP's in the cluster. Hence, the
> initial context you obtain is tied to a single server in the cluster (the
> one returned by the DNS). The weblogic implementation on the client side
has
> no idea of the existence of the other servers in the cluster. This is not
a
> cluster aware context. To obtain a cluster aware context, either list all
> the IP's in the URL like t3://server1,server2,server3:7001 or have
> "mycluster" return a list of all servers in the cluster.
>
> Giri
>
>
> "Farid Bellameche" <[email protected]> wrote in message
> news:[email protected]...
> > The documentation says :
> >
> > to obtain a Context for JNDI lookup do the following :
> > Hashtable ht = new Hashtable();
> > ht.put(Context.INITIAL_CONTEXT_FACTORY,
> > "weblogic.jndi.WLInitialContextFactory");
> > ht.put(Context.PROVIDER_URL, "t3://mycluster:7001");
> > try {
> > Context ctx = new InitialContext(ht);
> > // Do the client's work
> > }
> > catch (NamingException ne) {
> > // A failure occurred
> > }
> > finally {
> > try {ctx.close();}
> > catch (Exception e) {
> > // a failure occurred
> > }
> > }
> >
> > where "mycluster" is the DNS name of my cluster. My DNS server (Windows
> 200
> > DNS server) use round robin
> > to call alernatively all the wls server node in "mycluster" and it's OK.
> The
> > two servers of my cluster
> > are called alternatively for my EJB session stateless.
> > Now I unplug one of the two nodes of my cluster and the remaining server
> is
> > called only 2 times
> > and not after.
> >
> > Questions :
> > -is the load balancing between the nodes of mycluster only rely on DNS
> or
> > is there an internal
> > mecanism in EJB sub to try one server then an other ?
> >
> > - do I need to obtain a new reference on JNDI Context for each call ?
> >
> >
> > Thank's a lot.
> >
> > Farid Bellameche.
> >
> >
> >
> >
>
>
-
Problems with JNDI lookup for java:comp/env/ejb
Hi all,
I'm using OC4J 9.0.3 and I have problems when looking up for the local
EJB context.
I have a SLSB which refers to another SLSB via a JNDI mapping like
shown below. Both services are deployed within one EAR file.
(snippets of ejb-jar.xml and orion-ejb-jar.xml)
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>ServiceABean</ejb-name>
<home>com.coi.ServiceAHome</home>
<remote>com.coi.ServiceA</remote>
<ejb-class>com.coi.ServiceABean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<ejb-ref>
<ejb-ref-name>ejb/some/sub/packages/ServiceB</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>com.coi.ServiceBHome</home>
<remote>com.coi.ServiceB</remote>
</ejb-ref>
</session>
</enterprise-beans>
</ejb-jar>
<orion-ejb-jar>
<enterprise-beans>
<session-deployment location="global/some/sub/packages/ServiceA" name="ServiceABean">
<ejb-ref-mapping name="ejb/some/sub/packages/ServiceB" location="global/some/sub/packages/ServiceB" />
</session-deployment>
</enterprise-beans>
</orion-ejb-jar>
The ApplicationInitialContextFactory will be used (prepared by the container),
so the lookup for ServiceB within a method of ServiceA should work as follows:
public class ServiceABean implements SessionBean
public void someMethod()
InitialContext con = new InitialContext(); // will be of class ApplicationContext
Context localEjbContext = (Context)con.lookup( "java:comp/env/ejb" );
ServiceBHome serviceBHome = (ServiceBHome) PortableRemoteObject.narrow(
localEjbContext.lookup( "some/sub/packages/ServiceB" ),
ServiceBHome.class );
The problem is now, that the lookup for "java:comp/env/ejb" doesn't work
and throws a NameNotFoundException.
To figure out what's actually happening during lookup I debugged a little bit and
tried a few things:
1. A lookup for "java:comp" works fine. It returns an instance of class FlatMapContext
which consists of a hash map which itself contains an entry for "env".
2. So a lookup for "env" on that FlatMapContext also works and returns an instance of SubContext.
3. A lookup for "ejb" using this SubContext causes a NameNotFoundException
with message "java:comp/env/ejb not found".
4. A lookup like con.lookup( "java:comp/env" ) throws also a NameNotFoundException
with message "java:comp/env not found (not inside a J2EE module, for instance a Web-App,
EJB, or Application-Client)".
Does anyone know something about this?
Regards
--thomasHi Debu,
Great! 9.0.4 will be released in june/july this year, right? Sorry for my ironical reaction, but does that mean, that I don't have any chance to get my whole stuff running in 9.0.3? I cannot believe that. Isn't there a wordaround I could apply? A setting or whatever to substitute the daft FlatCtx by something else that is implemented according to the spec?
Regards
--thomas -
Doing a jndi lookup() for an EJB deployed on Glassfish v3
Hello.
I have deployed a Stateful Sesion EJB on a Glassfish v3 AppServer.
It is running under 'localhost' on my laptop pc.
I am also running a stand-alone java application on the same pc... it attempts to get a remote connection from the client-app to the Glassfish Server and then do a jndi lookup() to get a reference to my EJB.
here is the client source code:
public class LookupTest {
static Properties props = null;
public static void main(String[] args) {
try {
props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
props.put(Context.PROVIDER_URL, "iiop://localhost:3700");
Context ctx = new InitialContext(props);
System.out.println( "the context is: " + ctx);
System.out.println( "the environment contains: " + ctx.getEnvironment() );
System.out.println( " ");
// do a lookup.
Object elementObj = ctx.lookup("SerialContextProvider");
System.out.println(elementObj);
} catch (NamingException e) {
e.printStackTrace();
When I run this app, there are no Errors or Exceptions. It appears that the connection succeeds. But there are no EJB references in the context that is created. The only item that seems to be present in the context is an item named "SerialContextProvider", as noted in the return value from a list("") method invocation. Why can i not see the EJB within the context? Is my code wrong ??
Thanks,
Andy Jerpe
Edited by: user1169567 on Nov 28, 2010 12:12 PMOk, but the communication seems to be OK over the wire because if I use netstat -a I can see the ESTABLISHED connection with the server in the right RMI port.
TCP PORTAL35:1581 caapiranga:12405 ESTABLISHED
and then when I stop the instance in the OAS, the client shows an exception telling that the connection was lost.
An curious thing is that the ons.log doesn't log this connection ;/ -
How to write the jndi lookup for ejb using oc4j server in jdeveloper
Hi All,
i am new to the JDeveloper. i want to develop the session bean in JDeveloper using the OC4J server. how to write the jndi lookup in cllient. what are the xml files need to deploy the application. where can i mention the JNDI name in xml file. so please provide the information as soon as possible.
regards
ramThere is quite in-depth information in the Enterprise JavaBeans Developer's Guide.
Section 2 (Understanding EJB Application Development) explains the xml files needed and Section 29 (Accessing an EJB from a Client) explains how to do a JNDI lookup.
Hope this helps. -
EJB 3.0 and jndi lookup (simple question)
hi all,
i am newbie on Weblogic Application Server and i have some issues,
i have weblogic application server 10.0, also i have oracle timesten in-memory database, i have configured datasource and deploy my ejb 3.0 application, but i could not done jndi lookup?
here is my example:
1. one stateless session bean :
import javax.ejb.Remote;
@Remote
public interface InsertSubscriber {
public void insertSubscriber(SubscriberT subscriberT);
} 2. here is it's implementation :
@Remote(InsertSubscriber.class)
@Stateless
public class InsertSubscriberBean implements InsertSubscriber {
@PersistenceContext(unitName = "TimesTenDS")
private EntityManager oracleManager;
public void insertSubscriber(SubscriberT subscriber)
try {
System.out.println("started");
oracleManager.persist(subscriber);
System.out.println("end");
} catch (Exception e) {
e.printStackTrace();
}3 and my test client :
public class Client {
public static void main(String[] args) {
Context ctx = null;
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL, "t3://192.9.200.222:7001");
try {
ctx = new InitialContext(ht);
InsertSubscriber usagefasade = (InsertSubscriber) ctx
.lookup("ejb.InsertSubscriberBean");
} catch (NamingException e) {
e.printStackTrace();
} finally {
try {
ctx.close();
} catch (Exception e) {
e.printStackTrace();
}what i did incorrect ???
i got error like this : Name not fount exception
when i tried to view jndi tree on weblogic server application console i found this :
Binding Name:
TimestenExampleTimestenExample_jarInsertSubscriberBean_InsertSubscriber
Class:
test.InsertSubscriberBean_o7jk9u_InsertSubscriberImpl_1000_WLStub
Hash Code:
286
toString Results:
weblogic.rmi.internal.CollocatedRemoteRef - hostID: '2929168367193491522S::billing_domain:AdminServer', oid: '286', channel: 'null'what does it mean how i can done lookup to jndi ?
Regards,
Paata Lominadze,
Magticom LTD.
Georgia.Hi All,
I am using the weblogic cluster with session replication and EJB 2.0 with Local entity beans.
for fail-over session should be replicated to another server so we can achive the same session if 1st server fails.
Suppose i m using two managed server(server1,server2) in the cluster.I am storing the object of class ABC into session and object contains the instance of Local-EntityBean home but i put that as a transient.I have also override the readObject and write object method.
when write object is called on 1st server,readObject method should be called on second server so we will be sure that session is replicating properly.
pleaase find the code below : -
public IssuerPageBean() {
initEJB();
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
initEJB();
initializeCommonObject();
private void writeObject(java.io.ObjectOutputStream stream) throws IOException {
stream.defaultWriteObject();
private void initEJB() {
try {
ic = new InitialContext();
issuerHome = (LocalIssuerHome) ic.lookup("java:comp/env/Issuer");
} catch (NamingException e) {
e.printStackTrace();
in my case if i am calling the constructor IssuerPageBean(),it calls the initEJB() method and lookeup the entity local home properly but when readObject method is called on another server only initEJB() method is called directly and getting the exception below :
WARNING: Error during create -
javax.naming.NameNotFoundException: remaining name: env/ejb/Client
at weblogic.j2eeclient.SimpleContext.resolve(Ljavax/naming/Name;Z)Ljavax/naming/Context;(SimpleContext.java:35)
at weblogic.j2eeclient.SimpleContext.resolve(Ljavax/naming/Name;)Ljavax/naming/Context;(SimpleContext.java:39)
at weblogic.j2eeclient.SimpleContext.lookup(Ljavax/naming/Name;)Ljava/lang/Object;(SimpleContext.java:57)
at weblogic.j2eeclient.SimpleContext.lookup(Ljavax/naming/Name;)Ljava/lang/Object;(SimpleContext.java:57)
at weblogic.j2eeclient.SimpleContext.lookup(Ljava/lang/String;)Ljava/lang/Object;(SimpleContext.java:62)
at weblogic.jndi.factories.java.ReadOnlyContextWrapper.lookup(Ljava/lang/String;)Ljava/lang/Object;(ReadOnlyCont
extWrapper.java:45)
at weblogic.jndi.internal.AbstractURLContext.lookup(Ljava/lang/String;)Ljava/lang/Object;(AbstractURLContext.jav
a:130)
at javax.naming.InitialContext.lookup(Ljava/lang/String;)Ljava/lang/Object;(InitialContext.java:347)
at com.lb.equities.veda.tools.salesvault.jsp.ClientPageBean.initEJB()V(ClientPageBean.java:218)
at com.lb.equities.veda.tools.salesvault.jsp.ClientPageBean.readObject(Ljava/io/ObjectInputStream;)V(ClientPageB
ean.java:191)
at java.lang.LangAccessImpl.readObject(Ljava/lang/Class;Ljava/lang/Object;Ljava/io/ObjectInputStream;)V(Unknown
Source)
at java.io.ObjectStreamClass.invokeReadObject(Ljava/lang/Object;Ljava/io/ObjectInputStream;)V(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Ljava/lang/Object;Ljava/io/ObjectStreamClass;)V(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Z)Ljava/lang/Object;(Unknown Source)
at java.io.ObjectInputStream.readObject0(Z)Ljava/lang/Object;(Unknown Source)
at java.io.ObjectInputStream.readObject()Ljava/lang/Object;(Unknown Source)
at java.util.HashMap.readObject(Ljava/io/ObjectInputStream;)V(Unknown Source)
at java.lang.LangAccessImpl.readObject(Ljava/lang/Class;Ljava/lang/Object;Ljava/io/ObjectInputStream;)V(Unknown
Source)
at java.io.ObjectStreamClass.invokeReadObject(Ljava/lang/Object;Ljava/io/ObjectInputStream;)V(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Ljava/lang/Object;Ljava/io/ObjectStreamClass;)V(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Z)Ljava/lang/Object;(Unknown Source)
at java.io.ObjectInputStream.readObject0(Z)Ljava/lang/Object;(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Ljava/lang/Object;Ljava/io/ObjectStreamClass;)V(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Ljava/lang/Object;Ljava/io/ObjectStreamClass;)V(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Z)Ljava/lang/Object;(Unknown Source)
at java.io.ObjectInputStream.readObject0(Z)Ljava/lang/Object;(Unknown Source)
at java.io.ObjectInputStream.readObject()Ljava/lang/Object;(Unknown Source)
at weblogic.common.internal.ChunkedObjectInputStream.readObject()Ljava/lang/Object;(ChunkedObjectInputStream.jav
a:120)
at weblogic.rjvm.MsgAbbrevInputStream.readObject(Ljava/lang/Class;)Ljava/lang/Object;(MsgAbbrevInputStream.java:
121)
at weblogic.cluster.replication.ReplicationManager_WLSkel.invoke(ILweblogic/rmi/spi/InboundRequest;Lweblogic/rmi
/spi/OutboundResponse;Ljava/lang/Object;)Lweblogic/rmi/spi/OutboundResponse;(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(Lweblogic/rmi/extensions/server/RuntimeMethodDescriptor;Lweblogic
/rmi/spi/InboundRequest;Lweblogic/rmi/spi/OutboundResponse;)V(BasicServerRef.java:492)
Please help .
Thanks in Advance.
Edited by hforever at 03/04/2008 7:28 AM -
JNDI lookup fails - No such domain/application
Hi,
I tried to perform a JNDI lookup from a stand alone Java client towards Oracle 9iAS version 9.0.3 and failed with the following error:
javax.naming.NamingException: Lookup error: javax.naming.AuthenticationException: No such domain/application: mindejb; nested exception is:
javax.naming.AuthenticationException: No such domain/application: mindejb
java.lang.Object com.evermind.server.rmi.RMIContext.lookup(java.lang.String)
RMIContext.java:134
java.lang.Object javax.naming.InitialContext.lookup(java.lang.String)
InitialContext.java:345
void Samplecom.mind.ejb.stubs.AccountComplexStubClient.main(java.lang.String[])
AccountComplexStubClient.java:21
Below, are the JNDI settings I am using. The application by the name mindejb was deployed and is accessible using server side JSP or servlets. When I use a stand alone OC4J, the same settings (different port) work fine!
java.naming.factory.initial=com.evermind.server.rmi.RMIInitialContextFactory
java.naming.provider.url=ormi://localhost:3101/mindejb
java.naming.security.principal=admin
java.naming.security.credentials=admin
Thanks,
AviWhen you are running within an Oracle Application Server managed OC4J environment, then you should use the OPMN protocol loader we have that will insulate you from the specified ORMI port being used by OC4J.
The OPMN port is fixed so you can always rely on it, whereas the specific ORMI port used by an OC4J instance changes depending on the startup sequence, the number of procs configured, etc.
Here's a piece from the EJB documentation
http://download-west.oracle.com/docs/cd/B14099_19/web.1012/b15505/access.htm#i1019709
Location
All ports, including the RMI port, are dynamically set by OPMN when each OC4J instance starts. When you specify the following URL in the client JNDI properties, the client-side OC4J retrieves the dynamic ports for the instance, and chooses one from the list for communication.
java.naming.provider.url= opmn:ormi://<opmn_host>:<opmn_port>:<oc4j_instance>/<application-name>
The OPMN host name and port number is retrieved from the opmn.xml file. In most cases, OPMN is located on the same machine as the OC4J instance. However, you must specify the host name in case it is located on another machine. The OPMN port number is optional; if excluded, the default is port 6003. The OPMN port is specified in opmn.xml.
cheers
-steve- -
Hello everyone,
I developed a Web Service prototype accessing remote EJB using the EJB
control with special syntax in the jndi-name attribute: @jws:ejb
home-jndi-name="t3://10.10.245.70:7131/AccountDelegatorEJB"
Everything works fine, but I get an error when I restrict access to my web
service with a declarative security model by implementing steps provided in
help doc:
- Define the web resource you wish to protect
- Define which security role is required to access the web resource
- Define which users are granted the required security role
- Configure WebLogic Server security for my web service(Compatibility
Security/Users)
I launch the service by entering the address in a web browser. When prompted
to accept the digital certificate, click Yes, when prompted for network
authentication information, enter username and password, navigate to the
Test Form tab of Test View, invoke the method by clicking the button and I
get the following exception:
<error>
<faultcode>JWSError</faultcode>
<faultstring>Error during JNDI lookup from
jndi:t3://10.10.245.70:7131/AccountDelegatorEJB[Lookup failed for
name:t3://10.10.245.70:7131/AccountDelegatorEJB]</faultstring>
<detail>
<jwErrorDetail> weblogic.jws.control.ControlException: Error during JNDI
lookup from jndi:t3://10.10.245.70:7131/AccountDelegatorEJB[Lookup failed
for name:t3://10.10.245.70:7131/AccountDelegatorEJB] at
weblogic.knex.control.EJBControlImpl.acquireResources(EJBControlImpl.java:27
8) at
weblogic.knex.context.JwsInternalContext.acquireResources(JwsInternalContext
.java:220) at
weblogic.knex.control.ControlHandler.invoke(ControlHandler.java:260) at
ibas.AccountControl.getTransactionHistory(AccountControl.ctrl) at
ibas.GetSecure.retrieveVisaHistoryTxn(GetSecure.jws:64) </jwErrorDetail>
</detail>
</error>
I have a simple Hello method as well in my WebService (which is also
restricted) and it works fine, but remote EJB access doesn't. I tested my
prototype on Weblogic 7.2 and 8.1 platforms - same result.
Is that a bug or I am missing some additional configuration in order to get
that working. Has anyone seen similar behavior? Is there a known resolution?
Or a suggested way to work around the problem?
Thank you.
AndreAndre,
It would be best if this issue is handled as an Eval Support case. Please
BEA Customer Support at http://support.beasys.com along with the required
files, and request that an Eval support case be created for this issue.
Thanks
Raj Alagumalai
WebLogic Workshop Support
"Andre Shergin" <[email protected]> wrote in message
news:[email protected]...
Anurag,
I removed "t3", still get an error but a different one (Unable to create
InitialContext:null):
<error>
<faultcode>JWSError</faultcode>
<faultstring>Error during JNDI lookup from
jndi://secuser1:[email protected]:7131/AccountDelegatorEJB[Unable to
create InitialContext:null]</faultstring>
<detail>
<jwErrorDetail> weblogic.jws.control.ControlException: Error during JNDI
lookup from
jndi://secuser1:[email protected]:7131/AccountDelegatorEJB[Unable to
create InitialContext:null] at
weblogic.knex.control.EJBControlImpl.acquireResources(EJBControlImpl.java:27
8) at
weblogic.knex.context.JwsInternalContext.acquireResources(JwsInternalContext
.java:220) at
weblogic.knex.control.ControlHandler.invoke(ControlHandler.java:260) at
ibas.AccountControl.getTransactionHistory(AccountControl.ctrl) at
ibas.GetVisaHistoryTransactions.getVisaHistoryTxn(GetVisaHistoryTransactions
.jws:67) </jwErrorDetail>
</detail>
</error>
Note: inter-domain communication is configured properly. The Web Service to
remote EJB works fine without a declarative security.
Any other ideas?
Thank you for your help.
Andre
"Anurag" <[email protected]> wrote in message
news:[email protected]...
Andre,
It seems you are using the URL
jndi:t3://secuser1:[email protected]:7131/AccountDelegatorEJB
whereas you should not be specifying the "t3:" protocol.
The URL should be like
jndi://secuser1:[email protected]:7131/AccountDelegatorEJB
Please do let me know if you see any issues with this.
Note that this will only allow you to access remote EJBs in the same WLS
domain. For accessing EJBs on another domain, you need to configure
inter-domain communication by
following a few simple steps as mentioned at
http://e-docs.bea.com/wls/docs81/ConsoleHelp/jta.html#1106135. This link has
been provided in the EJB Control Workshop documentation.
Regards,
Anurag
"Andre Shergin" <[email protected]> wrote in message
news:[email protected]...
Raj,
I tried that before, it didn't help. I got similar error message:
<error>
<faultcode>JWSError</faultcode>
<faultstring>Error during JNDI lookup from
jndi:t3://secuser1:[email protected]:7131/AccountDelegatorEJB[Lookup
failed for
name:t3://secuser1:[email protected]:7131/AccountDelegatorEJB]</faultstr
ing>
<detail>
<jwErrorDetail> weblogic.jws.control.ControlException: Error during JNDI
lookup from
jndi:t3://secuser1:[email protected]:7131/AccountDelegatorEJB[Lookup
failed for
name:t3://secuser1:[email protected]:7131/AccountDelegatorEJB] at
weblogic.knex.control.EJBControlImpl.acquireResources(EJBControlImpl.java:27
8) at
weblogic.knex.context.JwsInternalContext.acquireResources(JwsInternalContext
.java:220) at
weblogic.knex.control.ControlHandler.invoke(ControlHandler.java:260) at
ibas.AccountControl.getTransactionHistory(AccountControl.ctrl) at
ibas.GetSecure.retrieveVisaHistoryTxn(GetSecure.jws:64) </jwErrorDetail>
</detail>
</error>
Anything else should I try?
P.S. AccountDelegatorEJB, the remote EJB my Web Service calls is NOTaccess
restricted.
I hope there is a solution.
Thanks,
Andre
"Raj Alagumalai" <[email protected]> wrote in message
news:[email protected]...
Andre,
Can you try using the following url with username and password
jndi://username:password@host:7001/my.resource.jndi.object ?
once you add webapp level security, the authenticated is the user who
invokes the EJB.
http://e-docs.bea.com/workshop/docs81/doc/en/workshop/guide/controls/ejb/con
CreatingANewEJBControl.html?skipReload=true
has more info on using remote EJB's.
Hope this helps.
Thanks
Raj Alagumalai
WebLogic Workshop Support
"Alla Resnik" <[email protected]> wrote in message
news:[email protected]...
Hello everyone,
I developed a Web Service prototype accessing remote EJB using the EJB
control with special syntax in the jndi-name attribute: @jws:ejb
home-jndi-name="t3://10.10.245.70:7131/AccountDelegatorEJB"
Everything works fine, but I get an error when I restrict access to my
web
service with a declarative security model by implementing steps
provided
in
help doc:
- Define the web resource you wish to protect
- Define which security role is required to access the web resource
- Define which users are granted the required security role
- Configure WebLogic Server security for my web service(Compatibility
Security/Users)
I launch the service by entering the address in a web browser. Whenprompted
to accept the digital certificate, click Yes, when prompted for
network
authentication information, enter username and password, navigate tothe
Test Form tab of Test View, invoke the method by clicking the buttonand
I
get the following exception:
<error>
<faultcode>JWSError</faultcode>
<faultstring>Error during JNDI lookup from
jndi:t3://10.10.245.70:7131/AccountDelegatorEJB[Lookup failed for
name:t3://10.10.245.70:7131/AccountDelegatorEJB]</faultstring>
<detail>
<jwErrorDetail> weblogic.jws.control.ControlException: Error during
JNDI
lookup from jndi:t3://10.10.245.70:7131/AccountDelegatorEJB[Lookupfailed
for name:t3://10.10.245.70:7131/AccountDelegatorEJB] at
weblogic.knex.control.EJBControlImpl.acquireResources(EJBControlImpl.java:27
8) at
weblogic.knex.context.JwsInternalContext.acquireResources(JwsInternalContext
.java:220) at
weblogic.knex.control.ControlHandler.invoke(ControlHandler.java:260)at
ibas.AccountControl.getTransactionHistory(AccountControl.ctrl) at
ibas.GetSecure.retrieveVisaHistoryTxn(GetSecure.jws:64)</jwErrorDetail>
</detail>
</error>
I have a simple Hello method as well in my WebService (which is also
restricted) and it works fine, but remote EJB access doesn't. I testedmy
prototype on Weblogic 7.2 and 8.1 platforms - same result.
Is that a bug or I am missing some additional configuration in order
to
get
that working. Has anyone seen similar behavior? Is there a knownresolution?
Or a suggested way to work around the problem?
Thank you.
Andre -
Stand-alone JNDI lookup of an EJB in an Enterprise Application (EAR) build
Hi All,
I am having some difficulty doing JNDI look up an EJB 3.0 Bean that is part of an Enterprise Application (EAR) build. Below are all the related codes:
package ejb;
import javax.ejb.Local;
@Local
public interface Hello1Local {
public String getHello1();
package ejb;
import javax.ejb.Stateless;
@Stateless
public class Hello1Bean implements Hello1Local {
public String getHello1() {
return "I am Hello1 Bean!";
package ejb;
import javax.ejb.Remote;
@Remote
public interface Hello2Remote {
public String getHello2();
package ejb;
import javax.ejb.Stateless;
import javax.ejb.EJB;
@Stateless
@EJB(name="ejb/Hello1",
beanInterface=Hello1Local.class,
beanName="Hello1Bean")
public class Hello2Bean implements Hello2Remote {
@EJB private Hello1Local hello1bean;
public String getHello2() {
return hello1bean.getHello1();
There is no problem looking up Hello2 Bean using an Application Client such as the following:
public class LocalHelloApplicationClient {
@EJB(name="Hello2")
private static Hello2Remote hello2Bean;
public static void main(String[] args) {
System.out.println("hello2Bean.getHello2(): " + hello2Bean.getHello2());
}There is also no problem doing JNDI lookup (from a Stand-Alone Client the same bean if both Hello1 and Hello2 were created by themselves. ie not part of an Enterprise Application (EAR) build. However, I am wondering whether it is possible to do JNDI lookup of the same bean (Hello2) that is part of an Enterprise Application (EAR) built. Below are the type of JNDI lookup entries that I have tried without success:
public class StandalonePojoCallHelloWorld {
public static void main(String [] args)
try
InitialContext jndiContext = new InitialContext();
Hello2Remote hello2Bean = (Hello2Remote) jndiContext.lookup("ejb.Hello2Remote");
or
Hello2Remote hello2Bean = (Hello2Remote) jndiContext.lookup("LocalHelloEnterpriseApplication.Hello2.remote");
or
Hello2Remote hello2Bean = (Hello2Remote) jndiContext.lookup("LocalHelloEnterpriseApplication.ejb.Hello2Remote");
or
Hello2Remote hello2Bean = (Hello2Remote) jndiContext.lookup("LocalHelloEnterpriseApplication.Hello2Remote");
or
Hello2Remote hello2Bean = (Hello2Remote) jndiContext.lookup("LocalHelloEnterpriseApplication.LocalHelloEnterpriseApplication-ejb.Hello2Remote");
System.out.println("hello2Bean.getHello2(): " + hello2Bean.getHello2());
catch (javax.naming.NamingException ne)
ne.printStackTrace();
They all came up with the same error message:
javax.naming.NameNotFoundException: LocalHelloEnterpriseApplication.LocalHelloEnterpriseApplication-ejb.Hello2Remote not found
at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:216)
at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:188)
at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:74)
at com.sun.enterprise.naming.RemoteSerialContextProviderImpl.lookup(RemoteSerialContextProviderImpl.java:129)
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)Any suggestion would be appreciated.
Thanks,
JackHello
I've somme problems to get access to ejb interface from remote stand-alone client.
Here is my EJB code :
package stateless;
import javax.ejb.Stateless;
@Stateless(name = "TestSB", mappedName = "ejb/stateless/TestSB")
public class TestEJBBean implements TestEJBRemote {
public String getMessage() {
return "Hello EJB World";
}And the remote interface :
package stateless;
import javax.ejb.Remote;
@Remote
public interface TestEJBRemote {
String getMessage();
} In client side, i just edit main.java like this :
package testclient;
import java.io.FileInputStream;
import java.util.Properties;
import javax.naming.InitialContext;
import stateless.TestEJBRemote;
public class Main {
public static void main(String[] args) throws Exception {
Properties props = new Properties();
props.load(new FileInputStream("jndi.properties"));
InitialContext ctx = new InitialContext(props);
TestEJBRemote testEJB = (TestEJBRemote) ctx.lookup("ejb/stateless/TestSB");
System.out.println(testEJB.getMessage());
}here is my jndi.properties file (my glassfish server IP is 192.168.0.10) :
java.naming.factory.initial = com.sun.enterprise.naming.SerialInitContextFactory
java.naming.factory.url.pkgs = com.sun.enterprise.naming
java.naming.factory.state = com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl
org.omg.CORBA.ORBInitialHost = 192.168.0.10
org.omg.CORBA.ORBInitialPort = 3918when i run client on the same machine than the glassfish app server, it works fine.
But i run it on the different machine than the glassfish app server (on the same LAN without firewall), it fails with this error message :
eclan@eclan-laptop:~/NetBeansProjects/TestClient$ java -jar dist/TestClient.jar
24 août 2008 09:53:05 com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl <init>
ATTENTION: "IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: 127.0.1.1; port: 3918"
org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2690)
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2711)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:261)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:274)
at com.sun.corba.ee.impl.transport.SocketOrChannelContactInfoImpl.createConnection(SocketOrChannelContactInfoImpl.java:130)
at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.beginRequest(CorbaClientRequestDispatcherImpl.java:192)
at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.request(CorbaClientDelegateImpl.java:181)
at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.is_a(CorbaClientDelegateImpl.java:325)
at org.omg.CORBA.portable.ObjectImpl._is_a(ObjectImpl.java:112)
at org.omg.CosNaming.NamingContextHelper.narrow(NamingContextHelper.java:69)
at com.sun.enterprise.naming.SerialContext.narrowProvider(SerialContext.java:131)
at com.sun.enterprise.naming.SerialContext.getRemoteProvider(SerialContext.java:220)
at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.java:160)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:398)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at testclient.Main.main(Main.java:14)
Caused by: java.lang.RuntimeException: java.net.ConnectException: Connection refused
at com.sun.enterprise.iiop.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:347)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:244)
... 13 more
Caused by: java.net.ConnectException: Connection refused
at sun.nio.ch.Net.connect(Native Method)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:507)
at com.sun.corba.ee.impl.orbutil.ORBUtility.openSocketChannel(ORBUtility.java:105)
at com.sun.enterprise.iiop.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:332)
... 14 more
24 août 2008 09:53:05 com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl <init>
ATTENTION: "IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: 127.0.1.1; port: 4038"
org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2690)
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2711)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:261)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:274)
at com.sun.corba.ee.impl.transport.SocketOrChannelContactInfoImpl.createConnection(SocketOrChannelContactInfoImpl.java:130)
at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.beginRequest(CorbaClientRequestDispatcherImpl.java:192)
at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.request(CorbaClientDelegateImpl.java:181)
at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.is_a(CorbaClientDelegateImpl.java:325)
at org.omg.CORBA.portable.ObjectImpl._is_a(ObjectImpl.java:112)
at org.omg.CosNaming.NamingContextHelper.narrow(NamingContextHelper.java:69)
at com.sun.enterprise.naming.SerialContext.narrowProvider(SerialContext.java:131)
at com.sun.enterprise.naming.SerialContext.getRemoteProvider(SerialContext.java:220)
at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.java:160)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:398)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at testclient.Main.main(Main.java:14)
Caused by: java.lang.RuntimeException: java.net.ConnectException: Connection refused
at com.sun.enterprise.iiop.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:347)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:244)
... 13 more
Caused by: java.net.ConnectException: Connection refused
at sun.nio.ch.Net.connect(Native Method)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:507)
at com.sun.corba.ee.impl.orbutil.ORBUtility.openSocketChannel(ORBUtility.java:105)
at com.sun.enterprise.iiop.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:332)
... 14 more
24 août 2008 09:53:05 com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl <init>
ATTENTION: "IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: 127.0.1.1; port: 4138"
org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2690)
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2711)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:261)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:274)
at com.sun.corba.ee.impl.transport.SocketOrChannelContactInfoImpl.createConnection(SocketOrChannelContactInfoImpl.java:130)
at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.beginRequest(CorbaClientRequestDispatcherImpl.java:192)
at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.request(CorbaClientDelegateImpl.java:181)
at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.is_a(CorbaClientDelegateImpl.java:325)
at org.omg.CORBA.portable.ObjectImpl._is_a(ObjectImpl.java:112)
at org.omg.CosNaming.NamingContextHelper.narrow(NamingContextHelper.java:69)
at com.sun.enterprise.naming.SerialContext.narrowProvider(SerialContext.java:131)
at com.sun.enterprise.naming.SerialContext.getRemoteProvider(SerialContext.java:220)
at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.java:160)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:398)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at testclient.Main.main(Main.java:14)
Caused by: java.lang.RuntimeException: java.net.ConnectException: Connection refused
at com.sun.enterprise.iiop.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:347)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:244)
... 13 more
Caused by: java.net.ConnectException: Connection refused
at sun.nio.ch.Net.connect(Native Method)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:507)
at com.sun.corba.ee.impl.orbutil.ORBUtility.openSocketChannel(ORBUtility.java:105)
at com.sun.enterprise.iiop.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:332)
... 14 more
24 août 2008 09:53:05 com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl <init>
ATTENTION: "IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: 127.0.1.1; port: 3918"
org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2690)
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2711)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:261)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:274)
at com.sun.corba.ee.impl.transport.SocketOrChannelContactInfoImpl.createConnection(SocketOrChannelContactInfoImpl.java:130)
at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.beginRequest(CorbaClientRequestDispatcherImpl.java:192)
at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.request(CorbaClientDelegateImpl.java:181)
at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.is_a(CorbaClientDelegateImpl.java:325)
at org.omg.CORBA.portable.ObjectImpl._is_a(ObjectImpl.java:112)
at org.omg.CosNaming.NamingContextHelper.narrow(NamingContextHelper.java:69)
at com.sun.enterprise.naming.SerialContext.narrowProvider(SerialContext.java:131)
at com.sun.enterprise.naming.SerialContext.getRemoteProvider(SerialContext.java:220)
at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.java:160)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:398)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at testclient.Main.main(Main.java:14)
Caused by: java.lang.RuntimeException: java.net.ConnectException: Connection refused
at com.sun.enterprise.iiop.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:347)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:244)
... 13 more
Caused by: java.net.ConnectException: Connection refused
at sun.nio.ch.Net.connect(Native Method)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:507)
at com.sun.corba.ee.impl.orbutil.ORBUtility.openSocketChannel(ORBUtility.java:105)
at com.sun.enterprise.iiop.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:332)
... 14 more
24 août 2008 09:53:05 com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl <init>
ATTENTION: "IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: 127.0.1.1; port: 4038"
org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2690)
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2711)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:261)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:274)
at com.sun.corba.ee.impl.transport.SocketOrChannelContactInfoImpl.createConnection(SocketOrChannelContactInfoImpl.java:130)
at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.beginRequest(CorbaClientRequestDispatcherImpl.java:192)
at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.request(CorbaClientDelegateImpl.java:181)
at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.is_a(CorbaClientDelegateImpl.java:325)
at org.omg.CORBA.portable.ObjectImpl._is_a(ObjectImpl.java:112)
at org.omg.CosNaming.NamingContextHelper.narrow(NamingContextHelper.java:69)
at com.sun.enterprise.naming.SerialContext.narrowProvider(SerialContext.java:131)
at com.sun.enterprise.naming.SerialContext.getRemoteProvider(SerialContext.java:220)
at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.java:160)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:398)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at testclient.Main.main(Main.java:14)
Caused by: java.lang.RuntimeException: java.net.ConnectException: Connection refused
at com.sun.enterprise.iiop.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:347)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:244)
... 13 more
Caused by: java.net.ConnectException: Connection refused
at sun.nio.ch.Net.connect(Native Method)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:507)
at com.sun.corba.ee.impl.orbutil.ORBUtility.openSocketChannel(ORBUtility.java:105)
at com.sun.enterprise.iiop.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:332)
... 14 more
24 août 2008 09:53:05 com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl <init>
ATTENTION: "IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: 127.0.1.1; port: 4138"
org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2690)
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2711)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:261)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:274)
at com.sun.corba.ee.impl.transport.SocketOrChannelContactInfoImpl.createConnection(SocketOrChannelContactInfoImpl.java:130)
at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.beginRequest(CorbaClientRequestDispatcherImpl.java:192)
at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.request(CorbaClientDelegateImpl.java:181)
at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.is_a(CorbaClientDelegateImpl.java:325)
at org.omg.CORBA.portable.ObjectImpl._is_a(ObjectImpl.java:112)
at org.omg.CosNaming.NamingContextHelper.narrow(NamingContextHelper.java:69)
at com.sun.enterprise.naming.SerialContext.narrowProvider(SerialContext.java:131)
at com.sun.enterprise.naming.SerialContext.getRemoteProvider(SerialContext.java:220)
at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.java:160)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:398)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at testclient.Main.main(Main.java:14)
Caused by: java.lang.RuntimeException: java.net.ConnectException: Connection refused
at com.sun.enterprise.iiop.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:347)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:244)
... 13 more
Caused by: java.net.ConnectException: Connection refused
at sun.nio.ch.Net.connect(Native Method)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:507)
at com.sun.corba.ee.impl.orbutil.ORBUtility.openSocketChannel(ORBUtility.java:105)
at com.sun.enterprise.iiop.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:332)
... 14 more
eclan@eclan-laptop:~/NetBeansProjects/TestClient$ THANKS YOU FOR YOUR HELP
Justin
Maybe you are looking for
-
Delete all calendars from iPhone?
My wife got a hand-me-down iPhone 3G from her brother. It has all of his calendars in it. Can we remove these calendars without having to sync it with something like Outlook? She connects this to an XP machine, not my Mac. She just wants to obliterat
-
Finding the multiple JRE installed path in Linux OS
for my requirement on finding the JRE installaiton folder on windows and Linux machines , I can able to get it in windows but I am facing problem in getting the jre installed path from Linux machine. I am using Debian etch OS. Can anyone help me to f
-
Get text frame's angle of rotation
Hello. Does anyone know if there's a way to get/return a text frame's angle of rotation? I've searched through the CS4 AppleScript documentation and the closest I found was a text frame's "matrix" property which seems to be used to rotate an object b
-
What are the objects that support documentation?
What are the objects that support documentation?
-
Clear in FCE, but then blurry when exported!
I made a movie in FCE. Here is the info for the videos i used to make it - 1280 by 720 HD = dimensions/H.264, interger (little Endian) = codec! However when i export it with quicktime conversion w/ the same specs. it comes out saying it 720 hd