Unable to access EJB from servlet
Hi,
I have in service method my servlet code.
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.ApplicationInitialContextFactory");
env.put(Context.PROVIDER_URL, "ormi://localhost/hello");
env.put(Context.SECURITY_PRINCIPAL, "admin");
env.put(Context.SECURITY_CREDENTIALS, "mypwd");
Context ctx = new InitialContext(env);
Object obj = ctx.lookup("HelloName");
HelloHome home = (HelloHome) javax.rmi.PortableRemoteObject.narrow(obj, HelloHome.class);
Hello hello = home.create();
this is how i have orion-ejb-jar.xml
<enterprise-beans>
<session-deployment name="Hello" location="HelloName" >
</session-deployment>
</enterprise-beans>
ejb-jar.xml
<session>
<ejb-name>Hello</ejb-name>
<home>examples.HelloHome</home>
<remote>examples.Hello</remote>
<local-home>examples.HelloLocalHome</local-home>
<local>examples.HelloLocal</local>
<ejb-class>examples.HelloBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
When i access the servlet i get this error.
javax.naming.NameNotFoundException: HelloName not found
at com.evermind.server.rmi.RMIContext.lookup(RMIContext.java:149)
at com.evermind.server.ApplicationContext.lookup(ApplicationContext.java:217)
at com.evermind.server.ApplicationContext.lookup(ApplicationContext.java:88)
at javax.naming.InitialContext.lookup(InitialContext.java:345)
at examples.HelloServlet.service(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:772)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:782)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
at java.lang.Thread.run(Thread.java:479)
Is location attribute in orion-ejb-jar.xml used to specify JNDI name? Can i get the JNDI tree showing the name mappings in oc4j? How do i correct this error?
Ravi
Ravi --
The most portable and standards oriented solution is to define an ejb-ref in the web.xml for the servlet, and then look up the name using the formal EJB UNC model.
web.xml:
<ejb-ref>
<ejb-ref-name>ejb/AppSessionFacadeHome</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>faqapp.ejb.AppSessionFacadeHome</home>
<remote>faqapp.ejb.AppSessionFacade</remote>
</ejb-ref>
servlet lookup
InitialContext ctx = new InitialContext();
Object homeObject = ctx.lookup("java:comp/env/ejb/AppSessionFacadeHome");
EJBHome ejbHome = (EJBHome)
portableRemoteObject.narrow (homeObject, AppSessionFacadeHome.class);
cheers
-steve-
Similar Messages
-
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 -
Problem accessing ejb from servlet
Hi,
I'm aving a problem accessing a stateful session bean from a servlet. I'm using a jndi lookup to do it because I need that a client has its own bean reference...
My code into the service method is:
InitialContext ctx;
try {
ctx = new InitialContext();
carrelloService = (CarrelloLocal)ctx.lookup("java:comp/env/ejb/Carrello");
and I have a reference to EJB into web.xml:
<ejb-local-ref>
<ejb-ref-name>ejb/Carrello</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home></local-home>
<local>carrello.model.CarrelloLocal</local>
</ejb-local-ref>
If I use @EJB annotation to inject the servlet, it works fine.
Instead using jndi lookup throws a NamingException because it doesn't find java:comp/env/ejb/Carrello entry.
Any idea about the problem?Here's something simple that I have that works:
<p> </p>
SimpleBean
<p> </p>
@Stateless(name="SimpleBean")
public class SimpleBeanBean implements SimpleBeanLocal {
<p> </p>
web.xml; -- note I use a whacko ejb-ref-name just to make it obvious where I'm using it.
<p> </p>
<ejb-local-ref>
<ejb-ref-name>ejb_mapping_doodad/SimpleBean</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local>sab.otn681398.ejb.SimpleBeanLocal</local>
</ejb-local-ref><p> </p>
servlet:
<p> </p>
package sab.otn681398.web;
import java.io.IOException;
import java.io.PrintWriter;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.*;
import javax.servlet.http.*;
import sab.otn681398.ejb.SimpleBeanLocal;
public class TestServlet extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=windows-1252";
private static final String SIMPLE_BEAN_JNDI = "ejb_mapping_doodad/ASimpleBean";
private final boolean USEENC = true;
private SimpleBeanLocal simple = null;
public void init(ServletConfig config) throws ServletException {
super.init(config);
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
try {
if(simple==null) {
simple = createSimple();
} catch(NamingException ne) {
throw new ServletException("Error in looking up the EJB", ne);
out.println("<html>");
out.println("<head><title>TestServlet</title></head>");
out.println("<body>");
out.printf("<p>The %s bean has been hit: %s times</p>", simple, simple.getHitCount());
out.println("</body></html>");
out.close();
private SimpleBeanLocal createSimple() throws NamingException {
return (USEENC==true? createSimpleViaENC(): createSimpleViaName());
private SimpleBeanLocal createSimpleViaENC() throws NamingException {
InitialContext ic = new InitialContext();
SimpleBeanLocal simple = (SimpleBeanLocal)ic.lookup("java:comp/env/" + SIMPLE_BEAN_JNDI);
return simple;
private SimpleBeanLocal createSimpleViaName() throws NamingException {
InitialContext ic = new InitialContext();
SimpleBeanLocal simple = (SimpleBeanLocal)ic.lookup(SIMPLE_BEAN_JNDI);
return simple;
}<p> </p>
-steve- -
Unable to call EJB from servlet
Fillowing is my ejb module
package univesity;
import java.rmi.RemoteException;
import javax.ejb.*;
public interface EnrollmentCartHome extends javax.ejb.EJBHome
EnrollementCartObject create() throws CreateException,RemoteException;
package univesity;
import java.rmi.RemoteException;
public interface EnrollementCartObject extends javax.ejb.EJBObject
public void addCourse(int courseID) throws RemoteException;
package univesity;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
public class EnrollementCartEJBBean implements SessionBean
int courseID;
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 addCourse(int courseID)
System.out.println("i am in add course");
System.out.println("i am in add course--->"+courseID);
public void ejbCreate() throws CreateException
System.out.println("i am in ejbCreate");
courseID=0;
}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">
<jndi-name>ejb/EnrollmentCartHome</jndi-name>
<ejb-jar>
<description>Simplest Statefull Session Bean</description>
<display-name>University EJB</display-name>
<enterprise-beans>
<session>
<ejb-name>Enrollement</ejb-name>
<home>university.EnrollementCartHome</home>
<remote>university.EnrollementCartObject</remote>
<ejb-class>university.EnrollementCartEJBBean</ejb-class>
<session-type>Statefull</session-type>
<transaction-type>Bean</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>here is my servlet
package university;
import javax.naming.InitialContext;
import javax.servlet.*;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class EnrollCourse extends javax.servlet.http. HttpServlet
public void doGet(HttpServletRequest req,HttpServletResponse res)
public void doPost(HttpServletRequest req,HttpServletResponse res)
try {
InitialContext ic = new InitialContext();
Object objRef = ic.lookup("ejb/EnrollmentCartHome");
university.EnrollementCartHome home=(university.EnrollementCartHome)javax.rmi.PortableRemoteObject.narrow(objref, university.EnrollementCartHome.class);
university.EnrollementCartObject obj=(university.EnrollementCartObject)home.create();
obj.addCourse(5);
catch (Exception ex)
{ ex.printStackTrace(); }
}i am getting following error
java.lang.Error: Unresolved compilation problems:
university.EnrollementCartHome cannot be resolved to a type
university.EnrollementCartHome cannot be resolved to a type
objref cannot be resolved
university.EnrollementCartHome cannot be resolved to a type
university.EnrollementCartObject cannot be resolved to a type
university.EnrollementCartObject cannot be resolved to a type
university.EnrollCourse.doPost(EnrollCourse.java:24)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)Thanks for your continuous reply
i solved all problems i have posted but now i am facing new problem that "EJB is already registerd"
giving you stack trace
15:21:22,109 WARN [ServiceController] Problem creating service jboss.j2ee:module=UniversityProjectEJBModule.jar,uid=22223562,service=EjbModule
javax.management.InstanceAlreadyExistsException: jboss.j2ee:jndiName=ejb/EnrollmentCartHome,service=EJB already registered.
at org.jboss.mx.server.registry.BasicMBeanRegistry.add(BasicMBeanRegistry.java:761)
at org.jboss.mx.server.registry.BasicMBeanRegistry.registerMBean(BasicMBeanRegistry.java:225)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.server.MBeanServerImpl$3.run(MBeanServerImpl.java:1422)
at java.security.AccessController.doPrivileged(Native Method)
at org.jboss.mx.server.MBeanServerImpl.registerMBean(MBeanServerImpl.java:1417)
at org.jboss.mx.server.MBeanServerImpl.registerMBean(MBeanServerImpl.java:376)
at org.jboss.ejb.EjbModule.createService(EjbModule.java:373)
at org.jboss.system.ServiceMBeanSupport.jbossInternalCreate(ServiceMBeanSupport.java:260)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:243)
at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
-
Unable to access EJB with servlet as client
Hi,
I am Naga, a java developer trying to work with Weblogic6.1 at present.
When i try to use Servlet as a client to my EJB, I am getting an error
saying that Home class not found.
i have kept the Servlet class file under
E:\bea\wlserver6.1\config\mydomain\applications\DefaultWebApp\WEB-INF\classe
s
folder.
i mentioned the EJB-ref tags in web.xml too, But it is not working.
How to make the EJB home and remote interfaces visible to Servlet with
weblogic6.1 ?
If i put the EJB.jar file under
E:\bea\wlserver6.1\config\mydomain\applications\DefaultWebApp\WEB-INF\lib
directory the application is working. Is this is the only way to do ?
After reading the article "EJB 2 and J2EE Packaging, Part II" at http://www.onjava.com/pub/a/onjava/2001/07/25/ejb.html,
i came to know that their is another way to do this, but i could not get it properly.
If any one could explain about the series of steps involved, that would be
really great and appreciated.
Thanks in advance
Naga.Hi Naga,
If webApp and EJB are deployed as separate components,then you need to have EJB
classes in WEB-INF/classes of your webApp.
If the app is in EAR format then the servlet can see the EJb classes directly.
Thanks,
Vijay
"Nagamahesh" <[email protected]> wrote:
>
Hi,
I am Naga, a java developer trying to work with Weblogic6.1 at present.
When i try to use Servlet as a client to my EJB, I am getting an error
saying that Home class not found.
i have kept the Servlet class file under
E:\bea\wlserver6.1\config\mydomain\applications\DefaultWebApp\WEB-INF\classe
s
folder.
i mentioned the EJB-ref tags in web.xml too, But it is not working.
How to make the EJB home and remote interfaces visible to Servlet with
weblogic6.1 ?
If i put the EJB.jar file under
E:\bea\wlserver6.1\config\mydomain\applications\DefaultWebApp\WEB-INF\lib
directory the application is working. Is this is the only way to do ?
After reading the article "EJB 2 and J2EE Packaging, Part II" at http://www.onjava.com/pub/a/onjava/2001/07/25/ejb.html,
i came to know that their is another way to do this, but i could not
get it properly.
If any one could explain about the series of steps involved, that would
be
really great and appreciated.
Thanks in advance
Naga. -
Unable to access values from database in login page..
Hey all,
Friends I have a login.jsp page and I want if i enter username and password then it will be accessed from database and after verifying the details it will open main.jsp.I made a database as "abc" and created DSN as 1st_login having table 1st_login. But the problem is that I am unable to access values from database.
So Please help me.
Following is my code:
<HTML>
<body background="a.jpg">
<marquee>
<CENTER><font size="5" face="times" color="#993300"><b>Welcome to the"<U><I>XYZ</I></U>" of ABC</font></b></CENTER></marquee>
<br>
<br>
<br>
<br><br>
<br>
<form name="login_form">
<CENTER><font size="4" face="times new roman">
Username
<input name="username" type="text" class="inputbox" alt="username" size="20" />
<br>
<br>
Password
<input type="password" name="pwd" class="inputbox" size="20" alt="password" />
<br/>
<input type="hidden" name="option" value="login" />
<br>
<input type="SUBMIT" name="SUBMIT" class="button" value="Submit" onClick="return check();"> </CENTER>
</td>
</tr>
<tr>
<td>
</form>
</table>
<%
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connection = DriverManager.getConnection("jdbc:odbc:1st_login");
Statement statement = connection.createStatement();
String query = "SELECT username, password FROM 1st_login WHERE username='";
query += request.getParameter("username") + "' AND password='";
query += request.getParameter("password") + "';";
ResultSet resSum = statement.executeQuery(query);
//change: you gotta move the pointer to the first row of the result set.
resSum.next();
if (request.getParameter("username").equalsIgnoreCase(resSum.getString("username")) && request.getParameter("password").equalsIgnoreCase(resSum.getString("password")))
%>
//now it must connected to next page..
<%
else
%>
<h2>You better check your username and password!</h2>
<%
}catch (SQLException ex ){
System.err.println( ex);
}catch (Exception er){
er.printStackTrace();
%>
<input type="hidden" name="op2" value="login" />
<input type="hidden" name="lang" value="english" />
<input type="hidden" name="return" value="/" />
<input type="hidden" name="message" value="0" />
<br>
<br><br>
<br><br>
<br><br><br><br><br>
<font size="2" face="arial" color="#993300">
<p align="center"> <B>ABC © PQR</B>
</BODY>
</HTML>
and in this code i am getting following error
C:\Project\SRS\build\generated\src\org\apache\jsp\loginjsp.java:93: cannot find symbol_
C:\Project\SRS\build\generated\src\org\apache\jsp\loginjsp.java:93: cannot find symbol_
C:\Project\SRS\build\generated\src\org\apache\jsp\loginjsp.java:94: cannot find symbol_
C:\Project\SRS\build\generated\src\org\apache\jsp\loginjsp.java:95: cannot find symbol_
4 errors
C:\Project\SRS\nbproject\build-impl.xml:360: The following error occurred while executing this line:
C:\Project\SRS\nbproject\build-impl.xml:142: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 6 seconds)As long as you're unable to compile Java code, please use the 'New to Java' forum. This is really trival.
To ease writing, debugging and maintenance, I highly recommend you to write Java code in Java classes rather than JSP files. Start learning Servlets. -
Shutdown class; unable to access EJBs/JDBC
I have a fundamental question here, and for which I have not found any documentation
on BEA's own documentation center.
Can I, or can I not invoke operations on EJBs/JDBC/JNDI etc from my implementation
of weblogic.common.T3ShutdownDef??
Startup classes can in general access all resources, and they can also invoke
services on EJBs if LoadBeforeAppDeployments is false (the default) in config.xml.
However, the same does not seem to be true for shutdown classes. I am unable to
access services from a shutdown class.
As soon as I invoke weblogic.Admin with SHUTDOWN as the command, the server transitions
to STANDBY state and then the shutdown class is invoked.
The session bean is found and available, but when a transaction is sought to be
created to execute a finder on an EntityBean within the SessionBean, I get an
exception that transactions cannot be created in the Standby state of the server.
To get around this, I thought I will get a reference to the DataSource from JNDI
and execute a query on the JDBC connection, and that failed as well, saying that
JDBC connections are also not available.
Am I doing something wrong here? Or is this a bug.
I am developing on WLS 7.0.
Thanks!
Vivek.quote:
Please help me understand why. I have the easeToLoc setup to
received input variables:
The syntax of ActionScript dictates that you refer to the
callback function in the way that I pointed out. The only argument
that is passed to that listener function is an event object. This
is what it expects, nothing more. Take a look at the
docs
for more info, specifically the categories under Programming
ActionScript 3.0 -> Handling Events.
Looking at navPanelClose() and navPanelOpen(), the values
you're trying to pass seem more like constants to me, not
variables. So why not declare them as constants within this class
and refer to them as such within easeToLoc()? If you truly want to
use variables, perhaps creating a separate utility class to handle
this logic will work better.
When trying to access a method within one class from another
...let's say you want to access myMethod() within class MyAClass
from class MyBClass. You could:
1. Declare myMethod() as static and then refer to it from
anywhere after importing MyAClass. So you can call
MyAClass.myMethod() without having to instantiate MyAClass. This is
what you're trying to do here, I think.
2. Have class MyBClass extend MyAClass where myMethod() is
public or protected and MyBClass is in the same package as MyAClass
when it's declared as protected. For this to work you'd have to
instantiate MyBClass.
TS -
I am unable to access information from the internet as I am unable to install the lastest adobe flash player that is now required. Can you please help?
I fould a hack that makes the sites think you have the latest (Intel) version of Flash installed. So I installed it & it works with Firefox, TenFourFox & Safari. Here's the info.
Download this http://www.steelbin.com/FPforFBPPC.zip to your desktop, unzip it, and replace the current Flash Player plug-in which is in your main/Library/Internet Plug-Ins folder, (not the user Library). Save the old one just in case this one doesn't work.
Cheers, Tom -
I am from India using my iphone4 with Vodafone and firmware version 5.0.1(9A405). I am unable to access 3G from my device as the CELLULAR DATA NETWORK option in the settings is missing. Any methods or options for fixing the same????
I am from India using my iphone4 with Vodafone and firmware version 5.0.1(9A405). I am unable to access 3G from my device as the CELLULAR DATA NETWORK option in the settings is missing. Any methods or options for fixing the same????
-
HT4623 unable to access itunes from ipad
I am unable to access itunes from remote devices which include my ipad and iphone. When I try to purchase apps etc, I am advised "Cannot connect to itunes Store"
Hello marie-louise,
I recommend taking a look at this section of the article Can't connect to the iTunes Store found here http://support.apple.com/kb/ts1368.
Troubleshooting on an iPhone, iPad, or iPod touch
If you haven't been able to connect to the iTunes Store:
Make sure that your iOS software is up to date by connecting your iOS device to iTunes and clicking on Check for Update in your device's Summary page in iTunes.
Check and verify that you are in range of a Wi-Fi router or base station. If you are on a 3G capable device, make sure that cellular data is turned on from Settings > General > Cellular.
Note: If connected to 3G, larger items may not download. You may need to connect to Wi-Fi to download apps, videos, and podcasts.
Check to make sure you have an active internet connection. You can check the User Guide for your device for help with connecting to the internet.
Check to make sure other devices (portable computers, for example) are able to connect to the Wi-Fi network and access the internet.
Try resetting (turning off and then on again) your Wi-Fi router
If the issue persists, see troubleshooting Wi-Fi networks and connections.
Note: All iPhone, and iPod touch models support 802.11b/g Wi-Fi networks. In addition, iPhone 4, and iPod touch (4th generation) support 802.11n Wi-Fi networks (2.4 GHz only).
And if that does not resolve the issue take a look at this article:
iTunes: Advanced iTunes Store troubleshooting
http://support.apple.com/kb/ts3297
All the very best,
Sterling -
Hi everyone,
I deployed my EJB component in an Oracle 8.1.7 database and I try to access it from a servlet.
If I run my servlet from JDeveloper 3.2 (Web-to-Go), it all works fine. If I run my servlet from JRun 3.01 or from Tomcat 3.2.1, I get the following exception:
javax.naming.NoInitialContextException: Need to specify class name in environmen
t or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.fillInStackTrace(Compiled Code)
at java.lang.Throwable.<init>(Compiled Code)
at java.lang.Exception.<init>(Compiled Code)
at javax.naming.NamingException.<init>(NamingException.java:104)
at javax.naming.NoInitialContextException.<init>(NoInitialContextException.java:58)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:649)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:242)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:279)
at javax.naming.InitialContext.lookup(InitialContext.java:349)
at com.cognicase.framework.base.U0003.AbstractORB.getBean(AbstractORB.java:285)
at com.cognicase.framework.base.U0003.AbstractORB.getBean(Compiled Code)
at com.cognicase.demo.U2007BL.U2007WP_Users.lookupBean(U2007WP_Users.java:60)
at com.cognicase.framework.is.U0103.AbstractBeanWrapper.beforeBeanCall(AbstractBeanWrapper.java:121)
at com.cognicase.demo.U2007BL.U2007WP_Users.valideUser(U2007WP_Users.java:77)
at com.cognicase.demo.U2000WB.U2000MW_WorkSpace.CallEjb(Compiled Code)
at com.cognicase.demo.U2000WB.U2000MW_WorkSpace.doValidateLogin(Compiled Code)
at com.cognicase.demo.U2000WB.U2000MW_WorkSpace.processService(U2000MW_WorkSpace.java:98)
at Demo_0100_01.service(Demo_0100_01.java:128)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Compiled Code)
at org.apache.tomcat.core.ServletWrapper.service(Compiled Code)
at org.apache.tomcat.core.ContextManager.internalService(Compiled Code)
at org.apache.tomcat.core.ContextManager.service(Compiled Code)
at org.apache.tomcat.service.connector.Ajp13ConnectionHandler.processConnection(Compiled Code)
at org.apache.tomcat.service.TcpWorkerThread.runIt(Compiled Code)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(Compiled Code)
at java.lang.Thread.run(Compiled Code)
If I add my servlet classes, aurora_client.jar, mts.jar, vbjapp.jar and vbjorb.jar files to the CLASSPATH, it works fine.
The behavior is the same in JRun and Tomcat.
I don't like this solution since I have to make the CLASSPATH point to my application classes at the web server level instead of at the application context level.
Has anyone been able to solve this problem?
Thanks for your help.
nullYes, I did. Actually, if I run my servlet in JDeveloper (Web-to-Go), it all works fine. I also extracted the code that calls the EJB from the servlet and I tested it in a small Java application, and it also works fine.
Things stop to work when I deploy my servlet in JRun or in Tomcat.
It appears that my code is correct, but the environment I try to run it is not, and I can't figure out what's wrong.
Can anyone help me?
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Sandeep Desai ([email protected]):
Have you provided the environmental settings in the servlet.
It should be :
import oracle.aurora.jndi.sess_iiop.ServiceCtx;
env.put(Context.URL_PKG_PREFIXES, "oracle.aurora.jndi");
env.put(Context.SECURITY_PRINCIPAL, username);
env.put(Context.SECURITY_CREDENTIALS, password);
env.put(Context.SECURITY_AUTHENTICATION, ServiceCtx.NON_SSL_LOGIN);
InitialContext ctx = new InitialContext(env);
Object obj = ctx.lookup("test/EJBHome");
HomeObject home = PortableRemoteObject.narrow(
obj,"HomeObject.class");
RemoteObject remote = home.create();
This should make it work!!
<HR></BLOCKQUOTE>
null -
Very Urgent !!! Exception in looking up Local EJB from Servlet in WSAD 5.1
Hi,
I have a servlet and a local EJB. The servlet and EJB are deployed on same application server but in different J2EE applications i.e. different EAR files.
When I lookup an EJB with remote interfaces from servlet everything works fine. But when I try to lookup EJB with local interfaces from
Servlet I get following Exception.
Exception Stack: -
========================================================
avax.naming.NameNotFoundException: Context: localhost/nodes/localhost/servers/server1, name: TestLocalHome: First component in name TestLocalHome not found. Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
[12/8/05 14:14:05:047 IST] 7debf35b SystemErr R at com.ibm.ws.naming.ipcos.WsnOptimizedNamingImpl.do_resolve_complete_info(WsnOptimizedNamingImpl.java:968)
[12/8/05 14:14:05:047 IST] 7debf35b SystemErr R at com.ibm.ws.naming.cosbase.WsnOptimizedNamingImplBase.resolve_complete_info(WsnOptimizedNamingImplBase.java:1399)
[12/8/05 14:14:05:047 IST] 7debf35b SystemErr R at com.ibm.WsnOptimizedNaming._NamingContextStub.resolve_complete_info(Unknown Source)
[12/8/05 14:14:05:047 IST] 7debf35b SystemErr R at com.ibm.ws.naming.jndicos.CNContextImpl.cosResolve(CNContextImpl.java:3491)
[12/8/05 14:14:05:047 IST] 7debf35b SystemErr R at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1519)
[12/8/05 14:14:05:047 IST] 7debf35b SystemErr R at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1480)
[12/8/05 14:14:05:047 IST] 7debf35b SystemErr R at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt(CNContextImpl.java:1187)
[12/8/05 14:14:05:047 IST] 7debf35b SystemErr R at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1067)
[12/8/05 14:14:05:047 IST] 7debf35b SystemErr R at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:132)
[12/8/05 14:14:05:047 IST] 7debf35b SystemErr R at javax.naming.InitialContext.lookup(InitialContext.java:360)
[12/8/05 14:14:05:047 IST] 7debf35b SystemErr R at org.apache.jsp._DomainClient._jspService(_DomainClient.java:95)
[12/8/05 14:14:05:047 IST] 7debf35b SystemErr R at com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java:89)
[12/8/05 14:14:05:047 IST] 7debf35b SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[12/8/05 14:14:05:047 IST] 7debf35b SystemErr R at com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:344)
[12/8/05 14:14:05:047 IST] 7debf35b SystemErr R at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.serviceJspFile(JspServlet.java:669)
[12/8/05 14:14:05:047 IST] 7debf35b SystemErr R at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.service(JspServlet.java:767)
[12/8/05 14:14:05:047 IST] 7debf35b SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[12/8/05 14:14:05:047 IST] 7debf35b SystemErr R at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
[12/8/05 14:14:05:047 IST] 7debf35b SystemErr R at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
[12/8/05 14:14:05:047 IST] 7debf35b SystemErr R at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
[12/8/05 14:14:05:047 IST] 7debf35b SystemErr R at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
[12/8/05 14:14:05:047 IST] 7debf35b SystemErr R at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
[12/8/05 14:14:05:047 IST] 7debf35b SystemErr R at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
[12/8/05 14:14:05:047 IST] 7debf35b SystemErr R at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
[12/8/05 14:14:05:047 IST] 7debf35b SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:983)
[12/8/05 14:14:05:047 IST] 7debf35b SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:564)
[12/8/05 14:14:05:062 IST] 7debf35b SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
[12/8/05 14:14:05:062 IST] 7debf35b SystemErr R at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
[12/8/05 14:14:05:062 IST] 7debf35b SystemErr R at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
[12/8/05 14:14:05:062 IST] 7debf35b SystemErr R at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
[12/8/05 14:14:05:062 IST] 7debf35b SystemErr R at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
[12/8/05 14:14:05:062 IST] 7debf35b SystemErr R at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
[12/8/05 14:14:05:062 IST] 7debf35b SystemErr R at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
[12/8/05 14:14:05:062 IST] 7debf35b SystemErr R at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
[12/8/05 14:14:05:062 IST] 7debf35b SystemErr R at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:439)
[12/8/05 14:14:05:062 IST] 7debf35b SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)
========================================================
Please help asap.
Regds
VJ.The ejb spec only defines local ejb access within the same application. It's possible some app servers support access from a different application but it wouldn't be portable, nor would it work within the J2EE SDK or Sun Java System App Servers. To access a local ejb from a web component or ejb , define an ejb-local-ref in the client component's standard .xml file (web.xml or ejb-jar.xml) and use the ejb-link element to specify the ejb-name of the target ejb.
--ken -
Security exception while trying to access EJB from stand alone client
Hi!, I am trying a sample EJB application to R&D some security related issues. I want to access EJB through a web application as well as a stand-alone client. I have set approriate <method-permission> in EJB deployment descriptor. I am using users.properties/roles.properties file for authentication mechanism. I am using JBoss 3.2.
- On the web application side I am using BASIC authentication and the servlet is able to access the EJB OK, as long as I am using a login/password that has access to the EJB.
- Now I am trying to access the EJB using a stand alone Java class. These are the things I have tried till now:
=>Created a InitialContext with appropriate principal, credentials and tried getting a reference to EJB home interface. That resulted in security exception.
=>Logged into a LoginContext by using appropriate JBossSX classes and then tried getting a EJB home interface. Again security exception.
Now I am not sure what to do. I read at some places about client side container but not sure what that is. Does anyone has any ideas to try? Is there any other way I can make a swing application and a web application authenticate to EJB container?
Also can anyone point me to any documentation that gives some idea about how the security credentials gets propagated from web application/standalone client to EJB container?It would be better if you can post your code...and DD that way we can help you better
-
Unable to access Internet from LAN - Cisco ASA 9.1(2)
Hi,
I have Cisco 5515 IOS 9.1(2). I had configured out-to-in rule with 'ssh' and able to access the Internet server, but the same server is unable to access the Internet. Not sure what i am missing here. Please look in to the configuration below and suggest.
10.4.20.2 is the host i am trying to access the Internet and it fails, but able to 'ssh' to this IP from the internet.
ASA Version 9.1(2)
interface GigabitEthernet0/0
description OUTSIDE
nameif outside
security-level 0
ip address 1.1.1.1 255.255.255.248
interface GigabitEthernet0/1
description BACKUP
nameif backup
security-level 0
ip address 2.2.2.2 255.255.255.248
interface GigabitEthernet0/4
description INSIDE
nameif inside
security-level 100
ip address 10.4.20.1 255.255.255.0
boot system disk0:/asa912-smp-k8.bin
ftp mode passive
clock timezone PT -8
clock summer-time PT recurring
dns domain-lookup outside
object network 2.2.2.4_10.4.20.2
host 10.4.20.2
access-list out2in extended permit icmp any any inactive
access-list in2out extended permit ip 10.4.20.0 255.255.255.0 any
access-list out2in_bkp extended permit icmp any any inactive
access-list out2in_bkp extended permit tcp any object 2.2.2.4_10.4.20.2 eq ssh
pager lines 24
logging enable
logging timestamp
logging standby
logging monitor debugging
logging trap debugging
logging history debugging
logging asdm debugging
mtu outside 1500
mtu backup 1500
mtu inside 1500
mtu management 1500
no failover
icmp unreachable rate-limit 1 burst-size 1
asdm image disk0:/asdm-713.bin
asdm history enable
arp timeout 14400
no arp permit-nonconnected
object network 2.2.2.4_10.4.20.2
nat (inside,backup) static 2.2.2.4 net-to-net dns
access-group out2in in interface outside
access-group out2in_bkp in interface backup
access-group in2out in interface inside
route outside 0.0.0.0 0.0.0.0 1.1.1.2 10 track 100
route backup 0.0.0.0 0.0.0.0 2.2.2.3 20 track 101
timeout xlate 3:00:00
timeout pat-xlate 0:00:30
timeout conn 1:00:00 half-closed 0:10:00 udp 0:02:00 icmp 0:00:02
timeout sunrpc 0:10:00 h323 0:05:00 h225 1:00:00 mgcp 0:05:00 mgcp-pat 0:05:00
timeout sip 0:30:00 sip_media 0:02:00 sip-invite 0:03:00 sip-disconnect 0:02:00
timeout sip-provisional-media 0:02:00 uauth 0:05:00 absolute
timeout tcp-proxy-reassembly 0:01:00
timeout floating-conn 0:00:00
dynamic-access-policy-record DfltAccessPolicy
user-identity default-domain LOCAL
aaa authentication ssh console LOCAL
aaa authentication http console LOCAL
http server enable
http 192.168.1.0 255.255.255.0 management
http 0.0.0.0 0.0.0.0 outside
http 0.0.0.0 0.0.0.0 backup
no snmp-server location
no snmp-server contact
snmp-server enable traps snmp authentication linkup linkdown coldstart warmstart
sla monitor 100
type echo protocol ipIcmpEcho 8.8.8.8 interface outside
sla monitor schedule 100 life forever start-time now
sla monitor 101
type echo protocol ipIcmpEcho 8.8.4.4 interface backup
sla monitor schedule 101 life forever start-time now
service resetoutside
crypto ipsec security-association pmtu-aging infinite
crypto ca trustpool policy
track 100 rtr 100 reachability
track 101 rtr 101 reachability
telnet timeout 5
ssh 0.0.0.0 0.0.0.0 outside
ssh 0.0.0.0 0.0.0.0 backup
ssh timeout 60
ssh version 2
ssh key-exchange group dh-group1-sha1
console timeout 0
dhcpd address 192.168.1.2-192.168.1.254 management
dhcpd enable management
threat-detection basic-threat
threat-detection statistics access-list
no threat-detection statistics tcp-intercept
ntp server 123.108.225.6 source outside
ssl encryption rc4-sha1 aes128-sha1 aes256-sha1 3des-sha1
username xyz password ***** encrypted privilege 15
class-map inspection_default
match default-inspection-traffic
policy-map type inspect dns preset_dns_map
parameters
message-length maximum client auto
message-length maximum 512
policy-map global_policy
class inspection_default
inspect dns preset_dns_map
inspect ftp
inspect h323 h225
inspect h323 ras
inspect rsh
inspect rtsp
inspect esmtp
inspect sqlnet
inspect skinny
inspect sunrpc
inspect xdmcp
inspect sip
inspect netbios
inspect tftp
inspect ip-options
service-policy global_policy global
prompt hostname context
no call-home reporting anonymous
Cryptochecksum:9b63e3cfc9f98800d2bb3efa34c75906
: endHi Anand
Could you please do a packet tracer on the Asa?
Packet-tracer input inside icmp 10.20.4.2 8 0 4.2.2.2 detailed
Are you able to ping 4.2.2.2 from the server ?
Please use the following command
"fixup protocol icmp"
And then check whether you are able to ping the Internet.
Regards
Aditya -
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.
Maybe you are looking for
-
How to block opening a file for security purposes
There is a chance my MacBook may need repairs for case issues. I have some personal information on my computer that I want to protect from prying eyes. How would I do this? Thank you!
-
Global Warranty Valid In India Or Not???
I had bought my iPhone 5s from US around 3-4 months ago n there is some the problem in charging slot .Will my phone covers warranty in India or should i wait as i am going back in next 2-3 months???
-
"Allow Insecure Authentication" not visible on SMTP preferences
Good morning, The "Allow Insecure Authentication" checkbox is not visible on SMTP preferences on my sister's MacBook Pro running the latest version of Yosemite. I've found similar problem on a couple of Mac minis I have at the office. However, my Mac
-
How to hide mandatory field in OAF page through personalization
Hi, Could u please help, that how to hide mandatory field in seeded page. This could be achieved through personalization only. Thanks, Ramachandra. Edited by: 927747 on Jun 21, 2012 2:16 AM
-
MODERATOR: The thread has been LOCKED. Please do not share email addresses or requests for copyrighted or confidential material. hi guys, pls suggest me,one company co in india and when implement in us, pls send configuration steps or side. thanks