Access ApplicationBean from servlet

My project uses both JSF generated pages as well as servlets. I would like to be able to access an Application Bean from a servlet in the same project. The java files for the servlet are in the same directory as the package that holds the generated java page files. The Application bean should be accessible to both the generated classes as well as the servlets. Can anyone suggest how to set this up?

Hi Jim,
I am not sure I understand completely the problem you are facing, but I shall try to answer to the best of my knowledge and from what I have understood.
Since the JSF generated pages and the servlets are in the same folder all you would require to do is create an instance of the application bean and it should be accessible.
Hope this is what you were looking for.
Cheers
Giri :-)
Creator Team

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

  • How to run a MS Access Query from Servlet

    Is there a way to execute an MS Access query from a servlet. I have a query that is doing an INSERT into the database. I tried to code the servlet to directly do the query itself, but it keeps locking the database and hanging. I would appreciate any help.
    Thanks,
    Justin
    [email protected]

    r u refering to the query saved inthe MSACCESS, if so then it may not be possible, bcoz it is not a pure RDBMS. otherwise the u can do it as inthe above mention thread.

  • Access Datasource from Servlet Engine (Tomcat)

    Hi,
    I'm using datasource connections in my beans and event in servlets.. It works fine in JRun 3.1 environment.
    But when I port to J2EE1.3 its throwing this exception...
    I just want to understand whether it is a limitation in J2EE1.3 & Tomcat environment or it is a security problem or do I have to change any configuration file so that I can make the datasource connection available outside the J2EE environment.
    java.lang.IllegalArgumentException: Unknown component type      at com.sun.enterprise.naming.NamingManagerImpl.getComponentType(NamingManagerImpl.java:670)      at com.sun.enterprise.naming.NamingManagerImpl.getMangledIdName(NamingManagerImpl.java:708)      at com.sun.enterprise.naming.NamingManagerImpl.getComponentIdInternal(NamingManagerImpl.java:680)      at com.sun.enterprise.naming.NamingManagerImpl.getComponentId(NamingManagerImpl.java:313)      at com.sun.enterprise.naming.java.javaURLContext.getComponentContext(javaURLContext.java:397)      at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:51)      at javax.naming.InitialContext.lookup(InitialContext.java:350)      at com.camilion.env.ejb.EjbEnvironment.getJDBCConnection(EjbEnvironment.java:105)      at com.camilion.report.servlet.ReportServlet.service(ReportServlet.java:49)      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)      at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:428)      at org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:180)      at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)      at org.apache.catalina.core.ApplicationFilterChain.access$0(ApplicationFilterChain.java:197)      at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:176)      at java.security.AccessController.doPrivileged(Native Method)      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:172)      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:215)      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)      at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)      at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2314)      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)      at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:368)      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163)      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)      at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:995)      at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1088)      at java.lang.Thread.run(Thread.java:484)

    I'm getting the same problem trying to lookup a datasource from a JSP with J2EE 1.3 reference implementation.

  • 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("&lt;p&gt;The %s bean has been hit: %s times&lt;/p&gt;", 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-

  • Access files from servlet

    hi
    how can i access a local text file using a servlet.

    Presumably by "local" you mean a file on the server where the servlet is running? If so, you do what you would normally do in a Java program to access a local file. If by "local" you mean a file on some other system, which would be a bizarre meaning of the word, then the rules are the same as for any other Java program: that other system has to have a server running, and your servlet has to access it via that server.

  • 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-

  • Accessing db from servlet

    Hi,
    I have a college project and am facing some problems. I have a CONTROLLER CLASS holding all the logic, a SERVLET and a JSP page for showing errors. The prob is that I cant call a certain method from the servlet.. Here is the method I want to call from the servlet. And the problem area in the servlet is marked bold and in italics, except these two things, everything is working fine. PLEASE HELP
    *******************part of participantDAO class*******************
    public boolean updateParticipantTime (String tfNumber, String tfTime) throws Exception
    Connection dbConnection;
    Statement statement;
    ResultSet resultSet;
    String sqlText="";
    boolean update = false;
    Vector <Participant> myVector = new Vector <Participant>();
    Participant participant;
    if (jdbcDriverLoaded == false)
    loadDriver();
    try
    dbConnection = DriverManager.getConnection (connectionString) ;
    statement = dbConnection.createStatement () ;
    int number = Integer.parseInt(tfNumber.trim());
    if(tfTime.equals("") || tfTime == null)
    sqlText = "UPDATE participant SET finishingTime = NULL WHERE number = " + number ;
    System.out.println (sqlText) ;
    statement.executeUpdate (sqlText) ;
    sqlText = "n/a" ;
    statement.close () ;
    dbConnection.close () ;
    update = true;
    else
    sqlText = "UPDATE participant SET finishingTime = " tfTime.trim()"WHERE number = "+ number ;
    System.out.println (sqlText) ;
    statement.executeUpdate(sqlText) ;
    sqlText = "n/a" ;
    statement.close () ;
    dbConnection.close () ;
    update = true;
    catch (SQLException sqle)
    printSQLException (sqle, sqlText) ;
    throw sqle ;
    return(update);
    *********************SERVLET**************************
    import javax.servlet.* ;
    import javax.servlet.http.* ;
    import java.io.* ;
    import Participant_package.*;
    import java.lang.*;
    public class UpdateTimeServlet extends HttpServlet
    public boolean updateTime = false;
    ParticipantDAO participantDAO = new ParticipantDAO();
    int intNum;
    * @param request <code>HttpServletRequest</code>
    * @param response <code>HttpServletResponse</code>
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException
    doPost(request, response);
    * @param request <code>HttpServletRequest</code>
    * @param response <code>HttpServletResponse</code>
    public void doPost (HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException
    try
    HttpSession session = request.getSession(true);
    String number = null;
    String time = null;
    String messageText = "";
    number = request.getParameter("tfNumber");
    time = request.getParameter("tfTime");
    if(number.equals(""))
    messageText="Please give participant number.";
    request.setAttribute("message", messageText);
    RequestDispatcher dispatcher = request.getRequestDispatcher("/jsp/UpdateTime.jsp");
    dispatcher.forward(request, response);
    else
    intNum = Integer.parseInt(number);
    if(participantDAO.existParticipant(number) == false)
    messageText="No such participant was found. Try again!";
    request.setAttribute("message", messageText);
    RequestDispatcher dispatcher = request.getRequestDispatcher("/jsp/UpdateTime.jsp");
    dispatcher.forward(request, response);
    else
    participantDAO.updateParticipantTime(number, time);+
    messageText="Update successful";+
    request.setAttribute("message", messageText);+
    RequestDispatcher dispatcher = request.getRequestDispatcher("/jsp/UpdateTime.jsp");+
    dispatcher.forward(request, response);        }+
    catch (Exception e)+
    +*{*+
    System.out.println ("********* TIME FORMAT ERROR *********") ;*+
    +*System.out.println ("An unexpected exception occurred:" + e) ;*+
    +*System.out.println("Try again once more!");*+
    +*nextPage("/jsp/UpdateTime.jsp", request, response);*+
    +*return; }*+
    * Forwards according to the URI argument
    * @param request <code>HttpServletRequest</code>
    * @param response <code>HttpServletResponse</code>
    * @param nextURL <code>String</code>
    private void nextPage (String nextURI, HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException
    request.getRequestDispatcher(nextURI).forward(request, response) ;
    **********************JSP PAGE***************************
    <%@ page import = "java.util.*" %>
    <?xml version = "1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns = "http://www.w3.org/1999/xhtml">
    <head>
    <link rel ="stylesheet" type="text/css" href="/atk84f/CSS/RaceStyle.css" />
    <title>
    Update participants finishing time
    </title>
    </head>
    <body>
    <img src ="/atk84f/images/running1.jpg" />
    <a href="http://validator.w3.org/check?uri=referer"><img
    src="http://www.w3.org/Icons/valid-xhtml11-blue"
    alt="Valid XHTML 1.1" height="31" width="88" /></a>
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <h2>Update finishing time</h2>
    <%
    String number = (String) request.getParameter("tfNumber");
    String time = (String) request.getParameter("tfTime");
    String messageText = (String)request.getAttribute ("message") ;
    if(number == null)
    number = "";
    if(time == null)
    time="";
    if(messageText == null)
    messageText = "";
    %>
    <!-- Show Form -->
    <form action ="/atk84f/servlet/UpdateTimeServlet" method="post">
    <br />
    <table>
    <tr>
    <td class="form">Participant Number: </td>
    <td class="form"><input type="text" name="tfNumber" value="<%=number%>" /></td>
    </tr>
    <tr class=""tr>
    <td class="form">Time (hh:mm:ss): </td>
    <td class="form"><input type="text" name="tfTime" value="<%=time%>" /></td>
    </tr>
    <tr class="tr">
    <td class="form"></td>
    <td class="form"><input type="submit" name="btSubmit" value="Update" /></td>
    </tr>
    </table>
    </form>
    <!-- Show Message -->
    <p><big><%= messageText %></big></p>
    <p><a href ="/atk84f/Race.html">Main page</a></p>
    <p><a href ="/atk84f/jsp/ParticipantList.jsp">List of the participants</a><p>
    </body>
    </html>

    Please do these things:
    - 1 use the [&#99;ode] tags to make your code readable
    - 2 tell use what actually happened, eg. show the error
    - 3 simplify the problem, make an SSCCE
    When that is done, we may be able to help.
    Without that, here's all I can say:
    I can't really tell from the pile of unformatted code what state the response is in, but if you are getting IllegalStateException, its because the response is no longer virgin and forwarding isn't permitted.

  • JDBC + SERVLET: inserting text data  to access file from Html form

    Hi everybody !
    I'm trying to insert text data from my html form to access database using servlet and jdbc technologies.
    The problem that I'm that the data is TEXT, but not the English language !!!
    So my access db file gets - ???????? symbols instead the real text.
    This is the form line that sending data to my servlet:
    <form
    method="POST"
    ACTION=http://localhost:8080/servlet/myServlet enctype="text/html">
    And this is servlet line that defines response content:
    res.setContentType( "text/html" );
    What can I do to get in access db file the right text format and not a ???????? symbols.
    Maybe I must to ad some <meta ...> , but where ?

    You're dealing with Unicode, I'd guess, and not ASCII.
    I guess I'd have two questions:
    (1) Is the character encoding on your pages set properly for the language you're trying to use?
    (2) Does Access handle Unicode characters?
    Access isn't exacly a world-class database. (If it was, there'd be no reason for M$ to develop SQL Server.) I'd find out if it supports other character sets. If not, you'll have to switch to a more capable database that does. - MOD

  • Accessing EJBs from a servlet

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

    Yes, 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

  • Frame access from servlet not working

    Dear all,
    I am running my servlets on Tomcat 5.5 and using JDK 1.6. I have a small program that uses codecs to access frames from a video file. PreAccessCodec implements Codec interface and PostAccessCodec extends PreAccessCodec. I set the two codecs into the processor's codec chain. The program is implemented as a thread and once started grabs frames and stores the images in a certain interval. The problem is this: whenever I start the thread from a main program, everything runs without a glitch. However, when I put the code in init() method of the servlet, I get the following error message:
    The input format is not compatible with the given codec plugin: com.mapper.utils.PostAccessCodec@69d02b
    Failed to realize: com.sun.media.ProcessEngine@1478a43
      Cannot build a flow graph with the customized options:
        Unable to add customed codecs:
          com.mapper.utils.PreAccessCodec@15356d5
          com.mapper.utils.PostAccessCodec@69d02b
    Error: Unable to realize com.sun.media.ProcessEngine@1478a43 I am using netbeans 5.5.1 to deploy my servlets. I doubt that the problem is with classpaths because the servlet doesn't complain when I am using JMF's classes like Processor.
    I would really appreciate any help.
    Thank you.
    Message was edited by:
    calculemus

    The GE.iH() method should return false for
    a ..head-full ..en-headed, not headless
    environment, and I expect (from what you
    reported above) that will return false for both
    your servlet and application, and is apparently
    not the problem.It returned false when I tried GE, and it was not the problem as you suggested. However, I now noticed in the logs:
    java.awt.HeadlessException
    I use Netbeans for the development, and I tried using -Dheadless=true and -Dheadless=false, it did not change anything...
    I think it is time to check that assumption
    more carefully.
    My impression is that PreAccessCodec and
    it's 'Post' equivalent are mentioned a lot in JMF
    example code, but are custom classes,
    built to suit the use at the time. Did you write the
    Pre/PostAccessCodecs for this app.?Yes I customized them from the JMF sample codes. They are in the classpaths and are correctly read by the servlet. I did some logging and I actually saw that the code inside Pre/PostAccess was logging when my servlet was run.
    >
    So, what I am thinking, is that while the JMF
    based Processor class may well be on the
    server's
    classpath, perhaps Pre/PostAccessCodec classes
    are not.
    oes a jar appear in the WEB-INF/lib directory,
    that contains the Pre/PostAccessCodec.class?
    Failing that, are the classes themselves in
    WEB-INF/classes/(sub-dir according to package name)/ ?Nevertheless, just to double check I checked WEB-INF directory and the classes appear correctly in their appropriate 'package-folders'.
    I figured out where exactly the thread was not running. In my PostAccessCodec class, I had overloaded getSupportedInputFormats() function to return RGB format.
    public Format [] getSupportedInputFormats() {
    Format [] fomats = {new RGBFormat()};
    return fomrats;
    When I changed it to return {VideoFormat()}, the codec initializes, but I get nothing when I want to access the frame.
    I guess I will have to start another thread.
    @moderators, please move the post if it is inappropriate to put it in this thread, my apologies.
    The problem is still there and I am not able to get the frame access not working from the servlet. :(
    Message was edited by:
    calculemus
    Message was edited by:
    calculemus

  • [Fwd: Security problem accessing MBeanServer from a servlet]

    Reposting to Security and Servlet newsgroups.
    -------- Original Message --------
    Subject: Security problem accessing MBeanServer from a servlet
    Date: 10 Feb 2004 13:02:09 -0800
    From: Alain <[email protected]>
    Reply-To: Alain <[email protected]>
    Organization: BEA NEWS SITE
    Newsgroups: weblogic.developer.interest.management
    Hi,
    I am trying to understand how WLS 7.0 secures a call to an MBean. Got
    the following
    scenario:
    - I am in a servlet context
    - I have created and registered an MBean with the WLS MBeanServer. Fine
    so far
    - Within the same call I can retrieve the MBean attributes. Fine so far
    - I keep the MBeanServer reference in an object global to the servlet
    context
    The problem:
    - When I do another request and try to use the cached MBeanServer
    instance to
    access the MBean, I get the following error:
    weblogic.management.NoAccessRuntimeException: Access not allowed for
    subject:
    principals=[], on ResourceType ...
    Any idea?
    Alain

    PaulF <paulf@reply_in_newsgroup.com> wrote:
    On 10 Feb 2004 13:02:09 -0800, Alain <[email protected]> wrote:
    Hi,
    I am trying to understand how WLS 7.0 secures a call to an MBean. Got
    the following
    scenario:
    - I am in a servlet context
    - I have created and registered an MBean with the WLS MBeanServer.Fine
    so far
    - Within the same call I can retrieve the MBean attributes. Fine sofar
    - I keep the MBeanServer reference in an object global to the servlet
    context
    The problem:
    - When I do another request and try to use the cached MBeanServer
    instance to
    access the MBean, I get the following error:
    weblogic.management.NoAccessRuntimeException: Access not allowed for
    subject:
    principals=[], on ResourceType ...
    Any idea?
    AlainWhat ResourceType are you trying to access. From the Exception you're
    trying to access it as an Anonymous user (principals=[]) and evidently
    you're attempting to access something that is protected. I can't tell
    what
    from the snippet you've included.
    Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
    Thanks Paul for your reply.
    You are right. I can access my custom MBeans if I am authenticated for example
    as an Administrator. My problem is that I want any application to access this
    MBean authenticated or not. I am trying to find how I could grant permission to
    this MBean to everyone. Still searching.
    Thanks.

  • Security problem accessing MBeanServer from a servlet

    Hi,
    I am trying to understand how WLS 7.0 secures a call to an MBean. Got the following
    scenario:
    - I am in a servlet context
    - I have created and registered an MBean with the WLS MBeanServer. Fine so far
    - Within the same call I can retrieve the MBean attributes. Fine so far
    - I keep the MBeanServer reference in an object global to the servlet context
    The problem:
    - When I do another request and try to use the cached MBeanServer instance to
    access the MBean, I get the following error:
    weblogic.management.NoAccessRuntimeException: Access not allowed for subject:
    principals=[], on ResourceType ...
    Any idea?
    Alain

    PaulF <paulf@reply_in_newsgroup.com> wrote:
    On 10 Feb 2004 13:02:09 -0800, Alain <[email protected]> wrote:
    Hi,
    I am trying to understand how WLS 7.0 secures a call to an MBean. Got
    the following
    scenario:
    - I am in a servlet context
    - I have created and registered an MBean with the WLS MBeanServer.Fine
    so far
    - Within the same call I can retrieve the MBean attributes. Fine sofar
    - I keep the MBeanServer reference in an object global to the servlet
    context
    The problem:
    - When I do another request and try to use the cached MBeanServer
    instance to
    access the MBean, I get the following error:
    weblogic.management.NoAccessRuntimeException: Access not allowed for
    subject:
    principals=[], on ResourceType ...
    Any idea?
    AlainWhat ResourceType are you trying to access. From the Exception you're
    trying to access it as an Anonymous user (principals=[]) and evidently
    you're attempting to access something that is protected. I can't tell
    what
    from the snippet you've included.
    Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
    Thanks Paul for your reply.
    You are right. I can access my custom MBeans if I am authenticated for example
    as an Administrator. My problem is that I want any application to access this
    MBean authenticated or not. I am trying to find how I could grant permission to
    this MBean to everyone. Still searching.
    Thanks.

  • How to connect to MS Access from servlet uploaded in TOMCAT server

    Hi,
    I want to access MS Access from servlet .I use TOMCAT server.I want to know what should i do.How to get drivers and how to set class path for them.
    Please help me in finding the solution
    thanks and Regards

    HI,
    try this
    <Code>
    response.setContentType(CONTENT_TYPE);
         PrintWriter out = response.getWriter();
         java.sql.DatabaseMetaData dm = null;
         java.sql.ResultSet rs = null;
         try
              Class.forName("sun,jdbc.odbc.JdbcOdbcDriver");
              Connection con = java.sql.DriverManager.getConnection("jdbc:odbc:dsnName","","");
              dm = con.getMetaData();
              out.println("<html>");
              out.println("<head><title>Servlet1</title></head>");
              out.println("<body bgcolor=\"lightblue\">");
              if(con!=null){
                   dm = con.getMetaData();
                   out.println("<B><br>Driver Information</B>");
                   out.println("\n\t<br><br>Driver Name: "+ dm.getDriverName());
                   out.println("\n\t<br>Driver Version: "+ dm.getDriverVersion ());
                   out.println("\n\t<br>Database Information ");
                   out.println("\n\t<br>Database Name: "+ dm.getDatabaseProductName());
                   out.println("\n\t<br>Database Version: "+ dm.getDatabaseProductVersion());
                   out.println("\n\t<br><br>Avalilable Catalogs ");
                   rs = dm.getCatalogs();
                   while(rs.next()){
                             out.println("<br>\tcatalog: "+ rs.getString(1));
                   out.println("\n\t<br><br>conURL =" + conURL);
                   out.println("\n\t<br><br>Title = Database");
                   rs.close();
                   rs = null;
                   con.close();
              }else {
                   out.println("Error: No active Connection");
         }catch(ClassNotFoundException e) {
              out.println("Coudn't laod the database driver: " + e.getMessage());
         } catch(SQLException e) {     
              out.println("SQLException caught: " + e.getMessage());
              try {
                   if (con != null)
                        con.close();
                   if (rs != null)
                        rs.close();
              catch (SQLException ignored) {}
              finally {
                   try {
                             if (con != null)
                                  con.close();
                             if (rs != null)
                                  rs.close();
                        catch (SQLException ignored) {}
    </Code>
    Sachin

  • Access of JSF Beans from Servlet Filter

    Is there any way how can I access session JSF beans from servlet filter?
    I need to check certain value of JSF bean stored in session scope in my filter.
    Thanks
    ferdo

    Frank,
    I am not sure about phase listener, this is the whole situation:
    as I am not using Container Managed Security with my JSF, after I do sucessfull login into application, I need to store some information into the session scope (user etc) and in the servlet filter I need to find out if the user is connected.
    I was trying to put such info into Servlet Session directly in my bean via External Context and reading the info in Filter.
    This is working fine when my application is running locally (jdev oc4j) but once deployed into Application server, when user login first time, user information is somehow removed from the session, and cannot figure out why.
    So I was thinking to try another approach, to find out from servlet filter if JSF bean value is set or not.
    Any other suggestions? Do not want to swicth to Container Manages Security now.
    ferdo
    null

Maybe you are looking for

  • How can I return to Win 8.1 from Win 10

    I've updated to Windows 10 TP from win 8.1 few weeks ago, but I didn't backup anything. I find win 10 slow at startup. I want to return to windows 8.1, I've tried using Win 8.1 ISO file but Windows says "Windows 8.1 setup has failed". Is there any an

  • Scenarios on PI 7.4

    hi All, If anyone worked on PI 7.4 swing tool , i need end-end scenario in PI 7.4 ,i  can see the ESR objects similar but struggling in configuring the ID objects.especially the ICO when i am trying to create new ico it is asking for communication co

  • Can't play video in iWeb

    I've created my site and compressed my video for iWeb in iMovie HD6. But for some reason, the video won't play when I visit the site. Any ideas? FYI, you can see the page here: http://web.mac.com/aubreysinger/iWeb/TheTrip/cinematique.html

  • Last software update cripples Motorola Razrs- why?

    We have two Motorola Razrs that since the last update, have been unresponsive, slow, and has issues texting, calling... you know, using your phone as a phone. Well, chatting with Verizon will get you nowhere, support was unresponsive and said 'sorry'

  • Iphone VoIP application development on Mac Mini

    Hello I am beginner for Mac. I plan to develop the voip application for iphone. Is it possible to develop on Mac mini(2GHz D & 1G RAM & 120G HD)? Thanks.