How to Configure the Datasource In JNDI and access it through Java Code

I have declared under web.xml
<resource-ref>
      <res-ref-name>MSDataSource</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      <res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
Under Jrun-resource.xml
<data-source>
            <dbname>xxxxxxx</dbname>
            <driver>macromedia.jdbc.sqlserver.SQLServerDriver</driver>
            <url>jdbc:macromedia:sqlserver://xxx.xxx.xx.xx:1433;databaseName=xxxxxxx</url>
            <username>xxxxxxxx</username>
            <password>xxxxxxxxx</password>
            <encrypted>false</encrypted>
            <encryption-class>jrun.security.JRunCrypterForTwofish</encryption-class>
            <native-results>true</native-results>
            <remove-on-exceptions>true</remove-on-exceptions>
            <pool-statements>false</pool-statements>
            <initial-connections>1</initial-connections>
            <connection-timeout>1200</connection-timeout>
            <transaction-timeout>20</transaction-timeout>
            <cache-enabled>false</cache-enabled>
            <cache-size>5</cache-size>
            <cache-refresh-interval>30</cache-refresh-interval>
            <jndi-name>MSDataSource</jndi-name>
            <poolname>Pool</poolname>
            <minimum-size>0</minimum-size>
            <maximum-size>2147483647</maximum-size>
            <user-timeout>20</user-timeout>
            <skimmer-frequency>420</skimmer-frequency>
            <shrink-by>5</shrink-by>
            <maximum-soft>true</maximum-soft>
            <debugging>false</debugging>
            <disable-pooling>false</disable-pooling>
            <isolation-level>READ_UNCOMMITTED</isolation-level>
            <description/>
     </data-source>
Under jrun-web.xml
<resource-ref>
      <res-ref-name>MSDataSource</res-ref-name>
      <jndi-name>MSDataSource</jndi-name>
</resource-ref>  
Java Code
String dsndb="java:comp/env/MSDataSource";
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,"jrun.naming.JRunContextFactory");
p.put(Context.PROVIDER_URL, "localhost:2932");
InitialContext context=new InitialContext(p);
System.out.println(context.getEnvironment());
DataSource ds=(DataSource)context.lookup(dsndb);
ds.getConnection();
System.out.println(ds.getConnection().toString());
Error is
{java.naming.provider.url=localhost:2932, java.naming.factory.initial=jrun.naming.JRunContextFactory}
Exception in thread "main" javax.naming.NameNotFoundException: No such binding: MSDataSource
    at jrun.naming.ContextManager.getBinding(ContextManager.java:680)
    at jrun.naming.ContextManager.getBinding(ContextManager.java:686)
    at jrun.naming.ContextManager.getObject(ContextManager.java:690)
    at jrun.naming.ContextManager.lookup(ContextManager.java:463)
    at jrun.naming.JRunNamingContext.lookup(JRunNamingContext.java:501)
    at jrun.naming.JRunNamingContext.lookup(JRunNamingContext.java:644)
    at jrun.naming.JRunNamingContext.lookup(JRunNamingContext.java:470)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at Controller.DBManager.getConnection(DBManager.java:29)
    at Controller.DBManager.main(DBManager.java:42)
Please help me .
Thanks in advance

Also, try to log the username/password in your authenticator, just to be sure that credentials changeGood piece of advice, michael. Worth of it. When I changed the credentials manually, it worked correctly,but from the application, when I logout from 'a', 'a' and log in to 'b', 'b', I got a valuable information.
I tried debugging like given below for checking from the application.
class MyAuthenticator extends Authenticator {
    protected PasswordAuthentication getPasswordAuthentication() {
         System.out.println("userrrrrrrrr"+UtilsHTTPS.username);
         System.out.println("pwdddddddddd"+UtilsHTTPS.password);
  .........................................The information I got while debugging from the application was, the username and password does not get printed. It implies that, Authenticator.setDefault(new MyAuthenticator()); does not work as desired ie; even on calling new MyAuthenticator(), it does not get inside the MyAuthenticator class.
Why does this happen? What is the solution for this?

Similar Messages

  • How to configure the permission between folders and groups programlly?

    Hi guys,
    I am developing extension for permission, here I have a question:
    I have a template which contains more sub folders, for each folder the corresponding group should be assigned by certain permission. for example: group g1 has "write" permission to folder f1; group g2 has "read" permission to folder f2 and so on. I assign these permissions by extension programlly. But now I have to provide the possibility (to user) to configure these permissions, that means if in future instead of group g1 has "write" permission to folder f1, group g1 has "read" permission to folder f1. This  kind of change should be allowed by extension. Should I set folders and groups as input parameter in an extension, and give the user possibility to input permission type? In another word, my program is supposed to get the permission from GUI and then create ACL. But where can I set the possibility for user to define the permission? And how can I read this permission?
    I hope I explained it clearly enough.
    Any help is greatly appreciated!
    Regards,
    Liying

    Hi jennifer,
    Find this usefull, follow steps at PAGE 3,
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/419b479b-0801-0010-f8a1-c26208b4b209
    Regards
    Juan

  • How to store the value into variable and access it in RMAN script

    I want to create a variable and dynamically assign a numeric value to it (may get the value may be from SQL )and access the value in RMAN script.
    Thanks...Raj

    Raj,
    We have been getting this type of request and it is not possible via RMAN to do that.
    BUT--You could write a sql/plus script to query your variable and produce the RMAN script with the new value.
    Just a suggestion.
    Tammy

  • Deploying a VB dll using some web service and accessing it through java

    I'm new to Web Services Based Programming. I would like to know whether this is possible and if so has anyone tried it. I want to create a vb dll that contains the remote methods that the client will access from a java program. After going thru a lot of articles, I'm still unsure on how to do this. I found one method was to Create a VB program/dll, deploy it in a web service and create the java program that accesses by another web service.
    I'm doing this as part of my lab syllabus. The thing is My lab exercises do not state anything about the technologies that I can use to do this.
    This is all that is stated there:-
    Creation Of DLL Using VB And Deploy it in Java
    I just cant get any ideas other than deploying both the parts as web services. If anyone has Better ideas for this, I would really appreciate it.
    I dont know anything about CORBA for languages other than Java and I'm already using the servlets and EJB's in my normal life. I'm also learning the ORB based programming in java. Therefore your help will probably help me learn something new then what I know.

    Sorry I wasn't too specific in my last question.
    This is my java class calling the native method print
    //HeyWorld.java
    class HeyWorld {
    private native void print();
    public static void main(String[] args) {
    new HeyWorld().print();
    static {
    System.loadLibrary("HeyWorld");
    In this case, my C method for calling a C++ method: HelloWorld.cpp
    #include "jni.h"
    #include "stdio.h"
    #include "stdafx.h"
    #Include "HeyWorld.h" //this is where i get my function prototype
    #include "Test.h" //this is the C++ header where the print method and the Test class is
    JNIEXPORT void JNICALL
    Java_HeyWorld_print(JNIEnv *env, jobject obj)
    CTest a; //CTest is the print class I created
    a.print();
    //This is the header for Test.h
    class CTest: public CWinApp
    public:
         CTest(); //constructor
         void print(); //our method
    //And this is the implementation of the class Test.cpp
    void CTest::print()
         printf("Hey World!\n");
         return ;
    I could compile the Test.cpp, HeyWorld.cpp successfully. However when I tried to compile HeyWorld.cpp using
    cl -I<path of jdk include> -I<path of jdk include win32> -LD HeyWorld.cpp -FeHeyWorld.dll,
    the VC++ 6.0 compiler gave me this error:
    HeyWorld.obj:error LNK2001: unresolved external symbol "public:_thiscall CTest::CTest(void)"
    HeyWorld.obj:error LNK2001: unresolved external symbol "public:_thiscall CTest::print(void)"
    Thanks for the help.

  • New Outlook 2013 Installation - How to configure for default pop email and access exchange 2003 server for shared folders only

    I have successfully installed and configured outlook 2013 to access my pop.integra.net email accounts.  We have an 2003 exchange server we use for shared folders which I am having difficulty accessing.
    My preference would be to set up my access to the exchange server and use the same data folders for email as are in use for my pop email account.  In outlook 2003 this was simple, but in 2007 on up it seems this feature has been hobbled.  Is there
    a workaround to get both accounts to use the same database?
    Next issue is if I use the Mail client wizard under Control Panel to set up access to the exchange server - everything looks fine but when launching outlook I receive the following 2 error messages:
    "The resource that you are trying to use is located on an unsupported version of Microsoft Exchange.  Contact your e-mail administrator for assistance."
    "Cannot start Microsoft Outlook. Cannot open the Outlook window. The set of folders cannot be opened.  Your Microsoft Exchange administrator has blocked the version of Outlook that your are using.  Contact your administrator for assistance."
    Obviously the optimal solution is to upgrade the Exchange Server - assuming that is not an option - are there any workarounds?
    Any assistance would be appreciated.

    Downgraded to Office 2007.
    So now have a new Windows 8.1 laptop with outlook 2007 installed.
    From what I have been told this should allow me to connect to the Exchange2003 server
    I set up the pop account - works fine
    set up the exchange account through Mail.exe and am unable to launch outlook.
    "Microsoft Exchange is Unavailable"
    "Retry - Work Offline - Cancel"
    Then
    "Cannot start Microsoft Office Outlook.  Cannot open the Outlook Window.  The set of folders cannot be opened.  The information store could not be opened."
    The data file path is the same for both the pop account and the exchange account:
    C:\Users\Scott\app data\local\microsoft\outlook\outlook.pst
    How do I get this to work?
    Help!

  • How to configure the runtime and consolidation for a track in CMS.

    How to configure the runtime and consolidation for a track in CMS.
    I can see the track exists in CMS but the same doesnt pull up in the NWDS in the development configuration perspective.
    I compared the given track with the one which gets pulled up in NWDS. Theres something called runtime system and consolidation which isnt defined for the track which is invisible.
    Please advise , what are these required for. And how can we configure the same.

    The runtime systems are defined for a track to setup the Transport path for any code changes....the Consolidation system is usually defined as a Virtual system for the track and used for comparison and fixing any broken or Dirty DC's ....that means it's not used as a Runtime System for Deployment as compared to DEV,QAT and PROD used for Deployment...
    Hope it helps..
    Regards,
    Shikhil

  • How to configure the XI  and PLM in discovery box

    How to configure the XI (SLD, Integration repository, Integration Builder ) in  SAP discovery system.
    And also i want to configure the PLM and xRPM within R/3 of discovery box.
    Regards,
    Nilesh Damle

    Hi Frank,
    well, first of all, your application provides log configuration information using an XML file at deployment time. This file is called log-configuration.xml (you can see the DTD description here: http://help.sap.com/saphelp_nw04/helpdata/en/48/ef8748caed894bb4b3ae953a60c592/frameset.htm). There you can set configure log controllers, which could be two types: location and category. So, you can specify your location and severity there. This is described here: http://help.sap.com/saphelp_nw04/helpdata/en/35/671c0136b4714c9e1b16b68211287b/frameset.htm.
    Then, after the application is deployed, the log configurations you provided for it are registered with the Log Configuration tool I mentioned about. Using this tool you can later on modify your configurations at runtime (for example, change the severity level) without having to redeploy the application.
    I hope it's clearer now? I guess it was me not getting your first question correctly that caused your confusion.
    Greetings,
    Ivo

  • How to Configure the Netweaver CE UDDI Server and Registry

    Hi,
    I'm trying to configure the UDDI registry in Netweaver CE (trial version 7.1 SR 1) following the <a href="http://help.sap.com/saphelp_nwce10/helpdata/en/45/47e8e91587072fe10000000a155369/frameset.htm">SAP Help documentation</a>. But as the help is not detailed not sure whether I'm doing it correctly. I can access the Service Registry by http://<host>:<port>/sr but not sure whether everything is fine. Also I want to publish Enterprise Services in the registry. As it's not possible to do that from ABAP 7.0 WebAS (doesn't not support UDDI v3) I want to do it via the UDDI client. How to configure the UDDI client by providing the Inquiry URL, Publish URL, etc in the settings?
    Please help me if anyone has any information regarding this.
    Thanks,
    Dipankar

    I am working through the same issues and have not found all of the answers.  However, this may get you closer.
    See http://help.sap.com/saphelp_nwce10/helpdata/en/45/635dd614d73bdbe10000000a1553f7/content.htm for some physical destinations that have to be set up for Visual Composer.
    You can also connect to the registry in NetWeaver Developer Studio by launching the Web Services Explorer from the J2EE Perspecive.  See the help for more details.

  • How to configure the smtp server..

    i had an error when running the java mail program..
    this is my program
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    import java.io.*;
    import java.util.Properties;
    public class MailClient
    public void sendMail(String mailServer, String from, String to,
    String subject, String messageBody,
    String[] attachments) throws
    MessagingException, AddressException
    // Setup mail server
    Properties props = System.getProperties();
    props.put("mail.smtp.host", mailServer);
    // Get a mail session
    Session session = Session.getDefaultInstance(props, null);
    // Define a new mail message
    Message message = new MimeMessage(session);
    message.setFrom(new InternetAddress(from));
    message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
    message.setSubject(subject);
    // Create a message part to represent the body text
    BodyPart messageBodyPart = new MimeBodyPart();
    messageBodyPart.setText(messageBody);
    //use a MimeMultipart as we need to handle the file attachments
    Multipart multipart = new MimeMultipart();
    //add the message body to the mime message
    multipart.addBodyPart(messageBodyPart);
    // add any file attachments to the message
    // addAtachments(attachments, multipart);
    // Put all message parts in the message
    message.setContent(multipart);
    // Send the message
    Transport.send(message);
    protected void addAtachments(String[] attachments, Multipart multipart)
    throws MessagingException, AddressException
    for(int i = 0; i<= attachments.length -1; i++)
    String filename = attachments;
    MimeBodyPart attachmentBodyPart = new MimeBodyPart();
    //use a JAF FileDataSource as it does MIME type detection
    DataSource source = new FileDataSource(filename);
    attachmentBodyPart.setDataHandler(new DataHandler(source));
    //assume that the filename you want to send is the same as the
    //actual file name - could alter this to remove the file path
    attachmentBodyPart.setFileName(filename);
    //add the attachment
    multipart.addBodyPart(attachmentBodyPart);
    public static void main(String[] args)
    try
    MailClient client = new MailClient();
    String server="smtp.canvasindia.com";
    String from="[email protected]";
    String to = "[email protected]";
    String subject="Test";
    String message="Testing";
    String[] filenames ={"c:/A.java"};
    client.sendMail(server,from,to,subject,message,filenames);
    catch(Exception e)
    e.printStackTrace(System.out);
    the error is .................
    javax.mail.SendFailedException: Invalid Addresses;
    nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 553 Attack detected from p
    ool 59.144.8.116. <http://unblock.secureserver.net/?ip=59.144.8.*>
    at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1196)
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:584)
    at javax.mail.Transport.send0(Transport.java:169)
    at javax.mail.Transport.send(Transport.java:98)
    at MailClient.sendMail(MailClient.java:47)
    at MailClient.main(MailClient.java:84)
    Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 553 Attack detected fro
    m pool 59.144.8.116. <http://unblock.secureserver.net/?ip=59.144.8.*>
    at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1047)
    ... 5 more
    how to configure the smtp server in my machine..
    please guide me...

    This uses gmail account, and gmail smtp
    * MailSender.java
    * Created on 14 November 2006, 17:07
    * This class is used to send mails to other users
    package jmailer;
    * @author Abubakar Gurnah
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    public class MailSender{
        private String d_email,d_password;
         * This example is for gmail, you can use any smtp server
         * @param d_email --> your gmail account e.g. [email protected]
         * @param d_password  --> your gmail password
         * @param d_host --> smtp.gmail.com
         * @param d_port --> 465
         * @param m_to --> [email protected]
         * @param m_subject --> Subject of the message
         * @param m_text --> The main message body
        public String send(String d_email,String d_password,String d_host,String d_port,
                String m_from,String m_to,String m_subject,String m_text ) {
            this.d_email=d_email;
            this.d_password=d_password;
            Properties props = new Properties();
            props.put("mail.smtp.user", d_email);
            props.put("mail.smtp.host", d_host);
            props.put("mail.smtp.port", d_port);
            props.put("mail.smtp.starttls.enable","true");
            props.put("mail.smtp.auth", "true");
            //props.put("mail.smtp.debug", "true");
            props.put("mail.smtp.socketFactory.port", d_port);
            props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
            props.put("mail.smtp.socketFactory.fallback", "false");
            SecurityManager security = System.getSecurityManager();
            try {
                Authenticator auth = new SMTPAuthenticator();
                Session session = Session.getInstance(props, auth);
                //session.setDebug(true);
                MimeMessage msg = new MimeMessage(session);
                msg.setText(m_text);
                msg.setSubject(m_subject);
                msg.setFrom(new InternetAddress(m_from));
                msg.addRecipient(Message.RecipientType.TO, new InternetAddress(m_to));
                Transport.send(msg);
                return "Successful";
            } catch (Exception mex) {
                mex.printStackTrace();
            return "Fail";
        //public static void main(String[] args) {
        //    MailSender blah = new MailSender();
        private class SMTPAuthenticator extends javax.mail.Authenticator {
            public PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(d_email, d_password);
    }

  • ASA 5505 8.4. How to configure the switch to the backup channel to the primary with a delay (ex., 5 min) using the SLA?

    I have ASA 5505 8.4.  How to configure the switch to the backup channel to the primary with a delay (for example 5 min.) using the SLA monitor?
    Or as something else to implement it?
    My configuration for SLA monitor:
    sla monitor 123
     type echo protocol ipIcmpEcho IP_GATEWAY_MAIN interface outside_cifra
     num-packets 3
     timeout 3000
     frequency 10
    sla monitor schedule 123 life forever start-time now
    track 1 rtr 123 reachability

    Hey cadet alain,
    thank you for your answer :-)
    I have deleted all such attempts not working, so a packet-trace will be not very useful conent...
    Here is the LogLine when i try to browse port 80 from outside (80.xxx.xxx.180:80) without VPN connection:
    3
    Nov 21 2011
    18:29:56
    77.xxx.xxx.99
    59068
    80.xxx.xxx.180
    80
    TCP access denied by ACL from 77.xxx.xxx.99/59068 to outside:80.xxx.xxx.180/80
    The attached file is only the show running-config
    Now i can with my AnyConnect Clients, too, but after connection is up, my vpnclients can't surf the web any longer because anyconnect serves as default route on 0.0.0.0 ... that's bad, too
    Actually the AnyConnect and Nat/ACL Problem are my last two open Problems until i setup the second ASA on the right ;-)
    Regards.
    Chris

  • How to configure the mail in Sales Support of SAP SD

    Hi,
    Experts I have one scenario in my co. that we have 300 users we have to send the mails to our 300
    users for every 2 or 3 months once. Regarding new promotions (Discounts , Price changes) of
    company.  For this every time we are changing the sold to party in quotation and taking printouts then
    sending to our users its a lengthy procedure, to avoid this long time very soon we are going to
    implement SAP SD Sales Suppor in our company is there any functionality in SAP to send mail at
    once to our 300 users  may i know about how to configure the mail for this scenario.
    Thanks and Regards
    MH

    Hi  Prashant,
    Thanks for you immediate responce, Can you give me the configuration steps in detail.
    Thanks and Regards,
    MH

  • How to configure the JMS application in WSAD 5.0

    hi
    i need to configure an JMS application in WSAD 5, but while configuring the application i am checked with intial context exception. but i have configured the jndi in the server. but i cant able to run the application.
    can anybody help me like how to configure the JMS application in WSAD (can we configure it without MQ simulator if yes i need the steps)
    thanks in advance

    Hi,
    did you check the WebSphere documentation or ask a question on an IBM forum?
    Frank

  • In Exports sales process, how you configure the Duty Draw Back

    in my case
    we r creating Exports but
    duty unavailability of time and time taking process in export processing
    we are creating Excise invoice and cenvat is debited .
    now we r asking the govt. for the duty draw back for the value already cenvat is debited with proper documents like ARE1 etc.
    how to manage this duty back and what r the replications or changes thereafter
    thanks in advance

    Hi Sunitha,
    Pls can u explain how did u solve (In Exports sales process, how you configure the Duty Draw Back) this issue....since i don't have idea abt this...but shortly i am going to do this in my client place....
    thanks,

  • How to install the struts-el jar and tld file

    How can i install/configure the struts-el jar and struts-logic-el.tld. When I tried with the related sites, i couldn't get any jar files for struts-el tag.
    I got only 404 status error.
    From where and how to get the jar file and tld file for the struts-el tag .Please refer me

    The jar file is part of the download of struts.
    its in the /contrib/lib directory
    You should need struts, jstl plus the struts-el jar files.
    The tld files should not be necessary - just use the standard URIs for them.
    eg http://struts.apache.org/tags-logic-el

  • How to Configure MS Exchange 2007 CCR and SCC Cluster in a single system

    Hi i want to configure ms-exchange 2007 server for both SCC and CCR. i have two Windows Server 2008 on running on my hyper-v. by using cluster on both hyper v i want to install MS-Exchange 2007 for both SCC and CCR. ideally one windows server 2008 has
    Active Nodes and another one has passive nodes. please guide me as i am new in the field

    Duplicate of
    http://social.technet.microsoft.com/Forums/exchange/en-US/edea43a1-59b4-4d26-9b41-76d0f4677095/how-to-configure-ms-exchange-2007-ccr-and-scc-cluster-in-a-single-system?forum=exchangesvrgenerallegacy#c6e08365-c01a-40aa-a8bc-94219757ef13
    Blog |
    Get Your Exchange Powershell Tip of the Day from here

Maybe you are looking for

  • My Iphone is deleting messages from my inbox once I open them on my laptop in microsoft outlook. How do I stop this?

    Im not a techno person at all... so Im really struggling with my iphone at the moment. I have two mail inboxes, one for my hotmail and one for my work email. The hotmail one works fine. The other is a pain in the butt. Once I receive an email in the

  • Issue with the home buton... HELP

    So I just purchased my iPhone4 yesterday and here I am less than 24hrs later and there's an issue with the home button. Either the button won't work at all and I have to restart the phone, or its magically being held down and the voice control is act

  • Wrong cost centers and profit centers assigned

    hi all, In FBL3N for the TR(treasury document type) wrong cost center and profit center is being displayed can anyone tell me where is this setting made or where to change to the correct CC and PC? wishes Katya

  • Aluminum keyboard (USB, not wireless) intermittent problems

    Since I got my new Mac Pro here at work, the keyboard has intermittently acted strangely. Occasionally, letter and number keys only will occasionally stop working in the current application. Arrows, function keys and modifier keys will continue to wo

  • Flash player flickering preview

    Helllo, can someone help. I have a simple scene set up in flash. Every time i preview the flash player the screen will flicker white (or whatever the background color is). How do i stop that. Is it a bug? Macbook pro retina osx latest version