Referencing EJB from WAR frile
Dear All,
I have an deployed ejb, and want to reference this in a servlet within a WAR file.
How do I do this without also placing the ejb
classes within the WAR ! I realise that I could jar it all up into an EAR file
but would rather keep the components seperate..
Any help would be greatly appreciated
Kind regards
Tony
The ideal way to reference an ejb from a war file is,
1. Include the home, local, remote interfaces, Primary Key and
Exception classes (if any) in a <ejb-name>-ejb-client.jar.
2. Include the ejb implementation classes in <ejb-name>-ejb.jar and
reference the <ejb-name>-ejb-client.jar in its manifest file.
3. In war web.xml define an <ejb-ref> for each ejb that you need to
reference
4. Reference the ejb in your code using the ejb-ref name
4. Include the <ejb-name>-ejb-client.jar in the war file.
5. Include the war, <ejb-name>-ejb-client.jar, <ejb-name>-ejb.jar in
an ear file and deploy.
Dinesh Bhat
"Arne Christian H rseth" <[email protected]> wrote in message news:<[email protected]>...
What is an "expanded EAR file format"?
Could someone please give a link to more information?
Arne
Robert Patrick <[email protected]> wrote:
You can deploy in an "expanded EAR file format" which will allow you
to
work with the individual components but still have all the conveniences
of an EAR.
Tony May wrote:
Dear All,
I have an deployed ejb, and want to reference this in a servlet within
a WAR file.
How do I do this without also placing the ejb
classes within the WAR ! I realise that I could jar it all up intoan EAR file
but would rather keep the components seperate..
Any help would be greatly appreciated
Kind regards
Tony
Similar Messages
-
Accessing EJBs from a Web project
Hi,
I am getting the error: "com.sap.engine.services.jndi.persistent.exceptions.NameNotFoundException: Path to object does not exist at java:comp, the whole lookup name is java:comp/env/ejb/UserInfoServer." when I try to access the session bean from my web project. I have followed the instructions explicitly in http://help.sap.com/saphelp_nw04s/helpdata/en/55/29ed5eff965448941c0b42f01b9804/frameset.htm and also tried every other combination I can think of for configuring the references in both the EJB project & the web project (both in the same ear). I do have a jndi name in the visual administrator for localebjs/sap.com/myEar/UserInfoServer. Does anyone have any ideas?
Thanks & merry Christmas/Happy New year to all the SDN folks!I've managed to get around the problem for the time being by using "/localejbs/provider/application/beanName" - bypassing (I think) the whole JNDI issue - this is OK for now, but it's obviously not a long term fix.
Previously, I had used the default & so did not enter anything in the ejb-j2ee-engine.xml, and so my ejb's showed up nicely in the Visual Administrator JNDI Registry under the localejbs tab as you would expect. The problem appears to be in the Web project - The key is that the error is "Path to object not found" rather than "Name not found". It seems to me that it knows what it is looking for & that it is valid, but doesn't know how to get there! Note that the EJB project is in the same EAR. The only reference to "Path" that I can find is in the help doc above where it says "If the name of the target enterprise bean is not unique in the enterprise application scope, you can enter the path to the JAR file that contains the bean...". I've gone through the Car Rental Application pdf (I can't find the download that contains the entire application) & followed the instructions there explicitly for referencing ejbs from the web.. -
Access EJB from Servlet that in different archive?
<font class="mediumtxt">package kyro.ejb.session;
import javax.ejb.*;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
@Stateless(name="StandAlone")
@Remote(StandAlone.class)
public class StandAloneBean
implements StandAlone, StandAloneLocal
public StandAloneBean() {
public String sayHello() {
return "sayHello";
I want to access ejb from servlet that .war and .jar not in single .ear. I want to try that just with annotation not xml descriptor cause is easy to understand for me. I use Glassfish. But i can't lookup that ejb. How can i lookup that ejb with jndi? Can't you give me example of servlet to access that? I not use JNDI.properties, are that caused i can't access my ejb? I just thing .war and.jar in one server, are i have to used JNDI.properties. can you explain how to use JNDI.properties in servlet or separate file?
</font>But i can't lookup that ejb. How are you trying and what exception is occurring?
How can i lookup that ejb with jndi? [https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html|https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html]
m -
Calling EJB from Oracle via IIOP
I've spent the last two days trying to figure out how I can call an
EJB from an Oracle Stored Procedure. I first looked into WLS JNDI
(Using WLInitialContextFactory ), but my collegue recommended I look
into IIOP because it is "less proprietary". I was able to get a WL
example working that does a lookup on an EJB and "narrows" the IIOP
object...so it looked promissing, but then I tried to load the JAR
into Oracle and it said:
"referenced name javax/rmi/PortableRemoteObject could not be found"
So I did a quick check and it looks like this didn't come into
existance until JDK 1.3. By all accounts, Oracle 8.1.6 supports JDK 2
(1.2). So now I'm stuck. I've got a few examples about connecting to
the Oracle ORB using session-iiop, but I don't know if Weblogic will
be able to work with this. I don't know how I'd even call it because
the URL requires an Oracle SID...so now what? I see three options.
Please let me know which would be best (or another option that I'm
missing)
1. Try connecting with Weblogic "T3"
2. Try to get the right combination of classes loaded so 1.2 can work
like 1.3
3. Use the Oracle IIOP (I have no examples for connecting to other
ORBs so I have no idea how to lookup objects).
Chris[email protected] (Chris Snyder) writes:
Andy Piper <[email protected]> wrote in message news:<[email protected]>...
[email protected] (Chris Snyder) writes:
1. Try connecting with Weblogic "T3"It depends on what version of WLS you are using. If you are using 6.1
then you are out-of-luck because this only support JDK 1.3.1.We are using WLS 6.1 and Oracle 8.1.6. There's got to be a way to
connect what is essentially a 1.2 JVM to a 1.3.1 JVM. On my way home
yesterday I was wondering if just straight RMI would work...although
we need to encrypt the connection. I've seen several people talk
about calling EJB's from stored procedures so it seems like there is a
way. Any other ideas?The really gross way is HTTP. In a previous life I had a customer use
oracle's HTTP plug-in to do this. You could probably invert the
problem also. I.e. write CORBA objects that sit inside an Orb hosted
in WLS and invoke on those using oracle's CORBA support. But HTTP is
probably the way most likely to work. You probably couldn't use RMI
over HTTP either - you would have to write a servlet that delegated to
your beans.
andy -
Loading remote EJB from servlet using jakarta and openejb
I am trying to create an environment where I use
openejb as my EJB container, and JAKARTA Tomcat
as my
Servlet/JSP container. However,
i'm having a problem in lookingup my remote EJB from my
jakarta application.
That exact code works perfectly if I run it standalone. I
am using the same JRE. Jakarta has also loaded the
openejb-0.8.3.jar and openejb_client-0.8.3.jar
What I dont understand is why jakarta
would behave differently than command-line java when I
am
running in the same JRE on a single machine.
Any help would be much appreciated.Several fairly major improvements have been maid in OpenEJB specifically for the Tomcat people. For one, the whole way you integrate them has completely been rewritten. Now all you have to do is copy a openejb_loader-0.9.1.war into the Tomcat webapps directory and change an init-param in it. Pretty straight forward. OpenEJB 0.8.3 won't work with Tomcat in the same VM, however OpenEJB 0.9.0 and up have been totally revamped in all things related to classloading so that it can co-exist with Tomcats unique classloading architecture.
O'Reilly just published an article detailing the ins and outs of the integration, it's a pretty good read:
http://www.onjava.com/pub/a/onjava/2003/02/12/ejb_tomcat.html -
Accessing WebLogic EJBs from Tomcat 3.2
Has anyone out there tried to access EJBs in a WebLogic 5.10 SP6 app
server from a servlet in Tomcat 3.2? I'm operating under Win2K. When I
try to create the initial naming context, the following exception is
thrown:
java.lang.NoClassDefFoundError: COM/rsa/jsafe/JSAFE_InvalidUseException
at weblogic.security.WLMessageDigest.getInstance
(WLMessageDigest.java:52)
at weblogic.security.MD5RandomBitsSource.seed
(MD5RandomBitsSource.java:56)
at weblogic.rjvm.LocalRJVM.<init>(LocalRJVM.java:108)
at weblogic.rjvm.LocalRJVM.getLocalRJVM(LocalRJVM.java:85)
at weblogic.rjvm.RJVMManager.getLocalRJVM(RJVMManager.java:89)
at weblogic.rjvm.RJVMManager.initialize(RJVMManager.java:78)
at weblogic.kernel.Kernel.ensureInitialized(Kernel.java:137)
at weblogic.rjvm.ServerURL.findOrCreateRJVM(ServerURL.java:182)
at
weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(
WLInitialContextFactoryDelegate.java, Compiled Code)
at
weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(
WLInitialContextFactoryDelegate.java:148)
at weblogic.jndi.WLInitialContextFactory.getInitialContext(
WLInitialContextFactory.java:123)
at javax.naming.spi.NamingManager.getInitialContext(
NamingManager.java:771)
at javax.naming.InitialContext.getDefaultInitCtx(
InitialContext.java:169)
at javax.naming.InitialContext.<init>(InitialContext.java:146)
From poking around in the WebLogic server directories, in appears that
the RSA-related classes are implemented as native methods in jsafe.dll.
Should I be trying to install this dll in Tomcat somehow? If so, where
should I be looking for information on how to do this?
-- Erik"Erik Horstkotte" <[email protected]> wrote in message news:[email protected]...
Has anyone out there tried to access EJBs in a WebLogic 5.10 SP6 app
server from a servlet in Tomcat 3.2? I'm operating under Win2K. When I
try to create the initial naming context, the following exception is
thrown:[Sigh. I know it's bad form to follow up your own posts, but...]
Ignore the exact problem description above. I wasn't including
\weblogic\classes and \weblogic\lib\weblogicaux.jar in Tomcat's
classpath. Now the same code connects to the app server:
Connected successfully using http to JIMBO/172.16.1.4:7001
But immediately after connecting, I get a new exception:
java.lang.NoSuchMethodError: java.lang.NoSuchMethodException:
getNameInNamespace
at weblogic.jndi.toolkit.BasicWLContext_WLStub.ensureInitialized
(BasicWLContext_WLStub.java:127)
at weblogic.jndi.toolkit.BasicWLContext_WLStub.<init>
(BasicWLContext_WLStub.java:146)
at java.lang.reflect.Constructor.newInstance(Native Method)
at weblogic.common.internal.ClassTableEntry.newInstance
(ClassTableEntry.java:86)
at weblogic.common.internal.WLObjectInputStreamBase.readLeftover
(WLObjectInputStreamBase.java:248)
at weblogic.common.internal.WLObjectInputStreamBase
.readObjectBody (WLObjectInputStreamBase.java:202)
at weblogic.common.internal.WLObjectInputStreamBase.readObject
(WLObjectInputStreamBase.java:949)
at weblogic.common.internal.WLObjectInputStreamBase.readObjectWL
(WLObjectInputStreamBase.java:308)
at weblogic.jndi.toolkit.WLContextStub.readExternal
(WLContextStub.java:79)
at weblogic.common.internal.WLObjectInputStreamBase
.readPublicSerializable(WLObjectInputStreamBase.java:269)
at weblogic.common.internal.WLObjectInputStreamBase.readLeftover
(WLObjectInputStreamBase.java:254)
at weblogic.common.internal.WLObjectInputStreamBase.readObjectBody
(WLObjectInputStreamBase.java:202)
at weblogic.common.internal.WLObjectInputStreamBase.readObject
(WLObjectInputStreamBase.java:949)
at weblogic.common.internal.WLObjectInputStreamBase.readObjectWL
(WLObjectInputStreamBase.java:308)
at weblogic.rmi.extensions.AbstractInputStream2.readObject
(AbstractInputStream2.java:25)
at weblogic.jndi.internal.RemoteContextFactoryImpl_WLStub
.getContext(RemoteContextFactoryImpl_WLStub.java:99)
at weblogic.jndi.WLInitialContextFactoryDelegate
.newRemoteContext(WLInitialContextFactoryDelegate.java:316)
at weblogic.jndi.WLInitialContextFactoryDelegate.newContext
(WLInitialContextFactoryDelegate.java:242)
at weblogic.jndi.WLInitialContextFactoryDelegate
.getInitialContext(WLInitialContextFactoryDelegate.java, Compiled
Code)
at weblogic.jndi.WLInitialContextFactoryDelegate
.getInitialContext(WLInitialContextFactoryDelegate.java:148)
at weblogic.jndi.WLInitialContextFactory.getInitialContext
(WLInitialContextFactory.java:123)
at javax.naming.spi.NamingManager.getInitialContext
(NamingManager.java:771)
at javax.naming.InitialContext.getDefaultInitCtx
(InitialContext.java:169)
at javax.naming.InitialContext.<init>(InitialContext.java:146)
getNameInNamespace isn't a method in any of my EJB's (that I wrote, at
least - it could be generated by weblogic.ejbc), and it's not a method
I'm calling directly. Presumably, something in the remote session bean
creation is calling this method (of what class?)
Am still I missing classpath entries in Tomcat? If so, which ones?
If you've successfully referenced EJBs in a WebLogic Server from a
Tomcat servlet, what setup changes did you have to make to Tomcat and
WLS to make it fly?
-- Erik -
Persistence shared across EJB and WAR projects
Hi,
I have created an Enteprise Application in netbeans which has an EJB project and a web archive. This may be expanded further at a later time by having an application client as well. I am still fairly new to this so you'll have to forgive me if this is a simple problem. I have a persistence unit (persistence.xml) that I need to share across both WAR and EJB, but so far am not having much luck. I have read various responses and they say I should have the EAR constructed as the following:
project.ear
=======
META-INF/MANIFEST.MF
lib/persistence.jar
---> META-INF
---> META-INF/persistence.xml
project-ejb.jar
project-war.war
When I try and compile it though I get the following messages from both EE modules:
Note: The persistence xml file [META-INF/persistence.xml] was not found. NO GENERATION will occur!! Please ensure a persistence xml file is available either from the CLASS_OUTPUT directory [META-INF/persistence.xml] or using the eclipselink.persistencexml property to specify its location.
I have tried copying the persistence.xml into the main META-INF directory in the EAR file and setting the eclipselink.persistencexml=META-INF/persistence.xml, but it still shows the same thing. Is this a classpath issue or is there something else wrong?
Many thanksThe EAR is a good idea, but you put the META-INF/persistence.xml in your ejb module. The EJB is where you want to do all your (container managed) transactional stuff, so make calls into your EJBs from the WAR in stead of trying to share a persistence unit across modules.
-
Calling an EJB from jsp - ServletException
I am unable to call an EJB from jsp, unless I put the actuall classes of
the EJB into the classpath. Is this the right way to do it?
The exception is:
Servlet failed with ServletException
javax.servlet.ServletException: Servlet class: 'jsp_servlet._result'
could not be loaded - the requested class wasn't found in the
classpath:
'/local/apps/bea/wlserver6.0/config/gmodomain/applications/.wl_temp_do_not_delete/wl_local_comp34107.war:/local/apps/bea/wlserver6.0/./config/gmodomain/applications/.wl_temp_do_not_delete/WEB-INF/_tmp_war_gmo_gmo_webwar:/local/apps/bea/wlserver6.0/config/gmodomain/applications/.wl_temp_do_not_delete/WEB-INF/_tmp_war_gmo_gmo_webwar'
at
weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:532)
at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:191)
at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:148)
at
weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:306)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:208)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:246)
at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:1265)
at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1622)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
where result.jsp is the jsp page calling the EJB. I did an import of the
EJB classes in the jsp.
like i said, it works if I put the bean classes in the classpath. But is
it right?
if I have these in the exploded format, do I need to put anything in the
application web.xml under:
wlserver6.0/config/gmodomain/applications/DefaultWebApp_gmo/WEB-INF ?
redhat 6.2, wl6.0sp1
here are the xml files:
web.xml:
<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<!--
$Id: web.xml,v 1.2 2001/03/14 22:23:03 jeff Exp $
$Source:
/usr/local/cvsroot/JUnitEE/example/components/web-war/WEB-INF/web.xml,v
$
-->
<web-app>
<display-name>My Web Application</display-name>
<description>none</description>
<ejb-ref>
<ejb-ref-name>MyWeb</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>com.blah.ejb.myweb.WyWebHome</home>
<remote>com.blah.ejb.myweb.MyWeb</remote>
</ejb-ref>
</web-app>
weblogic.xml:
<!DOCTYPE weblogic-web-app PUBLIC "-//BEA Systems, Inc.//DTD Web
Application 6.0//EN"
"http://www.bea.com/servers/wls600/dtd/weblogic-web-jar.dtd">
<weblogic-web-app>
<jsp-descriptor>
<jsp-param>
<param-name>
pageCheckSeconds
</param-name>
<param-value>
1
</param-value>
</jsp-param>
<jsp-param>
<param-name>
verbose
</param-name>
<param-value>
true
</param-value>
</jsp-param>
<jsp-param>
<param-name>compileCommand</param-name>
<param-value>/local/apps/jdk1.3.0_02/bin/javac</param-value>
</jsp-param>
</jsp-descriptor>
<reference-descriptor>
<ejb-reference-description>
<ejb-ref-name>MyWeb</ejb-ref-name>
<jndi-name>MyWeb</jndi-name>
</ejb-reference-description>
</reference-descriptor>
</weblogic-web-app>
thanks,
Gary
Did you package your JSPs in a WAR and your EJBs in a JAR and package the
WAR and JAR in an EAR? That is how to do it in 6.0. Works well.
Peace,
Cameron Purdy
Tangosol, Inc.
http://www.tangosol.com
+1.617.623.5782
WebLogic Consulting Available
"gmo" <[email protected]> wrote in message
news:[email protected]...
> I am unable to call an EJB from jsp, unless I put the actuall classes of
> the EJB into the classpath. Is this the right way to do it?
> The exception is:
> Servlet failed with ServletException
> javax.servlet.ServletException: Servlet class: 'jsp_servlet._result'
> could not be loaded - the requested class wasn't found in the
> classpath:
>
'/local/apps/bea/wlserver6.0/config/gmodomain/applications/.wl_temp_do_not_d
elete/wl_local_comp34107.war:/local/apps/bea/wlserver6.0/./config/gmodomain/
applications/.wl_temp_do_not_delete/WEB-INF/_tmp_war_gmo_gmo_webwar:/local/a
pps/bea/wlserver6.0/config/gmodomain/applications/.wl_temp_do_not_delete/WEB
-INF/_tmp_war_gmo_gmo_webwar'
>
> at
>
weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.jav
a:532)
>
> at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:191)
>
> at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:148)
>
> at
>
weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:30
6)
>
> at
>
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:208)
>
> at
>
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:246)
>
> at
>
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
ntext.java:1265)
>
> at
>
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
:1622)
>
> at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
>
> at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>
> where result.jsp is the jsp page calling the EJB. I did an import of the
> EJB classes in the jsp.
> like i said, it works if I put the bean classes in the classpath. But is
> it right?
> if I have these in the exploded format, do I need to put anything in the
> application web.xml under:
> wlserver6.0/config/gmodomain/applications/DefaultWebApp_gmo/WEB-INF ?
>
> redhat 6.2, wl6.0sp1
>
> here are the xml files:
> web.xml:
>
> <?xml version="1.0"?>
> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
> 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
>
> <!--
> $Id: web.xml,v 1.2 2001/03/14 22:23:03 jeff Exp $
> $Source:
> /usr/local/cvsroot/JUnitEE/example/components/web-war/WEB-INF/web.xml,v
> $
> -->
>
> <web-app>
> <display-name>My Web Application</display-name>
> <description>none</description>
> <ejb-ref>
> <ejb-ref-name>MyWeb</ejb-ref-name>
> <ejb-ref-type>Session</ejb-ref-type>
> <home>com.blah.ejb.myweb.WyWebHome</home>
> <remote>com.blah.ejb.myweb.MyWeb</remote>
> </ejb-ref>
> </web-app>
>
> weblogic.xml:
>
> <!DOCTYPE weblogic-web-app PUBLIC "-//BEA Systems, Inc.//DTD Web
> Application 6.0//EN"
> "http://www.bea.com/servers/wls600/dtd/weblogic-web-jar.dtd">
> <weblogic-web-app>
> <jsp-descriptor>
> <jsp-param>
> <param-name>
> pageCheckSeconds
> </param-name>
> <param-value>
> 1
> </param-value>
> </jsp-param>
> <jsp-param>
> <param-name>
> verbose
> </param-name>
> <param-value>
> true
> </param-value>
> </jsp-param>
> <jsp-param>
> <param-name>compileCommand</param-name>
> <param-value>/local/apps/jdk1.3.0_02/bin/javac</param-value>
> </jsp-param>
> </jsp-descriptor>
> <reference-descriptor>
> <ejb-reference-description>
> <ejb-ref-name>MyWeb</ejb-ref-name>
> <jndi-name>MyWeb</jndi-name>
> </ejb-reference-description>
> </reference-descriptor>
> </weblogic-web-app>
>
> thanks,
>
> Gary
>
>
-
Problem calling AS8.2 EJB from Sun WebServer 6.1
Last time I've probably posted my question in to the wrong forum. Sorry for cross-posting, but I really need to solve this issue.
I am calling an EJB from a JSF portlet. When I deploy the portlet on a Sun Portal 7, running on a Webserver 6.1, then
InitialContext.lookup(String)
returns
com.sun.corba.se.impl.corba.CORBAObjectImpl
instead of
...MyClassHome_DynamicStub
The PortableRemoteObject.narrow then returns null instead of the class...
I've found a solution to this here: http://forum.java.sun.com/thread.jspa?forumID=136&threadID=619420
The solution is to use another INITIAL_CONTEXT_FACTORY:
props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.appserv.naming.S1ASCtxFactory")
But I need this to be done on a WebServer, and
com.sun.appserv.naming.S1ASCtxFactory is contained in the Application server jar (appserver-rt.jar I believe).
According to this:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6336410
I can't use this jar in the Sun Webserver. And it's probably true, the portlet doesn't work with the jar packaged in to the WAR.
Is there any other solution to this?Is there any other solution to this?Yes, there is. The EJB Client Jar was missing the RMI stubs. When I called the EJB from the AS8, the server probably created the stubs, but webserver didn't.
rmic -iiop classname solved the issue. -
Challenge: call local ejb from remote ejb on weblogic 9.2
Hi ALL,
How do I call to local ejb from remote ejb object. The jar file is deployed on weblogic server 9.2, if you want get it http://geocities.yahoo.com.br/lindembe/BEAProject.jar and the source code are http://geocities.yahoo.com.br/lindembe/BEAProject.zip. It is a sample app with two ejb that works so good on JBOSS, JOnAS, but BEA Weblogic.....
The complete problem you watch http://forum.java.sun.com/thread.jspa?threadID=768718&messageID=4387570#4387570
or
http://forums.bea.com/bea/message.jspa?messageID=600043148&tstart=0Your code in SigemFacadeBean should just do:
InitialContext ctx = new InitialContext();
when you lookup the local EJB. (This will work on all app servers. There's no need to put an app-server specific intial context factory in your code.)
Also, you can remove the jndi-name setting for the local ejb from your weblogic-ejb-jar.xml. jndi-name is only applied to remote ejbs.
-- Rob
WLS Blog http://dev2dev.bea.com/blog/rwoollen/ -
How can i access the EJB from a Webdynpro
Dear all,
How can i access the ejb , from a webdynpro?.
Is there any way to do that?.
I want to write the entire code (business functions) within the EJB and i wan to access the entire methods from a WebDynpro Application.This is the situation.
Please help me to , resolve this problem.(Here im using JDBC Connection .. etc.).
I want to do the basic connection setting's and data retrieval part within the EJB and use that within the WebDynpro..
how can i seperate this two(i mean, i want to seperate the JDBC connections and WebDynpro,i dont want to hard code any connection parameters within the webdynpro code)
So that i want use that saet of particular function's in many webdynpro applications..
(i dont need any help regarding webservice way.)
If anyone can , please help me..
I tried that javabean class , manifest file , that way (importing javabean model).
but im getting errors.
I cant properly utilize that..
So please help me with steps regarding that,,
for javabean
and if any , for EJB also..
with regards
Kishor.GHI,
Since webdynpros follows Model View Controller Architecture You can access EJBs in webdynpro(views/frontend) infact to connec to database uding JDBC you have to utilise EJB ( opening connection to database closing, and other Business functionality).See this link
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/unkown/web dynpro tutorial and sample applications.faq#q-7
<b>How to access the Car Rental Web Service?</b>
Regards,
RK -
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 -
HOW TO CALL A WEB SERVICE OR EJB FROM BPEL
HI
i want to call java web service or ejb from my bpel process. how can i do this.
i am using oracle soa10.1.3.1.0 and jdeveloper 10.1.3.1.0 and oracle database xe 10g.
thanks in advance K ROYYou could deploy your EJB or Java under a web service into your OC4J, after that, you invoke a partnerlink from BPEL to the destination of wsdl will do. Also don't forget to add in your XSD schema as well.
Thanks,
Jyno -
'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();
> }
>
>
>
>
>
-
Can I call an EJB from the database?
Hi,
I've just spent the last few days attempting to call an EJB from a stored procedure in a 10g database (and still haven't succeeded).
Now having spent hours searching the web (and this forum) for any successful examples (so far I have found none) I thought I'd add a message to see if there is anybody out there who has done this successfully. If so can you please provide me some details on how to do this?
Alternatively, I'd appreciate any input on how I can overcome my current hurdle in attempting to do this myself.
Here's how far I've got in my attempt:
I have a simple stateless session bean deployed to both Oracle 10gAS (a standalone OC4J container in 10.1.3) and to Weblogic 9. I have a client java class that calls a method on this bean and displays some ouput if successful. This all works from a standalone JVM (version 1.4) on both Weblogic and 10gAS.
I then tried to load the required libraries for Weblogic onto the database (namely the Weblogic.jar file). This resulted in the addition of some 32,000 odd objects of which 30,000 odd could not be resolved. I figured a lot of these may be down to JVM version issues (I believe that Weblogic 9 uses the 1.5 JRE) so I decided to put the Weblogic test on the back burner for now and just use the Oracle app server.
The tests with the Oracle app server looked promising. I only needed a handful of libraries to be loaded onto the database and all the relevant classes required for my test client had resolved (including the initial context factory required to do the jndi lookup of the bean). After granting all the permissions I believed I needed I'd got to the point where I could do a jndi lookup of the EJB; but when I tried to create an instance of the beans remote interface I got the following error:
java.security.AccessControlException: the Permission (java.lang.RuntimePermission getClassLoader) has not been granted to ProtectionDomain (file:generated/by/proxy <no certificates>)
com.evermind.net.DynamicClassLoader@612d9d34
<no principals>
java.security.Permissions@eb0f3c1a (
(java.util.PropertyPermission java.version read)
(java.util.PropertyPermission java.vm.name read)
(java.util.PropertyPermission java.vm.vendor read)
(java.util.PropertyPermission os.name read)
(java.util.PropertyPermission java.vendor.url read)
(java.util.PropertyPermission java.vm.specification.vendor read)
(java.util.PropertyPermission java.specification.vendor read)
(java.util.PropertyPermission os.version read)
(java.util.PropertyPermission java.specification.name read)
(java.util.PropertyPermission java.class.version read)
(java.util.PropertyPermission file.separator read)
(java.util.PropertyPermission java.vm.version read)
(java.util.PropertyPermission os.arch read)
(java.util.PropertyPermission java.vm.specification.name read)
(java.util.PropertyPermission java.vm.specification.version read)
(java.util.PropertyPermission java.specification.version read)
(java.util.PropertyPermission java.vendor read)
(java.util.PropertyPermission path.separator read)
(java.util.PropertyPermission line.separator read)
(java.net.SocketPermission localhost:1024- listen,resolve)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:280)
at java.security.AccessController.checkPermission(AccessController.java:429)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:528)
at oracle.aurora.rdbms.SecurityManagerImpl.checkPermission(SecurityManagerImpl.java:192)
at java.lang.Thread.getContextClassLoader(Thread.java:1203)
at com.evermind.server.rmi.RMICall.<init>(RMICall.java:36)
at com.evermind.server.rmi.RmiCallQueue.createCall(RmiCallQueue.java:33)
at com.evermind.server.rmi.RMIClientConnection.createQueuedCall(RMIClientConnection.java:592)
at com.evermind.server.rmi.RMIClientConnection.writeRequest(RMIClientConnection.java:581)
at com.evermind.server.rmi.RMIClientConnection.sendMethodInvocationRequest(RMIClientConnection.java:426)
at com.evermind.server.rmi.RMIClientConnection.invokeMethod(RMIClientConnection.java:415)
at com.evermind.server.rmi.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:63)
at com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(RecoverableRemoteInvocationHandler.java:28)
at __Proxy0.create(Unknown Source)
at com.axiomsystems.test.client.TestDBClient.test(TestDBClient.java:76)
Has anybody come across this before? If so can they help?
If not has anybody out there actually managed to call an EJB method (without going via an RMI server/Servlet/or any other proxy).
Any help in this matter would be greatfully appreciated.
Cheers,
Anand.Sure, here's the code. It's what JDev generates automatically but I have seperated some things into several diffrent lines so I could experiment easier.
final Context context = getInitialContext();
Object o=context.lookup( "SessionEJB4" );
Object l= PortableRemoteObject.narrow( o, SessionEJB4Home.class );
final SessionEJB4Home sessionEJB4Home = (SessionEJB4Home)l;
SessionEJB4 sessionEJB4 = sessionEJB4Home.create();
String ret=( sessionEJB4.hello( ) );
As I mentioned, for this I have used EJB2.1 bean, because I had same problems with EJB3.0, so I tried earlier versions of Java to make sure that is not the problem.
hello() method just returns string "hello".
Of course, this works in standalone client that is not loaded into database.
Now, I loaded all the jars mentioned in this thread, using loadjava options -v -resolve, and I loaded client using options -v -resolve -genmissing . Select query on user objects in database shows that client class and relevant classes are all valid.
Then I created stub and ran it. First it stopped throwing exception ORA-29532: Java call terminated by uncought Java exception: Java.lang.NoClassDefFoundError.
Method I try to run returns String value which is hello message if it works fine, else it prints the part of the stack trace. In this case, after p[revious error, When I try to run it again, i get return from the method :
Lookup error: java.lang.NoClassDefFoundError; nested exception is:
java.lang.NoClassDefFoundError
com.evermind.server.rmi.RMICall.throwRecordedException(RMICall.java:89)
com.evermind.server.rmi.RMIClientConnection.waitForJndiResponse(RMIClientConnection.java:371)
com.evermind.server.rmi.RMIClientConnection.lookup(RMIClientConnection.java:179)
com.evermind.server.rmi.RMIClient.lookup(RMIClient.java:283)
com.evermind.server.rmi.RMIClientContext.lookup(RMIClientContext.java:51)
javax.naming.InitialContext.lookup(InitialContext.java:347)
simpleejbproject.EJB4Client.hello(EJB4Client.java:35)
Of course, regular version of the client I run frokm command line works fine.
So I'm kind of a stuck here. I followed all directions, tried it on oracle 9 and oracle 10 DB, the problems remain the same. Am I missing something here?
Thanks
Just to add, getInitialContext()
private static Context getInitialContext() throws NamingException {
Hashtable env = new Hashtable();
// Oracle Application Server 10g connection details
env.put( Context.INITIAL_CONTEXT_FACTORY, "oracle.j2ee.rmi.RMIInitialContextFactory" );
env.put( Context.SECURITY_PRINCIPAL, "oc4jadmin" );
env.put( Context.SECURITY_CREDENTIALS, "manager1" );
env.put(Context.PROVIDER_URL, "opmn:ormi://mserv:4005:home/TestEjb4");
return new InitialContext( env );
It goes withouth any exceptions.
Message was edited by:
user510152
Maybe you are looking for
-
Something weird happening with View Options....
Hi!, OK, so I go into my hard drive root (where the library, users, system folders are). I go to the View menu and choose Show View Options. In that small panel, I check the Show Item info checkbox so that it shows me all the info about folders. I en
-
Not more than one service order against same sales document item
A service order gets created against the sales order item as per standard SAP process. As credit management is active, when the order is under credit block for the customer the service order gets created only after the credit block is released. On r
-
Database upgrade process and step
Hi, I am trying to do as following: I have old server with 10.2.0.3 32 bits on Linux. We are trying to have RH Linux 5.4 64 bits and oracle 10.2.0.3 64 bits. How can i restore from 10.2.0.3 32 bits cold backup to new server? Thanks Pat Edited by: use
-
Click on email not heard (sometimes) after 10.7.2 update
I've noticed that since I did the recent Lion update to 10.7.2 that when I'm in Mail (the new interface, not classic) that SOMETIMES when I click on a email in my message list that it does not pop into the view pane. Sometimes it is heard, other time
-
Does the iPhone 4S problem of reducing the signal quality? ("capture of death")
Does the iPhone 4S problem of reducing the signal quality? ("capture of death")