Loggin my web application

Hi!
I'm extending the org.apache.log4j.jdbc.JDBCAppender to log my web application directly in a database.
OK, this is my code:
package dbweb.logging;
import java.sql.*;
import javax.sql.*;
import java.util.*;
import javax.naming.*;
public class JDBCAppender extends org.apache.log4j.jdbc.JDBCAppender {
    private InitialContext context;
    private ResourceBundle webappconf;
    private String admindb;
    private DataSource datasource;
    public JDBCAppender() {
        super();
        try {
            context = new InitialContext();
            // Get ConnectionPool
            datasource = (DataSource) context.lookup("comp/env/jdbc/MyConnectionPool");
        } catch (javax.naming.NamingException nEx) {
            System.out.println(nEx.getExplanation());
    protected Connection getConnection() {
        try {
            connection = datasource.getConnection();
            connection.getAutoCommit();
            return connection;
        } catch (SQLException sqlEx) {
            System.out.println(sqlEx.getMessage());
            return null;
    protected void closeConnection(Connection con) {
        try {
            con.close();
        } catch (SQLException sqlEx) {
            System.out.println(sqlEx.getMessage());
    protected String getLogStatement(org.apache.log4j.spi.LoggingEvent event) {
        // MAKE STATEMENT
        return sqlStatement;
}When I try to get my web application ConnectionPool it seems that the JDBCAppender InitialContex isn't the web application one, in fact this command:
datasource = (DataSource) context.lookup("comp/env/jdbc/MyConnectionPool");returns null, therefore my web application crashes when I try to log a message. This is the error:
No object bound to name java comp/env/jdbc/MyConnectionPool
How can I do to get my web application Connection Pool???
Thanks in advance.
+ Anhur +

You must have the context stated in your server.xml and web.xml file. I don't know what server you are using, but you will have to consult the documentation to see where this goes. For example, in Tomcat 5.5 you would have to do the following:
1) Add the following to server.xml:
<GlobalNamingResources>
    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
    <Resource name="jdbc/MyConnectionPool"
                auth="Container"
                type="javax.sql.DataSource"
                driverClassName="your.driver.DBDriver"
                factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
                url="jdbc:driver:@your.dbserver.com:1200:dbname"
                username="user"
                password="pass"
                maxActive="20"
                maxIdle="10"
                maxWait="-1" />
...2) In context.xml
<ResourceLink global="jdbc/MyConnectionPool" name="jdbc/MyConnectionPool" type="javax.sql.DataSource"/>3) In yourapp/WEB-INF/web.xml:
        <resource-ref>
          <res-ref-name>jdbc/MyConnectionPool</res-ref-name>
          <res-type>javax.sql.DataSource</res-type>
          <res-auth>Container</res-auth>
     </resource-ref>

Similar Messages

  • IIS 7.5 URL Rewrite: Hit specific page of a web application but should be redirected to another application's page

    I have deployed 2 different web application on IIS 7.5 running on Windows Server 2008 R2 but on different port numbers i.e. one application deployed on port no. 1776 and another on 8091. I want to rewrite URL in such a way that if i hit any page of first
    application such as default.aspx then it will be redirected to particular page of another application along with some changes in url.
    Example: if i access any page from first application like:
    http://g2wv126rbsc:1776/sites/main/commercial/commercial-solutions/financing/default1.aspx
    then it should redirect to specific page of another application along with some changes in url:
    http://g2wv126rbsc:8091/main/commercial/commercial-solutions/financing/default2.aspx
    Note: In above mentioned url, also removed "sites".
    I tried to create a inbound rule through URL Rewrite module (installed on IIS 7.5) by selecting Action as "Rewrite" but didn't find any success.
    I need some examples if anyone has come across same kind of issue.
    Thanks in advance.

    Please post ASP.NET questions in the ASP.NET forums (http://forums.asp.net ).

  • Problems access to a web application (Web Interface or Web report)

    Hi,
    We found problems with the access to web application. Some users have problems with direct links to the web applications(Web Interface or Web reporting), when they click on the link an error message appears, the message displays the following text:
    "Cannot open file Bex?sap-language=ENbsplanguge=ENcmd=idoc_TE.."
    Clicking in details the message is "No Access to specified file"
    For this users the access to excel reporting is correct, the message appears when they click on the direct web links through the browser or directly in BW system, but if they type the URL they can access. Other users can use the direct web link without problems.
    I highly appreciate any help or idea about how to solve this issue.
    Thanks in advance.

    HI,
    please ask to your basis that check the language of every single user on su01 tx.
    This is the problem i think.
    Natalia.

  • How to configure request manager service for multiple website in one web application

    I have set up sp 2013 as below:
     web application : wa1
    site collection : sc1
    sp site: site1, site2
    I used 2 WFE, 1 APP, how can I use request manager service to control  site1 to wfe1, site2 to wfe2?
    Awen

    That's not what i'd describe as load balancing.
    A better description would be load-isolation. In your description then if the load on site1 was large (and growing) but site2 was quiet then site1 would struggle and eventually become unable to handle the number of users but site2 would still be ok. That's
    fine from a QOS point of view but it's not the norm for load balancing. It would work in simple scenarios but the out of the box load balancing tools are much better suited than that sort of approach.
    This article shows how to configure the RMS and may help show how your request is difficult to configure:
    http://www.harbar.net/articles/sp2013rm2.aspx

  • How can we remove javascript completly from J2EE based web application?

    java script produce lots of problem in web application i just want to remove them comletly

    rinku5259 wrote:
    java script produce lots of problem in web application i just want to remove them comletly3 easy steps
    1. using the mouse or keyboard, select the javascript code
    2. press the delete button on the keyboard
    3. save the file
    do that for each file that has JavaScript in it

  • Error while running web application through JDEV (10.1.3.0.3) in OC4J

    Error while running web application through JDEV (10.1.3.0.3) in OC4J.
    Here is the error message.
    07/10/02 14:45:28 Exception in thread "OC4J Launcher" oracle.classloader.util.AnnotatedNoClassDefFoundError:
         Missing class: javax.xml.bind.JAXBContext
         Dependent class: com.oracle.corba.ee.impl.orb.config.InternalSettingsORBConfigImpl
         Loader: oc4j:10.1.3
         Code-Source: /C:/jdev/j2ee/home/lib/oc4j-internal.jar
         Configuration: <code-source> in boot.xml in C:\jdev\j2ee\home\oc4j.jar
    The missing class is not available from any code-source or loader in the server.
    07/10/02 14:45:28      at oracle.classloader.PolicyClassLoader.handleClassNotFound (PolicyClassLoader.java:2073) [C:/jdev/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@7]
         at oracle.classloader.PolicyClassLoader.internalLoadClass (PolicyClassLoader.java:1681) [C:/jdev/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@7]
         at oracle.classloader.PolicyClassLoader.loadClass (PolicyClassLoader.java:1633) [C:/jdev/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@7]
         at oracle.classloader.PolicyClassLoader.loadClass (PolicyClassLoader.java:1618) [C:/jdev/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@7]
         at java.lang.ClassLoader.loadClassInternal (ClassLoader.java:319) [jre bootstrap, by jre.bootstrap]
         at com.oracle.corba.ee.impl.orb.config.InternalSettingsORBConfigImpl.init (InternalSettingsORBConfigImpl.java:46) [C:/jdev/j2ee/home/lib/oc4j-internal.jar (from <code-source> in boot.xml in C:\jdev\j2ee\home\oc4j.jar), by oc4j:10.1.3]
         at com.oracle.corba.ee.impl.orb.config.SunRIORBConfigImpl.init (SunRIORBConfigImpl.java:97) [C:/jdev/j2ee/home/lib/oc4j-internal.jar (from <code-source> in boot.xml in C:\jdev\j2ee\home\oc4j.jar), by oc4j:10.1.3]
         at com.oracle.iiop.server.IIOPServerExtensionProvider.configureOrb (IIOPServerExtensionProvider.java:26) [C:/jdev/j2ee/home/lib/oc4j-internal.jar (from <code-source> in boot.xml in C:\jdev\j2ee\home\oc4j.jar), by oc4j:10.1.3]
         at com.oracle.corba.ee.impl.orb.ORBServerExtensionProviderImpl.preInitApplicationServer (ORBServerExtensionProviderImpl.java:45) [C:/jdev/j2ee/home/lib/oc4j-internal.jar (from <code-source> in boot.xml in C:\jdev\j2ee\home\oc4j.jar), by oc4j:10.1.3]
         at com.evermind.server.ApplicationServer.serverExtensionPreInit (ApplicationServer.java:1031) [C:/jdev/j2ee/home/lib/oc4j-internal.jar (from <code-source> in boot.xml in C:\jdev\j2ee\home\oc4j.jar), by oc4j:10.1.3]
         at com.evermind.server.ApplicationServer.setConfig (ApplicationServer.java:861) [C:/jdev/j2ee/home/lib/oc4j-internal.jar (from <code-source> in boot.xml in C:\jdev\j2ee\home\oc4j.jar), by oc4j:10.1.3]
         at com.evermind.server.ApplicationServerLauncher.run (ApplicationServerLauncher.java:98) [C:/jdev/j2ee/home/lib/oc4j-internal.jar (from <code-source> in boot.xml in C:\jdev\j2ee\home\oc4j.jar), by oc4j:10.1.3]
         at java.lang.Thread.run (Thread.java:595) [jre bootstrap, by jre.bootstrap]

    Hi,
    The guide you were refering was pointing to 10.1.2 wizards.
    For the latest 10.1.3 tutorial, please follow the below tutorial link :
    http://www.oracle.com/technology/products/jdev/101/tutorials/WS/WSandAScontrol.htm
    Hope this helps,
    Sunil..

  • Error while web application deployment in NetBeans5.5

    Error while web application deployment in NetBeans5.5. I am always getting Tomcat deployment error. using Netbeans 5.5.1 with bundeld tomcat. But in some machines its working fine.
    regards
    jossy v jose

    What is the error message you see?
    Are there any stacktraces or other relevant messages in the ide log file? (The ide log file is [userdir]/var/log/messages.log. On userdir: http://blogs.sun.com/karthikr/entry/jse_directories)
    You can also check the server log file to see if there are more detailed messages.
    You can also try setting ant's verbose level to debug or verbose (Tools | Options | Miscellaneous | Ant | Verbosity Level) and check the output.

  • Error while deploying web application in OAS

    I was trying to deploy a web application in OAS through enterprise manager. But I get the following error. Can any one please help me.
    An error occurred when processing the data submitted. Find the appropriate field and enter the correct information as noted next to each field.
    Archive Location - Failed in uploading archive. Invalid archive file: Unsupported archive type. unknown

    As the error message tells, did you make sure you have a correct/valid archive file? You might try deploying it from command line to make sure issue isn't at EM side.
    For 10.1.3 refer:
    http://download.oracle.com/docs/cd/B32110_01/web.1013/b28951/overview.htm#CJAJHJIA
    For 10.1.2 refer:
    http://download.oracle.com/docs/cd/B14099_19/core.1012/b13997/cmds.htm#BEIJGHDG
    http://download.oracle.com/docs/cd/B14099_19/core.1012/b13997/cmds.htm#BEICHFGJ
    Thanks
    Shail

  • WEB.XML gives me an error while deploying a Web Application in Weblogic 5.1

    I have a Web.xml which I copied the one from their documentation and edited for my servlet specific data. When I try to deploy it I am getting the following error.
              Wed Nov 15 17:10:37 EST 2000:<E> <HTTP> Error reading Web application 'C:/tomcat
              /webapps/La/'
              java.net.UnknownHostException: java.sun.com
              Can you throw some light on this? I have included the first three lines from the WEB,XML file where weblogic is choking.
              <?xml version="1.0" encoding="UTF-8"?>
              <!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN'
              'http://java.sun.com/j2ee/dtds/webapp_2_2.dtd'>
              Thank You
              Trisula P. Siripurapu
              

              Hi Jacek,
              Thank you for your suggestion. I changed the Web App version to 1.2 instead of 2.2. It worked. Thanks once again for the timely response. I really do appreciate it.
              Trisula Pani Siripurapu.
              Jacek Laskowski <[email protected]> wrote:
              >"Trisula P. Siripurapu" wrote:
              >>
              >> I have a Web.xml which I copied the one from their documentation and edited for my servlet specific data. When I try to deploy it I am getting the following error.
              >> Wed Nov 15 17:10:37 EST 2000:<E> <HTTP> Error reading Web application 'C:/tomcat
              >> /webapps/La/'
              >> java.net.UnknownHostException: java.sun.com
              >
              >I remember having the same problem before I added the latest service
              >pack (SP 6). If you don't want to download it, just change DOCTYPE to
              >
              ><!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application
              >1.2//EN' 'http://java.sun.com/j2ee/dtds/webapp_2_2.dtd'>
              >
              >and it should work. Notice the change of Web Application version - 1.2
              >rather then 2.2. I'm (almost) sure, I saw one example - examples/webapp
              >(?) - with this header. Take a look at the accompanying examples.
              >
              >When you apply SP6, things should work as they suppose to.
              >
              >> Trisula P. Siripurapu
              >
              >Jacek Laskowski
              

  • Capture an image using the web camera from a web application

    Hi All,
    Could anyone please share the steps what have to be followed for capture an image using the web camera from a web application.
    I have a similar requirement like this,
    1) Detect the Webcam on the users machine from the web application.(To be more clear when the user clicks on 'Add Photo' tool from the web application)
    2) When the user confirms to save, save the Image in users machine at some temporary location with some unique file name.
    3) Upload the Image to the server from the temporary location.
    Please share the details like, what can be used and how it can be used etc...
    Thanks,
    Suman

    1) Detect the Webcam on the users machine from the web application.(To be more clear when the user clicks on 'Add Photo' tool from the web application)There's not really any good way to do this with JMF. You'd have to somehow create a JMF web-start application that will install the native JMF binaries, and then kick off the capture device scanning code from the application, and then scan through the list of devices found to get the MediaLocator of the web cam.
    2) When the user confirms to save, save the Image in users machine at some temporary location with some unique file name.You'd probably be displaying a "preview" window and then you'd just want to capture the image. There are a handful of ways you could capture the image, but it really depends on your situation.
    3) Upload the Image to the server from the temporary location.You can find out how to do this on google.
    All things told, this application is probably more suited to be a FMJ (Freedom for Media in Java) application than a JMF application. JMF relies on native code to capture from the web cams, whereas FMJ does not.
    Alternately, you might want to look into Adobe Flex for this particular application.

  • Unable to resolve JNDI DataSource in weblogic 12c When you upgrade web application

    I create a datasource which jndi name is jdbc/allianzB2CDataSource and the target is AdminServer ,and i deploy a web application in AdminServer.In that web application,the code(base on spring framework) is:
    public static DataSource getJndiDataSource(String name) {
      JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
      Properties jndiEnvironment = new Properties();
      jndiEnvironment.put("java.naming.factory.initial",
      "weblogic.jndi.WLInitialContextFactory");
      dsLookup.setJndiEnvironment(jndiEnvironment);
      try {
      dsLookup.setResourceRef(false);
      return dsLookup.getDataSource(name);
      } catch (Exception e) {
      dsLookup.setResourceRef(true);
      return dsLookup.getDataSource(name);
    And the parameter is jdbc/allianzB2CDataSource,everything work fine,but when i restart or upgrate the web application,i got the error like this:
    javax.naming.NameNotFoundException: Unable to resolve 'jdbc.allianzB2CDataSource'. Resolved 'jdbc'; remaining name 'allianzB2CDataSource'
    Unable to resolve 'jdbc.allianzB2CDataSource'. Resolved 'jdbc'; remaining name 'allianzB2CDataSource'

    I create a datasource which jndi name is jdbc/allianzB2CDataSource and the target is AdminServer ,and i deploy a web application in AdminServer.In that web application,the code(base on spring framework) is:
    public static DataSource getJndiDataSource(String name) {
      JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
      Properties jndiEnvironment = new Properties();
      jndiEnvironment.put("java.naming.factory.initial",
      "weblogic.jndi.WLInitialContextFactory");
      dsLookup.setJndiEnvironment(jndiEnvironment);
      try {
      dsLookup.setResourceRef(false);
      return dsLookup.getDataSource(name);
      } catch (Exception e) {
      dsLookup.setResourceRef(true);
      return dsLookup.getDataSource(name);
    And the parameter is jdbc/allianzB2CDataSource,everything work fine,but when i restart or upgrate the web application,i got the error like this:
    javax.naming.NameNotFoundException: Unable to resolve 'jdbc.allianzB2CDataSource'. Resolved 'jdbc'; remaining name 'allianzB2CDataSource'
    Unable to resolve 'jdbc.allianzB2CDataSource'. Resolved 'jdbc'; remaining name 'allianzB2CDataSource'

  • Help needed for Extending ISA Web applications

    Hi All,
    I am working on CRM 5.0. Need some kind of step by step guide to enhance standard Web applications. For example,
    Adding a new field. Changing the Layout etc.
    If some one has already done this kind of modifications, please share the same with me.
    It will be of immense  help to me
    Please mail the same to [email protected]
    Regards,
    Eureka.

    Hi,
    You need to get the development and extension guide.
    Have a look at this posting for details of how to find it.
    How to modify Webshop's layout, style and so on...
    Hope this helps,
    Gareth.

  • Downloaded fonts (MapInfo) are not getting displayed once assigned to drop down in my web application

    I am using mapinfo fonts in my web application and assigning these fonts to the dropdown boxes as below :
    ddlSymbol.Style.Add("font-family", "MapInfo Arrows");
    But it is not showing correct font. Same is working nice with IE or Chrome. Only FIrefox is giving problem. I am using Firefox 23.0.1.
    Thanks.

    Does it work if you use a stylesheet?
    Does the font show in Options > Content and work if you set this font as the default font?
    Any errors in the Web Console (Firefox/Tools > Web Developer;Ctrl+Shift+K)?

  • SSO to Web Application from Portal

    Hi,
        I am working on a scenario where I need to access a Web Application from the Portal.
        I read about the Application Integrator that is provided by the Portal .
        I wanted to know that can I only have SSO to those Web Application that accept the userid and password and as URL parameters using Application Integrator , ie: those applications that have post method cannot be integrated.
       Please help me out with clearing this doubt.
    Thnx,
    Pravesh Puria.

    Hi  Abdulbasit ,
        Please give me more details , we have a Lotes Notes Web application hosted on Domino server , another is J2EE based application. I need to achieve SSO to each of these applications from the SAP Portal.
       I followed the below listed steps:
       Created two systems one for each Web application based on the template generated from the application integrator. I entered the user mapping values for both the systems.
       I also created two IViews. When I preview , the logon page of the web application opens but the user credentials are not passed to the application.
       Please help me with the steps to achieve the SSO , from the reply I interpret that Logon ticket method was used to achieve the SSO and user mapping.
        My email id is : [email protected]
        It will be of immense help to me.
    Thnx,
    Pravesh Puria.

  • SSO to web application

    Hello all,
    Okay, I'm trying to accomplish SSO between EP5.0 and an existing web application and am having little luck.  Basically, the web app will be called in the portal and I need to somehow pass the web app the userid/pswd that is stored in a user mapping entry in the portal (userid is not the same as the portal userid).  In retrieving the usermapping info, the pswd is encoded (obviously for security reasons).  So, anyone have an idea as how to a) get the usermapping info and b) pass it to the web app.  (I've tried using a session cookie, but it does not appear be globally visible).
    Cheers,
    Mike

    I'm not familiar with EP5.0, but I think maybe using URL rewriting can accomplish SSO.
    But I am worry about if this method will encode the password.

Maybe you are looking for