Datasource works with java code but not with sql:query dataSource=...

Hello everyone! I have a small problem with binding a DataSource object via JNDI and retrieving it in a web application. This is the case:
I did not wish to make the DataSource available through the server.xml, because I want to create applications that can be bundled in a simple .war file. So I create the DataSource when the context is created in the contextInitialized() method of ServletContextListener like this:
InitialContext initialContext = new InitialContext();
Properties properties = new Properties();
properties.setProperty( "driverClassName", "com.mysql.jdbc.Driver" );
properties.setProperty( "factory",   "org.apache.commons.dbcp.BasicDataSourceFactory" );
properties.setProperty( "username", servletContext.getInitParameter( "dbUser" ) );
properties.setProperty( "password", servletContext.getInitParameter( "dbPass" ) );
properties.setProperty( "url",      servletContext.getInitParameter( "dbUrl" ) );
properties.setProperty( "defaultAutoCommit", "false" );
properties.setProperty( "maxActive",         "25" );
properties.setProperty( "initialSize",       "15" );
properties.setProperty( "maxIdle",           "10" );
properties.setProperty( "testOnBorrow",      "true" );
properties.setProperty( "testOnReturn",      "true" );
properties.setProperty( "testWhileIdle",     "true" );
properties.setProperty( "validationQuery",   "SELECT 1" );
properties.setProperty( "removeAbandoned",   "true" );
DataSource dataSource = BasicDataSourceFactory.createDataSource( properties );
initialContext.rebind( "daers", dataSource );Please comment if you think this is a bad idea!
All the above seems to work fine. When I try to retrieve the DataSource in a .jsp file then it all works fine like this:
<% try {
        javax.naming.InitialContext initialContext = new javax.naming.InitialContext();
        java.sql.Connection conn = ( ( javax.sql.DataSource )initialContext.lookup( "daers" )).getConnection();
        java.sql.Statement statement = conn.createStatement();
        java.sql.ResultSet resultSet = statement.executeQuery("SELECT users.name FROM users;");
        while (resultSet.next()) {
            System.out.println(resultSet.getString(1));
    } catch ( java.sql.SQLException e ) {
        e.printStackTrace();
    } catch ( javax.naming.NamingException e ) {
        e.printStackTrace();
%>But when I try to execute the same sql query through the appropriate JSTL taglib I get a:
javax.servlet.ServletException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver"The JSTL code I use is this:
<sql:query dataSource = "daers" var = "query" scope = "page">
        SELECT users.name
        FROM users
    </sql:query>I do put both of the two above pieces of code in the same .jsp page and the first works but the second causes the exception...
Any clues..?
Is it illegal to lookup a DataSource in <sql: dataSource=...> if the DataSource is not registered in the server.xml file..?
If so, do I have any alternatives (like putting the DataSource as a servlet context variable)..?

I added a response in your original message:
http://forum.java.sun.com/thread.jspa?messageID=9629812
Let's keep to it since splitting things across two posts might be confusing.

Similar Messages

  • My firewire port works with ext hd but not with audio interface

    2010 Imac 21.5 running 10.8.5. My firewire port works with ext hd but not with audio interface. The local authorized Apple tech said that I need a new motherboard, but my firewire ext drive works perfectly. I don't understand. Thanks.

    You must go to the website of the audio interface manufacturer and look for, download and install updated drivers for the audio device you are using.
    This is not, neccessarily, an Apple issue.

  • Have Sony reader 505, ADE doesn't recognize when attached to mac OX 10.6.8. works with reader library but not with ADE

    Have Sony reader 505, ADE doesn't recognize when attached to mac OX 10.6.8. works with reader library but not with ADE

    YEAY!
    I just got the solution (that worked for me, anyway) from a Sony support rep. No PC or VMWare needed.
    OK, you've installed Sony eBook Library v3, and Adobe Digital editions, you've set up your acocunts and authorized your computer on both of them, and you've authorized your Reader with the Sony Library application.
    You go to the public library ebook download page, either through the Sony Library or just through a bookmark.
    You check out a book, and open it in Adobe Digital Editions, which still won't recognize your Reader.
    BUT, in the Sony Library app, you can now click "File, Import.." and go find the pdf you downloaded with the Adobe app.
    On my Mac, it was in ~/Documents/Digital Editions
    Import it, and drag it to your Reader.
    The first time you do this, it will ask you to authorize the Reader with your Adobe ID.
    Worked like a charm.

  • ITunes library stored on an external hard drive which is connected to my airport extreme, I wish to share my iTunes library over my network, I can do this with my laptop, but not with my iPad, can anyone tell me if it is possible

    I have my iTunes library stored on an external hard drive which is connected to my airport extreme, I wish to share my iTunes library over my network, I can do this with my laptop, but not with my iPad, can anyone tell me if it is possible

    You can't connect directly to the external drive, but should be able to use iTunes Home Sharing via the laptop.
    http://support.apple.com/kb/PH1453

  • My Printer (samsung clx-3185fw) says it connects to my network but I can't seem to print wirelessly.  I could with my netgear but not with my airport extreme, any ideas?

    My Printer (samsung clx-3185fw) says it connects to my network but I can't seem to print wirelessly.  I could with my netgear but not with my airport extreme, any ideas?
    I have restarted all units, disconnected and reconnected

    Hi ryanfromstockbridge,
    I apologize, I'm a bit unclear on exactly what you are seeing when you try to add the printer or print to the printer. If you continue to have issues printing to this wireless printer, you may find the information and troubleshooting steps outlined in the following articles helpful:
    OS X Yosemite: Printing troubleshooting
    Troubleshooting printer issues in OS X - Apple Support
    OS X Yosemite: Add or remove a printer
    Sincerely,
    - Brenden

  • Using iCloud my iCloud calendar is syncing with my iPhone but not with the Outlook calendar on my PC (Windows 7)

    Using iCloud, my iCloud calenda is syncing with my iPhone but not with the Outlook calendar on my PC (Windows 7)

    smurfanda wrote:
    I agree. What I see is that it is creating an icloud calendar in Outlook but I want it to sync to Outook itself.
    That is what it does. There is no sync, you have a new calendar.

  • ESR,ID working with 8000 port but not with 50000

    Hi experts,
    I am working with PI 7.1. I am working with SOAP to ABAP SERVER Proxy scenario. I have downloaded the WSDL from ID and using XMLSPY sent a SOAP request to PI server and I got an error in SXMB_MONI under the Call Adapter step saying CLIENT_RECEIVE_FAILED.
    We cross checked the services in  SMICM transaction, and we missed the HTTP port 8000 for the parameter icm/servr/port_xx.
    Then basis team changed the port 8000 in SMICM for the same parameter and restarted the Java stack.we checked the icm/HTTP/j2ee parameter which is having 50000 port.
    Now ESR,ID,SLD,RWB... etc are working with ABAP port 8000 but not with 50000 java port and also I am getting an error in SXI_ CACHE while doing my delta refresh if_http_client receive http_communication_failure : http_communication_failure:ICM_HTTP_CONNECTION_FAILED. Kindly suggest me to resolve this error.
    Naveen

    Hi,
    Re: Architecture of PI 7.1
    NW PI 7.1 - ICM is not binding to port 5$$00
    from the above two threads it is very clear that from PI 7.1 both the ABAP and J2EE ports are same.
    Now we maintained both the ICM and j2ee port as 50000. Now ESR,ID,SLD are working with port 50000.
    But in my SOAP to Proxy scenario I  am getting the same error. When I try to send request to XI server using Altova xmlspy I am getting following error in SXMB_MONI under Call Adapter
    <SAP:Code area="INTERNAL">CLIENT_RECEIVE_FAILED</SAP:Code>
      <SAP:P1>400</SAP:P1>
      <SAP:P2>ICM_HTTP_CONNECTION_FAILED</SAP:P2>
    When i click that HTML error It shows
    404 Resource not found
    I am getting the following error in CC monitoring .
    com.sap.engine.interfaces.messaging.api.exception.MessagingException: com.sap.engine.interfaces.messaging.api.exception.MessagingException: XIServer:CLIENT_RECEIVE_FAILED
    My reciever communication channel is in green status CC monitoring.
    I tested my server proxy in my end system which is successfully fetching data.
    I am using the following URL format for generating the WSDL from Integration directory.
    http://host:port /XISOAPAdapter/MessageServlet?channel=p:s:c
    Do we need to maintain the Fully qualified host name  in the above URL?
    I tried with a test scenario which is an asynchronous communication with the above mentioned URL format. I got a success message in SXMB_MONI.
    Since I am using PI 7.1 I tried the following URL also  but i this case,the XML spy itself throws error. I couldnt see any messages in SXMB_MONI.
    http://host:port/XISOAPAdapter/MessageServlet?senderParty=&sender
    Service=FS&interface=IF&receiverParty=&receiverService=TS&interfa
    ceNamespace=IFNamespace
    I have seen many threads in SDN for this same error but I didn't get an answer for my scenario.
    Lakshman and Manjusha
    Thanks for the quick responses.
    Regards
    Naveen
    Edited by: naveen perumal on Jul 24, 2009 8:00 PM

  • Windows 8.1 64bit. Webcam works with "Camera" app but not with Skype.

    I've spent a few hours googling and trying out various things - all listed below. I give up - any ideas??? OS: Windows 8.1 64bitMemory: 32GBWebCam: Microsoft VX-7000. As per subject - the webcam works with the "Camera" app but not with Skype for desktop or for Modern UI (or the Microsoft Lifecam software for that matter).  Already attempted: 1) Uninstall webcam drivers - download latest from microsoft (Windows 7) and install in Windows 7 compatibility mode.2) Close (from taskmgr) anything that looks like it might use Webcam. 3) Run Skype for Desktop in Windows 7 and 8 compatibility modes None of the above work. In Skype for Modern UI the webcam doesn't appear in the drop down in Settings - so I can't even select it. In Skype for desktops (version 6.11.32.102) the webcam is found but instead of image I get "Can't start video. Try closing other programs that might be using your webcam". I see from a bit of googling that various people seem to have the same issue (i.e. Webcam works with Camera app but not Skype) - so I'm hopeful someone has found a workaround / fix to this issue and I've just not had the googling skills to find it  Thanks, - Matt Symes

    OK - I appear to have resolved the issue.  I restricted my google terms to [vx-7000 site:microsoft.com "windows 8.1"] Which uncovered this article: http://support.microsoft.com/kb/933311 I noticed there were a couple of Windows 7 x64 specific registry settings that were mentioned so I checked these and they weren't as per the article. In fact - one of the Registry Keys was already used by other software "AI Charger+" which is some ValueAdd software that came with my motherboard. I uninstalled AI Charger+, uninstalled LifeCam driver. Reinstalled LifeCam driver in Windows 7 compatibility mode. Still not working. I returned to the registry and noticed the settings still differed from the above article. I corrected them (which involved not just amending Data but having to add new Values). I then disabled and reenabled the LifeCam from dvcmgmt.msc I was then able to get video from the webcam in the Skype for Desktop preview screen.    

  • Wireless video link example works with antenna only but not with SMA to SMA cable

    I am trying to run wireless video link example https://decibel.ni.com/content/docs/DOC-22728 . It works fine if I use install antennas on my Tx and Rx USRPs. But it does not work if I use SMA to SMA cable to connect Tx and Rx USRPs. Can somebody guide me what is the reason why it is only workng with antennas but not with SMA to SMA cable. 
    Thanks 
    JK

    I connect the 30 dB attenuator at RF input port of Rx USRP. But it does not work completely.
    Without connecting attenuator i was not able to receive any thing on my Rx VI although it shows waveform. But after connecting attenuator receiver some times receive text messages and some times not. Also it does not work at all for images and for video it works partially but gives some error related to memory full after few mins.
    I want to know why this example works completely without any problem if I use antennas, and why it does not work perfectly if i use sma to sma cable for connecting transmit and receive usrps.
    Please guide
    Thanks 
    JK

  • Macbook Pro 7,1 (mid 2010?) boot with 6GB mem, but not with 8GB

    Hello,
    I bought a Macbook Pro 13" equipped with 4GB RAM at Apple Store on Oct-2010, and it says it's Macbook Pro 7,1 in profiler.
    I tried to upgrade the RAM from 2GBx2 to 4GBx2, but the MBP freezed in boot sequence with 8GB RAM.
    After some tests, including swap and change the combination of memory modules, I found my MBP can boot with 2+4GB configuration, but not with 4+4GB.
    Does anyone know similar issue on the latest MBP 13"?

    This is a memory speed problem - check here: http://discussions.apple.com/thread.jspa?messageID=13154160#13154160
    When using 2+4 gb, memory speed is choosen, based on the slowest dimm - the 2gb one (1066mHz), when using single/double 4gb - speed is 1333mHz).
    You can see the memory speed in diagnostic mode. I'm trying some stuff, if I succeed, I'll post my way.
    ps. Changing 4gb memory sodimms to 1066mHz will solve your problem. Or if apple fixes the efi to downclock the 1333mhz ones (which btw every pc can do from the bios).

  • URGENT: Rest web service with get method works fine in browser but not with java client(Android)

    Hi ,
    I have created one REST web service which accepts two parameters send back JSON results.
    I tested the it in browser with URL as http://+Inteernal server+/ords/utimes/login_info?p1=+first_param+&p2=+second_para+
    Web service URL :  http://+Inteernal server+/ords/utimes/login_info?p1={p1}&p2={p2}
    But when java team wants to access it from java code it gives error as "400- Bad Request".
    one more IMP thing : when I test it in RESTful web service by using "set bind variable" , it only set value of first parameter.
    APEX version : 4.2
    Database : 11g (XE)
    ords : 2.0.8
    please help me ASAP.
    regards,
    Nagesh Patil

    Hi Pragya,
    thank you for the update.
    Another question: could you please give us any reference about these corrections you told about? Maybe they could be relevant in our case too.
    Our raised incident number is: 3100851983
    Kind regards,
    Davide

  • Why does my Web Handler work with Internet Explorer, but not with Firefox

    I am trying to develop a web page that uses the Simile Timeline (http://code.google.com/p/simile-widgets/wiki/Timeline) with data from SQL Server.
    In initial testing of my timeline I tested it with Example.xml, a static XML file in the correct format to be event data. I wrote the following in the appropriate place within mytimeline's Javascript: -
    var WebHandler = "Example.xml"
    tl.loadXML(WebHandler, function (xml, url) { eventSourceFamily.loadXML(xml, url) });
    This worked fine with both Firefox and Internet Explorer. I then changed the assignment to
    var WebHandler = "GDBTimeline.ashx?Type=Family&Userid=" + getControlValue("input", "hdnUser");
    so that invoked a web handler that could look up the SQL database and return the XML that I wanted, and wrote this web handler.
    This works perfectly with Internet Explorer, but with FireFox the timeline band is blank. Yet when I examine the http traffic with Fiddler2 (http://www.fiddler2.com/fiddler2/) I see that with either browser there is a response from URL
    /GDB_pages/GDBTimeline.ashx?Type=Family&Userid=robertb
    that returns the XML that it is supposed to.
    I have previously used web handlers with Firefox before, with no problems. The Fiddler results conclusively show that the web handler is invoked, and returns the appropriate XML, and this XML is identical to the XML from the static test with Example.xml.
    Where do I start looking for answers? I don't even know if this is a Simile problem, a Firefox problem, or an ASP.NET problem.
    Thank you, Robert.

    Problem solved. The issue: Content Type was not correct.
    Visual Studio creates the web handler with dummy code like this: -
    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
    context.Response.ContentType = "text/plain"
    context.Response.Write("Hello World")
    End Sub
    I wrote a database query that set a string variable to the XML I wanted: -
    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
    Dim Outstring as string
    ' my logic to fill Outstring with XML
    context.Response.ContentType = "text/plain"
    context.Response.Write(Outstring)
    End Sub
    This works with Internet Explorer. However it's not strictly correct: to make it work with other browsers as well,
    context.Response.ContentType = "text/plain"
    should be
    context.Response.ContentType = "text/xml"
    It now works with IE, FF, and Chrome, and presumably all others.

  • Script works in one frame, but not with frames before it

    Hi all-
    I'm a complete AS/Flash n00b, but hoping that I can get some guidance on this.
    I'm trying to test a very simple function for an e-learning module that is to train people on using 'quick keys' or key combinations on their keyboard. Basically, I want to show them a command and have them practice. In the practice, they will be asked to use a command and then have to do it on their keyboard.
    I used the code below successfully with one frame and a couple layers. I created a text-area ("traceArea), put it on the stage, set up the event and function... it works great! (although I'm sure the code isn't very pretty) When anything other than ctrl-p is pressed, it traces the "Try again!" message and when ctrl-p is pressed, "Great job!" pops up.
    stop();
    stage.addEventListener(KeyboardEvent.KEY_DOWN, detectKey);
    function detectKey(event:KeyboardEvent):void
    if (event.ctrlKey== true && event.keyCode==80 )
    traceArea.text = "Great job!";
    else
    traceArea.text = "Try again!";
    So, then I tried to build on to the file and added two frames before the previous AS code.
    Frame 1 - Intro
    A short introduction to the 'module' with a continue button. The code for this frame is:
    stop();
    continueBtn1.addEventListener(MouseEvent.MOUSE_UP,buttonPressed);
    function buttonPressed(event:MouseEvent)
    nextFrame();
    Frame 2 - Instructions
    This frame shows the viewer the correct keys to use to print (ctrl-p). There is another continue button here. Code:
    stop();
    continueBtn2.addEventListener(MouseEvent.MOUSE_UP,buttonPressed);
    The last frame is then the 'practice' (see first code above).
    When I run this file, there are no errors, but when it gets to that last frame, nothing is traced and there is no output on any keyboard command. I know the solution must be pretty easy, but I'm missing it and have no idea what it might be!
    Any help is appreciated. Thanks!
    -Andy

    use the trace function to debug your flash code:
    stop();
    stage.addEventListener(KeyboardEvent.KEY_DOWN, detectKey);
    function detectKey(event:KeyboardEvent):void
    trace(event);
    if (event.ctrlKey== true && event.keyCode==80 )
    traceArea.text = "Great job!";
    else
    traceArea.text = "Try again!";

  • Applet works under 1.4, but not with 1.3

    i have a correct signed applet, which works with java 1.4.2 plug-in (means, the security dialog comes up, the user hits yes and the applet runs and can read/write files on local disk etc.)
    a fresh installation of win2k with java 1.3.1_11 does not accept the certification at all.
    it shows a FilePersmission while reading the .jar file itself.
    the jar is on the local hard disk and is being access via a local html file. (no webserver at all in the moment)
    is it possible that 1.3.1 does not check for certificates on local jar files or something?

    Try it with a webserver and see if it works. I am having a problem getting an applet to work locally under certain versions of the plugin.

  • Applet work with JRE 7_51 but NOT with JRE 7_45

    Hello,
    My major problem is, that my Applet signed with COMODO certificate DOES NOT WORK with JRE 7_45.
    The SAME applet works fine with JRE 7_45, if I sign this applet WITH A SELFMADE UNTRUSTED certificate.
    WHY the comodo signed applet doesn't run in JRE 7_45 ???
    If i launch the comodo signed applet with JRE 7_51 it works perfect !!!
    But in our company we got JRE 7_45 and I have to deal with JRE 7_45. That’s my problem.
    Could you please tell me a solution what I have to do that the comodo signed applet works also in JRE 7_45.
    Thank you!
    Philipp

    Thanks gimbal2.
    I agree the problem may be in the proxy or in the firewall but I don' to know how to prove it as if i call the servlet url from browser I dont have problems .
    The version im using is 6.45 but im sure the same problem occurs also with other versions of JRE6 .
    ... and the problem disappear with JRE7 ...
    trouble is my company want people to use JRE6
    any idea ?
    Gio

Maybe you are looking for

  • Urgent - How to delete a variant in F110 (automatic payment program)

    Hello, I want to delete a variant created in printout medium tab. Please guide me. version-  4.6c Thanks in advance. Regards, Jay

  • BB app world

    Hi, I have just brought a BB and have already activiated the BBM and internet wiht my service provider o2. I have created a BB id on my phone in order to start downloading apps but the problem i am having is that when try to sign in the message that

  • Add another Node EBS 11i

    Hi all, this thread is in continuation with thread. Re: EBS upgrade path Applicaiotn=11.5.10.2 DB=10.2.0.5.0 OS= OEL 4.8 Nodes configuration is 1+1+1 i.e. Node Name erpapps (Admin+Web+Form+Concurrent) erpdb db tier erpdrdb standby database <b>want to

  • Open tabs lost on exit after syncing

    After selecting the new option to sync my settings with my new account, I selected to sync everything except for Passwords and History. But since then, Firefox does not save my open tabs, even though I selected that option. It does not appear to save

  • Templates Project Setup and Lease Management Setups don't show up during selection set creation

    Hi, I am new to iSetup. I have just installed iSetup using the Isetup List Of Mandatory Patches For R12 (Doc ID 811040.1) I don't find the following templates needed by my users to create selection sets: - Projects Setup - Lease Management Setups Any