How to use tomcat JNDI  resource in eclipse

hi all, In my project i am using JSF,Tomcat,eclipse... i am planing to implement annotaions as part of my application
I want to use Jndi resource as part of my project by using java annotaions
for this i configured my server.xml in tomcat as
<Context docBase="ALWREPORTSNEW" path="/ALWREPORTSNEW"
reloadable="true"
source="org.eclipse.jst.jee.server:ALWREPORTSNEW" >
<Resource auth="Container"
driverClassName="com.mysql.jdbc.Driver" maxActive="10000"
maxIdle="3000" maxWait="10000" name="jdbc/enrollmentschema"
password="adminadmin" removeAbandoned="true"
removeAbandonedTimeout="300" type="javax.sql.DataSource"
url="jdbc:mysql://localhost:3306/enrollment_schema_old"
username="root" />
</Context>And i configured web.xml as
<resource-ref>
<description>Enrollment Schema Connection pooling</description>
<res-ref-name>jdbc/enrollmentschema</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>And some where in my project i am using annotaion as follows. i am getting NULL when trying access that annotaion .
@Resource(name = "jdbc/mobileEnrollProd") DataSource mobileds;
@Resource(name = "jdbc/enrollmentschema")
private DataSource enrollds;
public String UploadBankWise() {
System.out.println("--------- ds "+enrollds);// *i am getting NULL*
}but same code working with Glassfish and net benas..
can any body hint me where i did mistake
thanks in advance

Go to Window-Preferences-Java-Debug-Step Filtering. When the dialog opens, press F1 for help. Good luck!

Similar Messages

  • Dynamically set database url using tomcat jndi

    By using Tomcat JNDI, database url information needs to be hardcoded in server.xml file according to the documentation. Is there a way to change the URL information in the code dynamically if necessary?
    And also we need multiple connection pools and the connection information about those pools are only known during run time. So the TOMCAT JNDI is still the right way to go???
    By the way, does anybody ever use tomcat DBCP package to get datasource and set url dynamically?
    Thanks in advance.

    By using Tomcat JNDI, database url information needs
    to be hardcoded in server.xml file according to the
    documentation. Is there a way to change the URL
    information in the code dynamically if necessary?
    Not that I know of.
    And also we need multiple connection pools and the
    connection information about those pools are only
    known during run time. So the TOMCAT JNDI is still the
    right way to go???
    I think so. Since it's just a JDNI lookup, perhaps you can set up multiple data sources and decide on the lookup name at the last minute, depending on circumstances. That might work. I haven't tried it myself. - MOD
    By the way, does anybody ever use tomcat DBCP package
    to get datasource and set url dynamically?
    Thanks in advance.

  • Creating A File Resource Using Tomcat JNDI

    Hi guys,
    My problem is that I am creating a web service and I cannot get to a properties file without creating an absolute reference to that file. If I was creating a servlet I would simple use getServletContext() method to get a relative reference to it. However since it is an axis web service i have to deploy my applications in the WEB-INF/services directory, and because it does not interact with the axis servlet I cannot use getServletContext(). So i thought I could create a JNDI file resource reference in the tomcatHome/conf/context.xml file, similar to how I created a JNDI connection pool. The resouce definition looks like this;
    <Resource name="resource/dialogueEngineConfig" auth="Container"
                      type="java.io.File"
                      url="file:/Applications/apache-tomcat-5.5.1/webapps/axis2/META-INF/DialogueEngine.properties">
    </Resource>now I tried to access the resource in my code like this;
    // Obtain our environment naming
    Context envCtx = (Context) new InitialContext().lookup("java:comp/env");
    // Look up our file
    File  f = (File) envCtx.lookup("resource/dialogueEngineConfig");However I get a NamingException; 'Cannot create resource instance'
    I don't understand why I cant create a file resource in JNDI, it seems like a simple enough thing to do. Am I doing something wrong or missing something? Any help would be greatly appreciated.
    Thanks

    Hello xalien,
    I have the same problem. I need to access external xml config file via JNDI from my servlet, running on Tomcat 5.0.28. Have you manage to define an URL resource? If so, please provide an example how to do it. Many thanx.

  • How to use Tomcat for naming services

    Hi,
    I want to use Tomcat server for a naming service,but how??.
    What i want to do is
    It will register 2 services to a the naming server.
    Later lookup for it from another code.
    I want to know how i can register the same using Tomcat...
    Thanks in Advance
    Mandrake

    http://tomcat.apache.org/tomcat-5.0-doc/jndi-resources-howto.html

  • How to configure a JNDI resource

    I'll try to make my question as simple as possible since I've never got an answer on these forums :(
    I want to configure a JNDI resource in the Sun Java(TM) System Application Server Enterprise Edition 8.1 Admin Console so that webapplications can do basic ldap searches using JNDI.
    The following code works for me:
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, "ldap://the.ldap.server:389");
    env.put(Context.SECURITY_AUTHENTICATION,"simple");
    env.put(Context.SECURITY_PRINCIPAL,"thebinddn");
    env.put(Context.SECURITY_CREDENTIALS,"thepassword");
    try {
      LdapContext ctx = new InitialLdapContext(env, null);
      SearchControls cons = new SearchControls();
      cons.setSearchScope(SearchControls.SUBTREE_SCOPE); 
      NamingEnumeration results = ctx.search("ou=People,o=Temmellys,o=org", "uid=juhani2", cons);
      while (results != null && results.hasMore()) {
        /* doing something with the results */
      ctx.close();           
    catch (Exception e) {
      e.printStackTrace(out);
    }So my question is; How do I configure this resource with the same environment properties in the admin console? I want to name the resource ldap/test and access it in the following way (is this correct?):
    InitialContext ctx0 = new InitialContext();
    LdapContext ctx = (LdapContext)ctx0.lookup("ldap/test"); Do I configure a "Custom resource" or an "External resource" and how do I specify the properties?
    See my original post for more information:
    http://swforum.sun.com/jive/thread.jspa?threadID=62965&tstart=0
    Even if this is basic rtfm stuff it would be nice if someone could help me out here. I am developing a portal for an organization running JES and my hands are tied on trying to get other things to work.

    Problem solved in the original thread. If you are trying to do the same be sure to check it out (the SUN documentation is faulty):
    http://swforum.sun.com/jive/thread.jspa?threadID=62965&tstart=0
    I apologize for starting two threads on this.

  • How to use a Java Resource in my java source

    Hello,
    I need to know how to use my external JAR I loaded in the database using this line below:
    CREATE OR REPLACE JAVA RESOURCE NAMED "MyJar" USING BFILE (BFILE_DIR,'MyExternal.jar');
    In fact, I have a Java file using this JAR, but I do not know how to tell to the java source that it have to use this JAR.
    ==========Java Source importing the Jar===================
    package com.gemalto.ws.snmp;
    import java.io.IOException;
    import java.util.Vector;
    import org.snmp4j.Snmp;
    import org.snmp4j.smi.*;
    import org.snmp4j.TransportMapping;
    import org.snmp4j.transport.DefaultUdpTransportMapping;
    import org.snmp4j.CommunityTarget;
    import org.snmp4j.mp.SnmpConstants;
    import org.snmp4j.PDU;
    import org.snmp4j.event.ResponseEvent;
    public class SNMPAgent
    ==========================
    Could you give the SQL request or loadjava command line permitting to do use my java resource file?
    Thks

    The JAR is already load by using CREATE JAVA RESOURCE ... or "loadjava -resolve –force -user p/p@SID –genmissing -jarasresource MyJar.jar"
    If we can create a resource by SQL or loadjava, how can I use it in my java code?
    Edited by: 847873 on 28 mars 2011 06:05
    Edited by: 847873 on 28 mars 2011 06:07

  • How to Use Step with Filters in Eclipse

    Hello, everyone!
    I have a question. How do I keep myself from accessing methods outside my own class? See, when I use the debug feature of Eclipse, (I am using Eclipse 3.0), and start debugging, I often "Step Into" methods of classes like String.class and the like. Doing so produces errors that I need to click on to for numerous times! =( It hinders me from doing what I want to do. Can anyone help me? How do I prevent Eclipse from doing that again? After all, my only concern is seeing the methods I wrote in action, and I don't really want to bother with the ones already defined in Java (like Integer.Class and such).
    I also did a search on google, but the sites that turned up are only those that say Use Step with Filters, and nothing specific (most of them are copy-pastes, so different sites end up saying exactly the same thing ). I did that already, and the same thing happens. What do I have to do in
    Window->Preferences->Java->Debug? Do I have to add packages, classes or filters? If so, how should I do it?
    Sorry for the long entry, but I'm getting frustrated with clicking on the errors... I hope someone can help me. =)
    Thanks in advance! =D

    Go to Window-Preferences-Java-Debug-Step Filtering. When the dialog opens, press F1 for help. Good luck!

  • How to use a Java Resource??

    Hello,
    I need to know how to use my external JAR I loaded in the database (hosted in Oracle 10.2.04) using this line below:
    CREATE OR REPLACE JAVA RESOURCE NAMED "MyJar" USING BFILE (BFILE_DIR,'MyExternal.jar');
    In fact, I have a Java file using this JAR, but I do not know how to tell to the java source that it have to use this JAR.
    ==========Java Source importing the Jar===================
    package com.gemalto.ws.snmp;
    import java.io.IOException;
    import java.util.Vector;
    import org.snmp4j.Snmp;
    import org.snmp4j.smi.*;
    import org.snmp4j.TransportMapping;
    import org.snmp4j.transport.DefaultUdpTransportMapping;
    import org.snmp4j.CommunityTarget;
    import org.snmp4j.mp.SnmpConstants;
    import org.snmp4j.PDU;
    import org.snmp4j.event.ResponseEvent;
    public class SNMPAgent
    ==========================
    Could you give the SQL request or loadjava command line permitting to do use my java resource file?
    Thks

    Hi,
    I think you should not load the jar as java resource.
    And I think there is no need to tell to the java source that it have to use the JAR. It will automatically look for the library.
    You should load the jar file using the loadjava utility.
    If it can helps, here is how I proceed :
    /* LOAD .JAR FILE */
    loadjava -user your_user/password@host -resolve -verbose -nodefiner C:\jdevstudio1013\jdev\lib\your_lib.jar
    /* LOAD PROGRAM */
    loadjava -user your_user/password@host -resolve -verbose -nodefiner C:\jdevstudio1013\jdev\mywork\your_program.java
    /* CREATE THE PL/SQL FUNCTION */
    create or replace procedure your_function(arg1 in varchar2, arg2 in varchar2) authid current_user as
    language java name 'your_program.your_function(java.lang.String, java.lang.String)';
    /* EXECUTE */
    select your_function('hello','world') from dual;

  • How to use Tomcat

    Hello friends
    I want to use some functions which are in Java Servlet Specification 2.3.
    I found that I have to use Tomcat for this. Any one who know about it please help, to find where I will get Its setup and required information to run the servlet in this tomcat.
    with thanks
    Vishwajeet

    Hi,
    1. go to: http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.0.2/bin/
    Download tomcat
    Ex: jakarta-tomcat-4.0.2.zip (Win)
    2. unzip it and put some where, you can rename the dir to C:\tomcat
    3. set the path to CATALINA_HOME tomcat:
    CATALINA_HOME=c:\tomcat
    4. run tomcat:
    %CATALINA_HOME%\bin\startup (Win)
    $CATALINA_HOME/bin/startup.sh (Unix)
    5. go to http://localhost:8080/ on your browser
    ...Enjoy
    Hill

  • How to set the JNDI resources and params

    I am trying to connect my Crystal reports to my JSP page.
    I am using MySql DB and TomCat 4.1
    My web.xml is in the right place and contains the JNDI name (jdbc/MyDB)
    I was able to accomplish the following:
    1) Setting the connection pool and
    2) Able to specify the JDBC database option and was also able to generate the report in the designer using this JDBC option connectivity.
    However, when I try to run the report from the JSP page, it gives me the following error:
    javax.servlet.jsp.JspException: Report location is not specified in the configuration file     at
    com.crystaldecisions.report.web.viewer.taglib.ReportServerControlTag.doEndTag(Unknown Source)
         at org.apache.jsp.testing_jsp._jspx_meth_crviewer_viewer_0(testing_jsp.java:159)My CrystalReportEngine-config.xml resides in
    C:\Program Files\Apache Group\Tomcat 4.1\webapps\WebModule1\WEB-INF\classes
    and it contains the following
    <CrystalReportEngine-configuration>
      <reportlocation>../..</reportlocation>
      <timeout>10</timeout>
      <keycode>Azzzzzzzzzzzzzzzzzzzzzz</keycode> </CrystalReportEngine-configuration>
    My report that I am trying to execute resides in the root of my application (where it supposed to be).
    This lead me to believe that I probably need to specify a JNDI datasource.!! Do you agree? If so, how can I specify the
    JNDI Provider URL
    JNDI Username (is this the tomcat admin user name)?
    JNDI PWD
    Initial CONTEXTReally appreciate any help you can offer

    Can anyone tell me where to post the previouse message to get a solution, or may be a hint?
    If i am doing anything wrong to not get a response, please let me know so i can reward it or correct it.
    thanks

  • How to use xliff as resource bundle ?

    I used to do Java i18n as following base on resource bundle in properties file format:
    Locale myLocale = new Locale("es", "ES");
    ResourceBundle bundle = ResourceBundle.getBundle("HelloResourceBundle", myLocale);
    System.out.println(bundle.getString("Hello"));I realized that there is new bundle called xliff like:
    <trans-unit id="Hello">
    <source>Hello how are you</source>
    <note>This is message to say hello</note>
    </trans-unit>Does java resource bundle support xliff file similar to properties file? if not, could anybody give an example how to handle xliff file?
    Thanks

    Following code worked for me:
    import oracle.javatools.resourcebundle.BundleFactory;
    import java.util.ResourceBundle;
    * This method retrieves localized strings from a given XLIF resource bundle.
    * @param bundleName The XLIF bundle from which the localized string is to be retrieved.
    * @param key The key of the localized string.
    * @return The localized string retrieved from the given XLIF bundle.
    public static String getXlifLocalizedString(String bundleName, String key) {
    if (StringUtils.isEmpty(key)) {
    return key;
    if (StringUtils.isEmpty(bundleName)) {
    return "[" + key + "]";
    String localizedString = null;
    ResourceBundle resourceBundle = null;
    try {
    resourceBundle = BundleFactory.getBundle(bundleName);
    localizedString = resourceBundle.getString(key);
    } catch (Exception e) {
    LOG.log(Level.SEVERE, "Problem in loading XLIF resource bundle: " + bundleName, e);
    return "[" + key + "]";
    return localizedString;
    }

  • How to declare a JNDI resource which is not a datasource ?

    Hi,
    I'm looking for a way to create a jndi bound resource, as a jang.lang.String for instance, within oc4j enterprise console or maybe by editing config files.
    I'm trying to configure an application once for all, so that I can deploy a .ear which is identical for development, testing, validation, production, ... environments while being able to configure those instance independently.
    Can it be done with oc4j ? (it's intuitive to create a jndi bound resource if it's a datasource, but it seems to be the only kind of resource we can create) and if so, how ?
    thx in advance
    Olivier

    Hi Olivier,
    As far as I know, this is not possible. I see only three ways
    1. Add an OC4J startup class and bind the desired names into JNDI
    (not sure, whether this is really possible)
    2. If you need the bound JNDI objects only in a web application: just add them to your web.xml file
    3. Write your own provider and add it to the default application.xml or to your application's application.xml
    Best,
    Manfred

  • How t use defferent handset (Emulator) with Eclipse --very IMP for u and me

    Hi all,
    I am using Eclipsewith ME + Suns WTK(2.2 , 2.5 and2.5.1 versions ) for devoleping Midlet Application.I have to teest my Midlet suite for
    a) MIDPI version 1.0 and CLDC 1.0 handsets
    b) MIDPI version 1.0 and CLDC 1.1 handsets
    But there are no Handsets with the above configuration available in these wtk versions.
    But I can change the cldc version in the Preference page of Eclipse
    (Eclipse>Windows>Preference>j2me>preverification>��..). &
    (Eclipse>Project Propertise>preverification...............................)
    Which among these Is the correct way?
    ====================================
    Also i got a url ---- http://developers.sun.com/mobility/device/device
    Here there are number of hand sets supports different CLDC and MIDP versions
    But how can i use this devise�s Emulators with Eclipse ME?
    Please give me a reply ,if anyone knows...........?
    ==================
    Many Many Thanks
    Bala M

    I am all new to Handheld development and saw that your useing Eclipse ME. Is there a way to get the j2me api into eclipse so the environment provides some insight? Right now im struggling in forward movement as I dont know any of the libraries and what the examples are doing or returning.
    Thanks for any information you can provide.

  • How to use webui ui:upload in eclipse 3.2

    Hi,
    I would like to use file upload using sun products.
    I tried with <ui:upload> but i am not able to render that component.
    my jsf:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ taglib uri="http://www.sun.com/web/ui" prefix="ui"%>
    <f:view>
    <html>
    <head>
    <title>Portfolio Analyzer</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link rel="stylesheet" type="text/css" href="css/menu.css" />
    <link rel="stylesheet" type="text/css" href="css/stylesheet.css" />
    </head>
            <ui:page id="page1">
                <ui:html id="html1">
                    <ui:body id="body1">
                        <ui:form id="form1">
                            <ui:upload id="fileUpload1" />
                        </ui:form>
                    </ui:body>
                </ui:html>
            </ui:page>
    </html>
    </f:view>my web.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
         <display-name>
         GPJ</display-name>
         <context-param>
            <param-name>javax.faces.CONFIG_FILES</param-name>
            <param-value>/WEB-INF/faces-config.xml</param-value>
        </context-param>
          <context-param>
            <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
            <param-value>server</param-value>
        </context-param>
        <context-param>
            <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
            <param-value>true</param-value>
            <!-- <description>
                This parameter tells MyFaces if javascript code should be allowed in the
                rendered HTML output.
                If javascript is allowed, command_link anchors will have javascript code
                that submits the corresponding form.
                If javascript is not allowed, the state saving info and nested parameters
                will be added as url parameters.
                Default: "true"
            </description>-->
        </context-param>
         <!-- Filter needed for File Upload component  -->
        <filter>
          <filter-name>UploadFilter</filter-name>
          <filter-class>com.sun.rave.web.ui.util.UploadFilter</filter-class>
          <init-param>
            <description>
              The maximum allowed upload size in bytes.  If this is set
              to a negative value, there is no maximum.  The default
              value is 1000000.
            </description>
            <param-name>maxSize</param-name>
            <param-value>1000000</param-value>
          </init-param>
          <init-param>
            <description>
              The size (in bytes) of an uploaded file which, if it is
              exceeded, will cause the file to be written directly to
              disk instead of stored in memory.  Files smaller than or
              equal to this size will be stored in memory.  The default
              value is 4096.
            </description>
            <param-name>sizeThreshold</param-name>
            <param-value>4096</param-value>
          </init-param>
    </filter>
        <filter-mapping>
          <filter-name>UploadFilter</filter-name>
          <servlet-name>Faces Servlet</servlet-name>
        </filter-mapping>
    <!--
    Where this servlet refer to the faces context
    -->
    <servlet>
         <servlet-name>Faces Servlet</servlet-name>
         <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
         <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
         <servlet-name>Faces Servlet</servlet-name>
         <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <!--
    This gives the welcome page as First.jsp
    -->
    <welcome-file-list>
            <welcome-file>faces/addCampaignGroup.jsp</welcome-file>
    </welcome-file-list>
    <!-- Faces Servlet Mapping -->
      <!--<servlet-mapping>
      <servlet-name>Faces Servlet</servlet-name>
      <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
          --><login-config>
      <auth-method>BASIC</auth-method>
    </login-config>
    <!--
    either this servlet or the listener can be given to refer the application context
    -->
    <!--<servlet>
                 <servlet-name>context</servlet-name>
                 <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>      
                <load-on-startup>1</load-on-startup>
    </servlet>
    -->
    <!--
    This listener is to get the first jsp page   
    -->
    <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
    </listener>
    </web-app>I think i have some problem with my web.xml
    Could anyone pls help me regarding.
    Thanks,
    Ambika.

    I just tested it at my Eclipse environment. It was set to UTF-8 and the following line was not allowed:
    String &#35430;&#39443; = "&#35430;&#39443;";When I set the encoding to UTF-16, it was accepted. If you still fails in this somehow, consult the eclipse boys, as said before.
    However. In name of reusability I don't recommend to use other languages than English thoroughout the whole Java code. Maybe only in javadocs. But still, English is preferred over all other languages. The core Java API itself is also all in English.

  • Using Tomcat in Eclipse?

    Hi,
    Can you tell me how to use Tomcat using Eclipse?
    Whether we have to plug-in Tomcat in Eclipse?
    I'm using Eclipse3.1.1 Version.
    Thanks,
    Hari

    you can use "com.sysdeo.eclipse.tomcat_3.1.0" plugin. Just download the zip file and expand it in plugin folder of eclipse. I am using it on ecipse 3.1.2 it works fine.
    By the way you need to set certain parameters in Eclispe.
    GO to windows-preferences-java
    Installed JREs - add the path of your j2sdk1.4.(eg.c:j2sdk1.4.2_11)
    then Go to windows--preferences--tomcat-
    advanced - fill your tomcat base
    JVMSettings - JRE drop down box select the j2sdk you added
    JVMSettings - classpath - add tools.jar from your j2sdk lib folder
    JVMSettings - Boot ClassPath - add rt.jar from your jre lib folder
    SourcePath
    Select your java project you are working with
    Then click ok.
    Try to run eclipse in clear mode.
    Please let me know if this worked. I also did the same procedure and It is working fine.
    Meena

Maybe you are looking for

  • Preview Draft Number in PLD Outgoing Payment

    Hi All, Anybody know how to preview draft number (field docentry, table OPDF) in PLD Outgoing Payment? and how to link payment draft report(OPDF) with outgoing payment (OVPM)? Thank U all. Regards, Ratna

  • AS 3.0 event target problem!!!

    I have an interesting problem regarding event.target in Flex 2/ActionScript 3.0. I am using the Flex Grocer app in order to try something out. I am attaching listeners to all the click events and then printing out event.target to keep track of my eve

  • Without regex package

    How can I check a string that belongs to a grammar or not without importing regex package in my java program. If Anybody have good idea please give .

  • Same field two meaning

    Hi all; I need to create a custom data source which contains different fields from different table, I am trying to create a view for this. I have this issue: same field ID has different meaning in two tables and I can't use those two same fields into

  • Use of Integration Engine on Application System

    I would like to know - the use of Integration Engine on Application System. Any links or docs are appreciated reg