Lookup of an EJB from a plain class outside iAS
Hi all,
I'm pretty new to iAS so excuse me if my question is too simple.
My question is:
I've deployed a standalone EJB into iAS, but I don't know how to do a
lookup from a class which is in outside iAS.
I am used to lookup the following way:
Hashtable l_hash = new Hashtable(2);
l_hash.put("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
l_hash.put("java.naming.provider.url", "100.10.10.10:1099"); //
host : port
InitialContext l_jndiContext = new
javax.naming.InitialContext(l_hash);
MyEJBHome l_myEJBHome = (MyEJBHome)
l_jndiContext.lookup("java:comp/env/ejb/MyEJBBean");
Can I do it the same way? and if so, which is the port iAS listens to?
TIA.......... Juan
Look at Chapter9 of the Developer's Guide and the converter sample.
(Especially if you have sp2 or earlier.)
The summary is that you just have to pass the parameters of a CXS in
your Hashtable. Assuming that you have sp3. If you have sp2 or earlier,
there is also a CLASSPATH workaround you must employ.
iAS can listen to any port. You specify it when you set up the CXS. (See
the Server Configuration part of Chapter 9). The default is 9010.
David
Juan Arraiza wrote:
Hi all,
I'm pretty new to iAS so excuse me if my question is too simple.
My question is:
I've deployed a standalone EJB into iAS, but I don't know how to do a
lookup from a class which is in outside iAS.
I am used to lookup the following way:
Hashtable l_hash = new Hashtable(2);
l_hash.put("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
l_hash.put("java.naming.provider.url", "100.10.10.10:1099"); //
host : port
InitialContext l_jndiContext = new
javax.naming.InitialContext(l_hash);
MyEJBHome l_myEJBHome = (MyEJBHome)
l_jndiContext.lookup("java:comp/env/ejb/MyEJBBean");
Can I do it the same way? and if so, which is the port iAS listens to?
TIA.......... Juan
Similar Messages
-
Help me which JNDIFactory to use to access EJB from a java class of JAR
I am confused in understanding the different JNDI factories
RMIInitialContextFactory, ApplicationInitialContextFactory and ApplicationClientInitialContextFactory
And the different namespaces like global, container local and component local.
Especially is there any relationship between the JNDI factories and the namespaces?
Or are they related to the deployment descriptors.
Because in application specific deployment descriptors (orion-ejb-jar.xml), we just map the JNDI location with the object (or its reference from ejb-jar.xml). We dont specify it can be accessed from this factory or that.
Shall we access an EJB from using any JNDI factory?
Specifically, I am stuck with what Factory to use to access an EJB from a Java class in a library (jar). The JAR is packaged with the EAR which contains the EJB Jar that I am trying to access.
THANK YOUEd,
As Robin said, I think you need code similar to this:
Context c = new InitialContext();
Object o = c.lookup("java:comp/env/Name");where Name is the name of your EJB as it appears in the "ejb-jar.xml"
deployment descriptor XML file.
Good Luck,
Avi. -
Invalid guid error looking up EJB from a startup class
Gentlemen,
I am receiving an "invalid guid at GDS" error that is similar to others reported at:
http://softwareforum.sun.com/servlet/ProcessRequest?RHIVEID=181&RPAGEID=135&HOID=50B500000008000000FE090000&UCATEGORY_0=_29_%24_24_6_&UCATEGORY_S=0
and
http://softwareforum.sun.com/servlet/ProcessRequest?RHIVEID=181&RPAGEID=135&HOID=50B500000008000000FE090000&UCATEGORY_0=_29_%24_24_6_&UCATEGORY_S=0
In my case, I can retrieve the EJB from my rich client with no problems. However, if I execute the exact
same code from within a startup class (i.e. com.iplanet.ias.startup.StartupClass) then I get the following error repeated until memory runs out:
javax.naming.NameNotFoundException: MessageRepositoryBean : Invalid guid null in
GDS
at com.netscape.server.ejb.EjbContext.lookup(Unknown Source)
at com.netscape.server.jndi.RootContext.lookup(Unknown Source)
at com.netscape.server.jndi.RootContext.lookup(Unknown Source)
at javax.naming.InitialContext.lookup(InitialContext.java:357)
at com.netscape.ejb.CorbaHomeFactoryImpl.ConstructEJBHome(Unknown Source
at com.netscape.CosNaming.NamingContextImpl.resolve(Unknown Source)
at org.omg.CosNaming._NamingContextImplBase.invoke(_NamingContextImplBas
e.java:233)
at com.sun.corba.ee.internal.corba.ServerDelegate.dispatch(ServerDelegat
e.java:236)
at com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:227)
at com.sun.corba.ee.internal.iiop.CachedWorkerThread.doWork(IIOPConnecti
on.java:262)
at com.sun.corba.ee.internal.iiop.CachedWorkerThread.run(IIOPConnection.
java:230)
javax.naming.NameNotFoundException: MessageRepositoryBean : Invalid guid null in
In previous answers people have suggested adding various things to the app server classpath. This does not make any difference for me. I am puzzled why code runs fine in a normal rich client, but not in a startup class. Here is the code that I am running:
try
String contextFactory = "com.sun.jndi.cosnaming.CNCtxFactory";
String providerURL = "iiop://localhost:9010";
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory);
p.put(Context.PROVIDER_URL, providerURL);
Context context = new InitialContext(p);
MessageRepositoryHome home = (MessageRepositoryHome)
PortableRemoteObject.narrow(context.lookup("ejb/MessageRepository"), MessageRepositoryHome.class);
MessageRepository repository = home.create();
catch(Exception e)
e.printStackTrace(Log.err);
System.exit(1);
Thanks for your help,
MarkI was mistaken in this posting. I was able to access the EJB from the startup class so there must be something else that I am doing to cause this problem. I'd still like to know why I get those invalid guid errors though.
By the way, please forgive me for using the gender-specific gentlemen in my posting. That was accidental. -
I'm using OC4J 10.1.3 Standalone.
I have a requirement to initialize web services and configuration parameters during app server start up.
Accordingly,I planned to call a EJB 2.0 stateless session bean from a StartUp class.
The ejb is responsible for initializing some configurations and web services.The ejb is dependent on some other classes which are present as utility jars .
However,I cannot somehow figure out how to refer the EJB from my startup class because the EAR which contains the EJB jar is in a child loader to that containing the startup class.
Please guide me!! Please suggest if some alternative approach could be taken to suffice my requirement.
TIAAvi, I was just waiting for the "servlet hack".
I really prefer the application client way, much cleaner, no servlet container needed, and could be tested outside the container.
--olaf -
Linkage Error Looking up EJB from BPEL (11g)
I am using 11g TP3.
I have a BPEL process that is using WSIF to call a plain java class. Then from this class I am attempting to lookup an EJB in another application (but on the same server).
My code looks like this...
env.put( Context.INITIAL_CONTEXT_FACTORY, "oracle.j2ee.rmi.RMIInitialContextFactory" );
env.put( Context.SECURITY_PRINCIPAL, "fmwadmin" );
env.put( Context.SECURITY_CREDENTIALS, "welcome" );
env.put(Context.PROVIDER_URL, "ormi://localhost:23891/DisEM");
javax.naming.InitialContext ctx =
new javax.naming.InitialContext(env);
Object obj = ctx.lookup("DisConfigManager");
I get a Linkage error on the lookup stating it "violates loader constraints" on class com/evermind/server/rmi/RMIClientConnection
Below is the full error text. Any help would be appreciated. Thanks.
Mar 26, 2008 8:49:31 AM oracle.j2ee.util.AnnotatedLogger log
WARNING: Exception returned by remote server: java.lang.LinkageError: Class com/evermind/server/rmi/RMIClientConnection violates loader constraints
08/03/26 08:49:31 got an exception looking up DisConfigManager: javax.naming.NamingException: Error resolving reference <Reference Class Name: javax.ejb.EJBObject
Type: location
Content: test-managers_DisConfigManager_BeanBinding
Type: CachePolicy
Content: NEVER
: javax.naming.NamingException: Lookup error: javax.naming.NamingException: Class com/evermind/server/rmi/RMIClientConnection violates loader constraints [Root exception is java.lang.LinkageError: Class com/evermind/server/rmi/RMIClientConnection violates loader constraints]; nested exception is: javax.naming.NamingException: Class com/evermind/server/rmi/RMIClientConnection violates loader constraints [Root exception is java.lang.LinkageError: Class com/evermind/server/rmi/RMIClientConnection violates loader constraints] [Root exception is javax.naming.NamingException: Class com/evermind/server/rmi/RMIClientConnection violates loader constraints [Root exception is java.lang.LinkageError: Class com/evermind/server/rmi/RMIClientConnection violates loader constraints]]
08/03/26 08:49:31 <INFO> WSIFBinding=> [MIB2ScanCartridge/MIB2ScanCartridge!1.0*2008-02-27_13-37-54_124.FinalizeScanService]:finalize Performing outbound request/response interaction..
Mar 26, 2008 8:49:43 AM oracle.j2ee.util.AnnotatedLogger logI was mistaken in this posting. I was able to access the EJB from the startup class so there must be something else that I am doing to cause this problem. I'd still like to know why I get those invalid guid errors though.
By the way, please forgive me for using the gender-specific gentlemen in my posting. That was accidental. -
Initiating Quartz from a startup class
Has anyone implemented quartz in a server startup class for scheduling?
Would this be a potential way of using quartz or is it not recommended?
Thanks for any thoughts on the subject.
TobyI was mistaken in this posting. I was able to access the EJB from the startup class so there must be something else that I am doing to cause this problem. I'd still like to know why I get those invalid guid errors though.
By the way, please forgive me for using the gender-specific gentlemen in my posting. That was accidental. -
Issue in accessing EJB from plain java
Hi,
I am new to OAS. I am using OAS 10.1.2.
I want to access EJB which runs inside OAS, through a plain java program which runs from outside the OAS environment (standalone java program).
I am confused on what to use. RMIInitialContextFactory or ApplicationClientInitialContextFactory for the context in the java program.
what should be the provide URL ?
java.naming.provider.url","ormi://hostname:18140/
is it "ormi" or something else? what is the port number should i use. there are many ports in this OAS. i see that in the console("Ports") link.
also let me know what should i mention in the EJB xml descriptor.
Is this lookup to be done by retrieving from jndi?
pls help.
Thanks,
Sukumar
with this confusion i developed an EJB with the following details
ejb-jar.xml
<ejb-ref>
<ejb-ref-name>ejb/testDetails</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<home>com.xxx.xxx.testDetailsHome</home>
<remote>com.xxx.xxx.testDetails</remote>
</ejb-ref>
orion-ejb-jar.xml
<entity-deployment name="ejb/testDetails" location="ejb/testDetails"
Client Java program
public class testDetailsClient
public static void main(String [] args)
testDetailsClient testDetailsClient = new testDetailsClient();
try
Context context =getInitialContext();
testDetailsHome testDetailsHome = (testDetailsHome)PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/testDetails"), testDetailsHome.class);
testDetails testDetails;
catch(Throwable ex)
ex.printStackTrace();
private static Context getInitialContext() throws NamingException
Hashtable env = new Hashtable();
env.put("java.naming.factory.initial","com.evermind.server.rmi.RMIInitialContextFactory");
//env.put("java.naming.factory.initial","com.evermind.server.ApplicationClientInitialContextFactory");
env.put("java.naming.provider.url","ormi://host_name:18140/"); //23791 18140
env.put(Context.SECURITY_PRINCIPAL, "ias_admin");
env.put(Context.SECURITY_CREDENTIALS, "abc123");
InitialContext context = new InitialContext(env);
return context;
if i execute this, it says
javax.naming.NameNotFoundException: java:comp/env/ejb/testDetails not found
18140 is Application Server Control RMI port.
if i run the same code with ApplicationClientInitialContextFactory, it throws exception saying
java.lang.InstantiationException: No location specified and no suitable instance of the type 'com.testdetails.testDetails' found for the ejb-ref ejb/testDetails
at com.evermind.server.administration.ApplicationResourceFinder.getEJBHome(ApplicationResourceFinder.java:268)
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:324)
at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:124)
at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:48)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
at java.lang.Thread.run(Thread.java:534)
javax.naming.NamingException: Error reading application-client descriptor: No location specified and no suitable instance of the type 'com.testdetails.testDetails' found for the ejb-ref ejb/testDetails
at com.evermind.server.ApplicationClientInitialContextFactory.getInitialContext(ApplicationClientInitialContextFactory.java:161)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.<init>(InitialContext.java:195)
at com.testdetails.testDetailsClient.getInitialContext(testDetailsClient.java:89)
at com.testdetails.testDetailsClient.main(testDetailsClient.java:20)
pls helpHi,
you do not have to package your EJB and PAR together! You can deploy them separately and then reference the J2EE Application from your PAR or vice versa to access it.
For instance you can access the EJB from your PAR as described here:
http://help.sap.com/saphelp_nw2004s/helpdata/en/42/9ddf20bb211d72e10000000a1553f6/frameset.htm
Or you can access a Portal application from J2EE like described here:
http://help.sap.com/saphelp_nw2004s/helpdata/en/42/9ddd0cbb211d72e10000000a1553f6/frameset.htm
Even if you package your PAR in to the same EAR with your EJB they will result in two different containers on the J2EE Engine and you will have to reference them as described in the link above to access the functionality of one component from the other.
Best regards,
Stefan Brauneis -
'Class Cast Exception' while invoking a EJB from a Servlet
Hi,
I am working on J2EE applications.I am using Webgain studio and weblogic server.I
got a problem while invoking EJB from the servlet.
While calling an EJB from the servlet, it is giving that "Class Cast Exception".This
is because, the remote home reference is not able to type casted to the"Home Interface"
of the EJB, even if I type casted explicitly. It is creating the context and able
to identify the EJB with the JNDI name.
Could please help me in solving this problem.I am pasting the code here.
Thanks in advance,
Dharma
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
resp.setContentType("text/html");
PrintWriter out = new PrintWriter(resp.getOutputStream());
try
Context context=getInitialContext();
Object reference=context.lookup("ArlProjContractorAppletSession");
ArlProjContractorAppletSessionHome home=(ArlProjContractorAppletSessionHome)PortableRemoteObject.narrow(reference,ArlProjContractorAppletSessionHome.class);
//Exception is occuring in the above statement. It is unable
//to cast to the home interface
ArlProjContractorAppletSession the_ejb=null;
try
the_ejb=home.create();
System.out.println("the_ejb = " + the_ejb.toString());
catch(Exception e)
e.printStackTrace();
catch(Exception e)
e.printStackTrace();
// to do: code goes here.
out.println("<HTML>");
out.println("<HEAD><TITLE>Contractor TimeTracker</TITLE></HEAD>");
out.println("<BODY>");
// to do: your HTML goes here.
out.println("</BODY>");
out.println("</HTML>");
out.close();
I came across this kind of problem once. My problem went away after I upgraded
from 5.1 SP6 to 5.1 SP8.
"Dharma" <[email protected]> wrote:
>
>Hi,
>
>I am working on J2EE applications.I am using Webgain studio and weblogic
>server.I
>got a problem while invoking EJB from the servlet.
>
>While calling an EJB from the servlet, it is giving that "Class Cast
>Exception".This
>is because, the remote home reference is not able to type casted to the"Home
>Interface"
>of the EJB, even if I type casted explicitly. It is creating the context
>and able
>to identify the EJB with the JNDI name.
>
>Could please help me in solving this problem.I am pasting the code here.
>
>Thanks in advance,
>Dharma
>
>
>public void doGet(HttpServletRequest req, HttpServletResponse resp)
> throws ServletException, IOException
> {
> resp.setContentType("text/html");
> PrintWriter out = new PrintWriter(resp.getOutputStream());
>
> try
> {
>
> Context context=getInitialContext();
>
> Object reference=context.lookup("ArlProjContractorAppletSession");
>
> ArlProjContractorAppletSessionHome home=(ArlProjContractorAppletSessionHome)PortableRemoteObject.narrow(reference,ArlProjContractorAppletSessionHome.class);
>
>//Exception is occuring in the above statement. It is unable
>//to cast to the home interface
>
> ArlProjContractorAppletSession the_ejb=null;
>
> try
> {
> the_ejb=home.create();
>
> System.out.println("the_ejb = " + the_ejb.toString());
>
> }
> catch(Exception e)
> {
> e.printStackTrace();
> }
> }
> catch(Exception e)
> {
> e.printStackTrace();
> }
> // to do: code goes here.
>
> out.println("<HTML>");
> out.println("<HEAD><TITLE>Contractor TimeTracker</TITLE></HEAD>");
> out.println("<BODY>");
>
> // to do: your HTML goes here.
>
> out.println("</BODY>");
> out.println("</HTML>");
> out.close();
> }
>
>
>
>
>
-
Calling EJB from class in same ear
Has anyone ever attempted to call an EJB from a class that is in the same ear?
I have a singleton class, not
another EJB, that is trying to get ahold of an EJB to call a method. This method
has been defined to have both
a local and remote interface.
I thought I should be able to get a hold of the local interface. When I try to
get the interface out of JNDI
as follows:
PickupCpaLocalHome cpaHome = (PickupCpaLocalHome) ctx.lookup("pickup.PickupCpaEJBLocal");
I get an exception:
javax.naming.LinkException: [Root exception is
javax.naming.NameNotFoundException: Unable to resolve
'app/ejb/PickupCpaEJB.jar#PickupCpaEJB/local-home' Resolved: 'app/ejb'
Unresolved:'PickupCpaEJB.jar#PickupCpaEJB' ; remaining name
'PickupCpaEJB.jar#PickupCpaEJB/local-home']; Link Remaining Name:
'java:app/ejb/PickupCpaEJB.jar#PickupCpaEJB/local-home'
When I look at the JNDI tree using the WebLogic console, it shows that "pickup.PickupCpaEJBLocal"
is
in JNDI.
Since the local interface doesn't work, I thought I'd try the remote interface.
The remote interface
works fine from my client and from another EJB in a different ear. Using the
remote interface I get an
exception when trying to cast the result to my home.
java.lang.ClassCastException:
com.fedex.pickup.j2ee.ejb.cpa.PickupCpaEJB_gapk5_HomeImpl_WLStub
// Code
PickupCpaHome cpaHome = (PickupCpaHome) ctx.lookup("pickup.PickupCpaEJBRemote");
As I mentioned earlier, the same code works in a client and in an EJB in another
ear.
Any ideasHas anyone ever attempted to call an EJB from a class that is in the same ear?
I have a singleton class, not
another EJB, that is trying to get ahold of an EJB to call a method. This method
has been defined to have both
a local and remote interface.
I thought I should be able to get a hold of the local interface. When I try to
get the interface out of JNDI
as follows:
PickupCpaLocalHome cpaHome = (PickupCpaLocalHome) ctx.lookup("pickup.PickupCpaEJBLocal");
I get an exception:
javax.naming.LinkException: [Root exception is
javax.naming.NameNotFoundException: Unable to resolve
'app/ejb/PickupCpaEJB.jar#PickupCpaEJB/local-home' Resolved: 'app/ejb'
Unresolved:'PickupCpaEJB.jar#PickupCpaEJB' ; remaining name
'PickupCpaEJB.jar#PickupCpaEJB/local-home']; Link Remaining Name:
'java:app/ejb/PickupCpaEJB.jar#PickupCpaEJB/local-home'
When I look at the JNDI tree using the WebLogic console, it shows that "pickup.PickupCpaEJBLocal"
is
in JNDI.
Since the local interface doesn't work, I thought I'd try the remote interface.
The remote interface
works fine from my client and from another EJB in a different ear. Using the
remote interface I get an
exception when trying to cast the result to my home.
java.lang.ClassCastException:
com.fedex.pickup.j2ee.ejb.cpa.PickupCpaEJB_gapk5_HomeImpl_WLStub
// Code
PickupCpaHome cpaHome = (PickupCpaHome) ctx.lookup("pickup.PickupCpaEJBRemote");
As I mentioned earlier, the same code works in a client and in an EJB in another
ear.
Any ideas -
Call EJB from a thread , pb with lookup
Hello,
I have seen taht it is possible to call an EJB within a thread that can act as a client. But in my case when the thread calls the EJB method the lookup failed. I do exactly the same like if I call the ejb from an external client.
In my case I have got the following architecture:
one MDB which receive a message the pass the a "manager of thread" which select a thread and then this thread calls a session bean. Everything goes well until the thread call the EJB method and at this time the lookup fail. I call from local interface as I constructed my jar with all this components inside, i.e the MDB, the thread manager, threads and the session bean.
I tried to call the session bean from the MDB in the same way I have done from the thread and in that configuration its ok.
Is there a specific manner to lookup an ejb when we want to call it from a thread or simply this configuration is completely impossible?
Thanks for any adviceinsert the following code before creating the InitialContext:
Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); -
EJB from stored procedure lookup problem
We are running a test case with in an EJB deployed to Oracle 8.1.6, accessing it from a Java stored procedure. It works okay if the stored procedure is called a limited number of times from a single client (client is non-Java). However, for performance testing, we are trying to run it several hundred times in sequence to better simulate the eventual production environment. Consistently on the 216th call, it fails with a NamingException from the InitialContext lookup. We can restart the client again and it will fail on the same call.
Sounds like something memory related to me. Does anyone have any ideas? I'm using standard EJB client code in my stored procedure, instantiating an InitialContext, performing a lookup on the EJB, performing a home interface create, then accessing an EJB method.
Thinking it might be that my test was too fast for whatever garbage collection is being done on the server, I tried a 2 second delay between invocations--same problem occurs, however. Should I be making a call to remove my EJBs when my stored procedure ends? If so, how would I do that?
I did try making the handle to my EJB a static variable within the stored procedure and only "creating" the EJB once. That works okay with a single client, but if I run 2 clients simultaneously, 1 will work for awhile and then eventually die trying to call the EJB method--while the other client continues to run successfully.
I'm stumped. Any insight or guidance will be greatly appreciated. Thanks.My DBA bumped up the large_pool_size and java_pool_size settings and the problem went away. I couldn't convince him to bump the settings one at a time, so am not sure which one was at the root of the problem.
As I looked at the trace logs on the server, I also noticed that we were getting intermittent "peer disconnected socket" messages during the testing. That appears to have gone away with the pool size increases, also--in case that helps out anyone else. -
EJBs From JSPs - Tutorials?
Hi all,
I've just been given a task, and I don't know where to start. I've been given an EJB and I need to write a web front end to test it (JSP). Now if it was a plain JavaBean, I know how to do it. But I know EJB's are different.
Could somebody point me in the direction of a good tutorial about accessing EJBs from JSPs. I'm using WebLogic as my application server, so something relevant to that would be nice.
Cheers for any help.To put it in "idiot" terms:
Think of your EJBs as people you want to ring up on the phone. You know their name, but not their number. How do you do this in real life? You use a phone book, using the person's name as a reference, which will lead you to the right number to dial.
The phonebook in this paradigm is JNDI - the naming and directory interfaces.
The name you use to look up is how the EJB is bound (ie, "java:comp/env/ejb/MyPerson", or "foo/bar/beans/MyPerson"). You define this name (the phone number) in the deployment descriptors packaged with the EJBs in the jar file.
You access the phone book (in your JSP or some other bean in your webapp) by using a Context.
ie:
Object objRef = initialContext.lookup("foo/bar/beans/MyPerson");
Then you ask the context for the person's home information:
MyPersonHome home = (com.foo.interfaces.MyPersonHome)PortableRemoteObject.narrow(objRef, com.foo.interfaces.MyPersonHome.class);
Once you know where they live (you have their Home information), you can ring them up (create them, search for them, search for a singular one)
MyPerson bill = home.findByPersonNameInHouse("billy");
once you have Billy in your possession, yu can perform business logic on him:
String stats = bill.getStatistics();
// get rid of bill permanently
bill.remove();
That should be enough of an introductory paradigm. You will need to follow along the tutorials and other many documents to understand exactly how things are bound (phone numbers are listed) and so forth.
Good luck! -
Error while running EJB from java client on JBOSS
Hi
As i am new to EJB i have created a helloworld application in ejb which is working fine when i try to call it from servlet but when i try to invoke the same ejb from java client (i.e from diff jvm) on jboss i got the following error:
javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused]]]
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1399)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:579)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at com.gl.TestClient.main(TestClient.java:39)
Caused by: javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused]]
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:254)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1370)
... 4 more
Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused]
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:228)
... 5 more
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:519)
at java.net.Socket.connect(Socket.java:469)
at java.net.Socket.<init>(Socket.java:366)
at java.net.Socket.<init>(Socket.java:266)
at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:69)
at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:62)
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:224)
... 5 more
Following is my code:
Home Interface:
package com.gl;
import javax.ejb.CreateException;
public interface testHome extends EJBHome {
String JNDI_NAME = "testBean";
public test create()
throws java.rmi.RemoteException,CreateException;
Remote Interface:
package com.gl;
import java.rmi.RemoteException;
import javax.ejb.EJBObject;
public interface test extends EJBObject {
public String welcomeMessage() throws RemoteException;
Bean:
package com.gl;
import java.rmi.RemoteException;
import javax.ejb.EJBException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
public class testbean implements SessionBean {
public void ejbActivate() throws EJBException, RemoteException {
// TODO Auto-generated method stub
public void ejbPassivate() throws EJBException, RemoteException {
// TODO Auto-generated method stub
public void ejbRemove() throws EJBException, RemoteException {
// TODO Auto-generated method stub
public void setSessionContext(SessionContext arg0) throws EJBException,
RemoteException {
// TODO Auto-generated method stub
public void ejbCreate(){}
public String welcomeMessage(){
return "Welcome to the World of EJB";
ejb-jar.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>testBean</ejb-name>
<home>com.gl.testHome</home>
<remote>com.gl.test</remote>
<ejb-class>com.gl.testbean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>
jboss.xml:
<?xml version='1.0' ?>
<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.2//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">
<jboss>
<enterprise-beans>
<entity>
<ejb-name>testBean</ejb-name>
<jndi-name>testBean</jndi-name>
</entity>
</enterprise-beans>
</jboss>
Client code:
package com.gl;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
public class TestClient {
public static void main(String[] args) throws Exception{
try{
/* Properties props=new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
props.put(Context.PROVIDER_URL, "jnp://localhost:1099");
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
props.put(Context.PROVIDER_URL, "localhost:1099");
System.out.println("Properties ok");
//env.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.jboss.naming.HttpNamingContextFactory");
//env.put(Context.PROVIDER_URL,"http://localhost:8080");
//env.put(Context.SECURITY_PRINCIPAL, "");
//env.put(Context.SECURITY_CREDENTIALS, "");
Context ctx=new InitialContext(props);
System.out.println("context ok");
//testHome home = (testHome)ctx.lookup("testBean");
Object obj = ctx.lookup ("testBean");
System.out.println("ojb = " + obj);
testHome ejbHome = (testHome)PortableRemoteObject.narrow(obj,testHome.class);
test ejbObject = ejbHome.create();
String message = ejbObject.welcomeMessage();
System.out.println("home ok");
System.out.println("remote ok");
System.out.println(message);
catch(Exception e){e.printStackTrace();}
I am able to successfully deployed my ejb on JBOSS but i m getting above error when i am trying to invoke ejb from java client.
kindly suggest me something to solve this issue.
Regards
Gagan
Edited by: Gagan2914 on Aug 26, 2008 3:28 AMIs it a remote lookup? Then maybe this will help:
[http://wiki.jboss.org/wiki/JBoss42FAQ]
- Roy -
Any difference in creating a web service from a java class or session bean?
Hi,
The JDeveloper tutorial at http://www.oracle.com/technology/obe/obe1013jdev/10131/devdepandmanagingws/devdepandmanagingws.htm demonstrates creating a web service from a plain java class. I'm wondering:
- Is it possible to create a web service from a stateless session bean instead of a java class? If so, what's the proper way to do this in JDeveloper? When I tried doing so in JDeveloper 10.1.3.0.4 (SU5) using the J2EE Web Service wizard, the wizard did not list the session bean in the Component To Publish dropdown (it does list any java classes available in the project). I can proceed by manually typing in the name of the session bean. After the wizard completes though, the @Stateless annotation that had been in my session bean class code is removed and replaced by a @WebService annotation. The end result is that it looks like it made no difference whether I had tried to create the web service from a session bean or plain java class as the annotations in the resulting web service code are the same (although if I had started from a session bean, the class for the web service still implements the Local/Remote EJB interface that the session bean originally implemented).
- Assuming it's possible to create a web service from a stateless session bean, is there any advantage/disadvantage creating a web service from a java class vs a stateless session bean? I'm creating the web service from scratch so I also need to either build the java class or stateless session bean the web service would be based on from scratch too.
Thanks for any ideas about this.Hi,
EJB Session beans (EJB 3.0) are deployed as WebServices by annotating the class with @WebService and the methds with @WebMethod (both tags require you to add the JSR-181 library to your project (available in the JDeveloper list of libraries)). Unlike the J2E WebService, the EJB session bean service is turned into a WebService upon deployment. This means you obtain teh WSDL file after deployment
- Assuming it's possible to create a web service from a stateless session bean, is there any advantage/disadvantage creating a web service from a java class vs a stateless session bean?
The difference is that EJB Session bean based web services are integrated with the J2EE container, which means that they can leverage container services like transaction handling, data sources, security, JMS etc.
Frank -
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.
Maybe you are looking for
-
Transfer data from Powermac G4 to new 27" iMac
I have a 2003 PowerMac G4 that I am replacing with a new 27" iMac 3.4 i7 which is on order. I want to transfer my photos and iTunes files to the new machine. I had purchased a LaCie d2 USB3/Thunderbolt harddrive in hopes of backing up the G4 but it i
-
Error Ipod Touch Stuck In Recovery Mode
hey guys ive got an ipod touch and after updateing it today to 2.2.1 it now wont turn on it is showing the itunes icon and usb connector ive plugged it back in to the computer i installed the update on and it says this ipod is in recovery mode ive tr
-
Planned Cost not coming for CO Activity in PM Order
Dear All, I am putting up the entire configuration process i am carrying out for CO activity and using it in the PM Order. Please see the link and guide me through as to why the Planned Cost for the Activity is mssing. http://www.scribd.com/doc/21375
-
Is there some way to configure FF so that BOOKMARKS can be accessed while in F11 mode? IE provides access to BOOKMARKS while in F11 mode so I would assume that FF does also.
-
Unable to set up networking with systemd-networkd
I'm trying to set up networking on a VPS I purchased. When I boot off the arch install image, the networking set up is configured via DHCP and everything seems to work perfectly. This is the configuration I see from the ip addr and ip route commands: