Jdbc connection blocks when run from jar

The following code establishes a connection EXCEPT when run from within a jar file:
String jdbcDriverName = "oracle.jdbc.driver.OracleDriver";
String dbConnectionURL = "jdbc:oracle:thin:@192.168.2.7:1521:PRISM";
String userName = "mdo";
String password = "mdpass";
// Load the JDBC driver and create a connection to the database
Class.forName( jdbcDriverName );
OracleDataSource dataSource = new OracleDataSource();
dataSource.setURL( dbConnectionURL );
dataSource.setUser( userName );
dataSource.setPassword( password );
connection = dataSource.getConnection();
When run from a jar file, the application does not execute beyond the line:
connection = dataSource.getConnection();
No exceptions are thrown, it just appears that getConnection never returns.
Do I need to do anything different to execute this code from within a jar file?
Thanks in advance,
Phil
<><

When building the JAR file, I inadvertently included files from two Oracle JDBC driver versions (1.2 and 1.4). I was building a single jar file with all files in it.
I am guessing same named files existed in both driver JARs and caused "confussion" when combined into the single JAR.
Still, I would have expected an exception to be thrown or a null connection to be returned instead if the thread just blocking.
Thanks for all replies,
Phil
<><

Similar Messages

  • Class not being created when running from jar

    Hi all,
    Tech info first:
    IDE: Sun Java Studio Enterprise 8
    Plaform: windows xp
    I have created a Swing app, that connects to a com port(using the RXTXcomm). now, when I run the app in the IDE, everything is fine and dandy, but, when I run the jar file, the application loads, but the class in the app which deals with the com port is not created. here is the code:
        private static void createAndShowGUI() {
            //Make sure we have nice window decorations.
            JFrame.setDefaultLookAndFeelDecorated(true);
            Main receiver = new Main();
            receiver.getPropertiesFromFile();
            //Create and set up the window.
            frame = new JFrame("R�FILOG RFID Empf�nger");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setContentPane(receiver.mainPanel);
            frame.setJMenuBar(receiver.createMenuBar());
            frame.addWindowListener(receiver);
            frame.setLocationByPlatform(true);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
            portListener = new RFIDReaderComm(receiver, "COM3");
            portListener.getConfiguration();        
        public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();   
    portListener in the createAndShowGUI() function is an interface level parameter and is the class that is not being created. There is no error message.
    If I move the two lines that deal with the port listener before the frame.pack() line, then the GUI is not even loaded, and when I view the processes in the task manager, the process starts and then quits without anything becoming visible. So from this I guess there is a problem with creating the class when running from a jar, but without any error messages, I have not a clue where to start...can anyone help?
    thanks in advance.

    Well, some more info, so maybe someone can come up with some tips for me...this is really important, and any help is greatly appreciated.
    This is obviously a classpath problem. After running the my jar file with java -jar I finally got the error NoClassDefFoundError
    Kind of obvious I suppose. But, I cannot seem to get the two jar files I need into the classpath. I have tried the following:
    Updating my computers CLASSPATH with the relevant paths - not working
    Trying to get the Sun Java Studio Enterprise to build the required jar files into the final package - cannot get this to work
    Tried updating the manifest.mf in the following way:
    Created a text file Manifest.txt with the lines:
    Class-Path: RXTXcomm.jar
    Class-Path: BrowserLauncher2-10rc4.jar
    ran the command (in the same directory as Manifest.txt):
    jar cfm RUFILOGScanner.jar Manifest.txt classes/*.class
    but this does not work either. When I run: jar tf RUFILOGScanner.jar all I get is:
    META-INF/
    META-INF/MANIFEST.MF
    classes/
    classes/CRCCalculator.class
    classes/Main$1.class
    classes/Main.class
    classes/RFIDReaderComm.class
    classes/URLDialog$1.class
    classes/URLDialog$2.class
    classes/URLDialog.class
    the classes I want added are not there. Plus, (I think this is because I am running SE8) the manifest.mf is not in a folder called META-INF. In fact, I have no folder called META-INF. Is this significant?
    Please, can anyone help me?

  • Program doesn't show icon when run from JAR

    Hello,
    I have a working program with menu and toolbar buttons with icons. When I compile and run the JAR it runs fine with all icons showing up. The icons are located in a folder named icons. They are referenced inside the Java code by "icons/iconName.png". However, after I make a JAR file of the program, it runs normally, but the icons do not show up.
    I use the command line command :
    jar cvfm Program.jar manifest.txt *.class"
    Then I open the JAR with WinRar and place the icons folder in the archive.
    My manifest.txt looks like this:
    {code}Manifest-Version: 1.0
    Class-Path: .
    Main-Class: MyMainClass
    SplashScreen-Image: splash.png{code}
    Any ideas what I did wrong?
    Thanks.

    I was having similar problems. If you use an IDE, such as NetBeans BE SURE to copy that image/ folder into the build/classes in the right place in the hierarchy. In any event, not having resource files such as textfiles and images over in the classes will prevent the IDE from executing a java run. That is obvious and easy to remedy.
    And then the discovery: what works in .class files won't work in .jar. I found this link and tried the following code in a synchronized thread (you want the images loaded before going further with any inits such as frame.setLocation(), or panel.setSize(), etc.):
    ClassLoader cldr = this.getClass().getClassLoader();
    URL imageURL   = cldr.getResource("images/usa_small.png");
    icons[x] = new ImageIcons(imageURL);Where I found it:
    [Class Loaders|http://bits.netbeans.org/dev/javadoc/org-openide-modules/org/openide/modules/doc-files/classpath.html]
    That will help you on the implementation of proper technique. Not sure about adding files to .jar "after the fact".

  • Issue with Enter-PSSession when running from the shell and via script

    Hello
    Can someone please help me with the following issue
    If I open the PowerShell console and do the following
    Enter-PSSession -computername Server1
    "This is a test" > C:\Log.txt
    Exit-PSSession
    It works e.g. the Log.txt file is create as expected on Server1
    However if I put the exact same command in a script and execute the script.
    ./TestScript.ps1
    The Log.txt file is created on my Client (e.g. PC) and not the Server1
    I also tried using $Session = New-PSSession -ComputerName Server1 etc.....
    then Enter-PSSession -Session $Session
    I also tried Enter-PSSession etc....
    Start-Sleep -seconds 60
    "This is a test" > C:\Log.txt
    Exit-PSSession
    Again no luck when running from shell all OK, then executing as a script (again from the command line) files is created on client
    Any ideas why this is happening please and how to resolve, I am using PowerShell v4 on the client and PowerShell v2 on the Server
    Thanks
    AAnotherUser__
    AAnotherUser__

    No, the command is explicitly designed for interactive use, not within a script. If you see
    http://technet.microsoft.com/en-us/library/hh849707.aspx you'll even see it clearly state that it "Starts an interactive session with a remote computer".
    There are quite a few threads elsewhere on the same subject, all of which say the same thing, for instance
    http://powershell.com/cs/blogs/tips/archive/2010/11/15/enter-pssession-do-s-and-don-ts.aspx and
    http://powershell.org/wp/forums/topic/running-multiple-remote-commands-with-enter-pssession/ and
    http://blogs.technet.com/b/heyscriptingguy/archive/2009/10/29/hey-scripting-guy-october-29-2009.aspx and
    http://social.technet.microsoft.com/Forums/scriptcenter/en-US/7e89b957-ff5b-42c4-b107-d7e18752fcf1/enterpssession-within-a-script
    So when you run it interactively, you've started the interactive connection to the remote computer and are now running the relevant commands on that machine. When you run it from the script it starts the remote connection, but crucially it doesn't use that
    new connection, the script is still being run in the current local session.
    When you think about it makes sense. Using the Invoke-command method you're connecting to a remote machine, sending the script block to the remote machine, and then running that block of code on the remote machine. The remote machine only knows about the
    code you send it, not the rest of the script (which is why if you use variables you have to pass them to invoke-command otherwise they won't be available to the script block on the remote machine. Conversely, when you use the Enter-PSSession method, you've
    connected to the remote machine, but you haven't passed any code to it. At that point you're on the remote machine, but it has no way to know what you want it to do since your script code is on the local machine. It can then either return to the local
    machine and run the next line of code locally (which it does), or sit there connected to the remote machine waiting input that will never come (which would be even less useful).

  • Opening Excel Workbook Fails when run from Scheduled Task on Windows Server 2008 Rw

    Hi,
    I have a little vbs script that instantiates the Excel.Application object and then opens a work book to perform some tasks on it. The script runs fine when run from the command line. When I attempt to run it as a scheduled task (it is supposed to update
    data that is pulled from a SQL Server at regular intervals), it fails with the following error:
    Microsoft Office Excel cannot access the file 'c:\test\SampleWorkbook.xlsm'. There are several possible reasons: .....
    The file does exist. The path reported in the error is correct. The account under which the task is running is the same account I use to run it from the command line. User Account Control is not enabled, and the task is set up to run with highest privileges.
    When I run the same script through the Task Scheduler from a Windows Server 2003 machine, it works without issue.
    I was just wondering if somebody on this forum has run into a similar issue in connection with Windows Server 2008 R2 and figured out what the magic trick is to make it work. I'm sure it is rights related, but I haven't quite figured out what which rights
    are missing.
    Thanks in advance for any advice you may have.

    This is truly killing me ... trying to get it working on Windows Server 2012 without success.
    I desperately need to automate running Excel macros in a "headless" environment, that is non-interactive, non-GUI, etc.
    I can get it to work using Excel.Application COM, either via VBScript or Powershell, successfully on many other Windows systems  in our environment - Windows Server 2008 R2, Windows 7 (32-bit), etc.,  -BUT-
    The two servers we built out for running our automation process are Windows Server 2012 (SE) - and it just refuses to run on the 2012 servers - it gives the messages below from VBScript and PowerShell, respectively- 
    I have tried uninstalling and re-installing several different versions of Microsoft Excel (2007 Standard, 2010 Standard, 2010 Professional Plus, 32-bit vs. 64-bit, etc.), but it makes no difference.
    Would be extremely grateful if any one out there has had any success in running Excel automation on Server 2012 in a non-interactive environment that they could share.
    ( I have tried adding the "%windir%\syswow64\config\systemprofile\desktop"
    folder, which did fix the issue for me when testing on Windows Server 2008 R2, but sadly did not resolve it on Windows Server 2012 )
    [VBScript error msg]
    Z:\TestExcelMacro.vbs(35, 1) Microsoft Office Excel: Microsoft Office Excel cannot
    access the file 'Z:\TestExcelMacro.xlsm'. There are several possible reasons:
    • The file name or path does not exist.
    • The file is being used by another program.
    • The workbook you are trying to save has the same name as a currently open work
    [Powershell error msg]
    Exception calling "Add" with "0" argument(s): "Microsoft Office Excel cannot open or save any more documents because th
    ere is not enough available memory or disk space.
     To make more memory available, close workbooks or programs you no longer need.
     To free disk space, delete files you no longer need from the disk you are saving to."
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : ComMethodTargetInvocation
    You cannot call a method on a null-valued expression.
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull

  • CommandAction works through OnDeviceDebug, but not when installed from jar

    Hi everybody,
    I'm trying to run a HelloMIDlet example and if I run it on emulator it works fine, also when I run it on mobile through OnDeviceDebug from eclipse it works fine, but when I install a jar file and run the application it ends with Application Error message and it exits. I found out that the problem might be in the CommandAction method, because when I use this:
    public void commandAction(Command c, Displayable s) {
              notifyDestroyed();
    }then the application works also when installed from jar, but when I use this:
    public void commandAction(Command c, Displayable s) {
       String label = new String("Exit");   //just for test
       if (label.equals("Exit"))
         notifyDestroyed();
    }then it ends with Application Error right after I run the program (and it works when I use OnDeviceDebug). I'm using jdk1.5.0_06 and WTK from Sony Erricsson (my target device is W800i, which supports CLDC1.1 and MIDP2.0)
    My manifest file is
    Manifest-Version: 1.0
    MicroEdition-Configuration: CLDC-1.1
    MIDlet-Name: HelloMIDlet
    Created-By: Sun Microsystems Inc.
    MIDlet-Vendor: Sun Microsystems, Inc.
    MIDlet-1: HelloMIDlet, , HelloMIDlet
    MIDlet-Version: 1.0
    MicroEdition-Profile: MIDP-2.0
    MIDlet-Description: Hello Worldand I don't use the jad file when installing the application (seems to be unecessary when you have a manifest file inside the jar). And I'm unable to debug it because when debugging then it works normally. Also I tried to recompile the BluetoothDemo and the same error(and works through OnDeviceDebug). And when I installed the jar file, which is originally distributed with BluetoothDemo then it worked. When I compared original jar file and my jar file then the only difference was in the size the class files (class files compiled by me were bigger then the class files in original jar file (which work)).
    Any ideas guys and girls?

    I tried that approach but it doesn't work either. I think maybe my directory structure is wrong.
    C:\IRS\IRS.jar
    C:\IRS\irs.hs
    referenced: jar:file://C:/IRS/IRS.jar!/irs.hs
    Am I doing this right?

  • Subreport not displayed when Run from SAP Business One

    We have a crystal report that displays a subreport when it is run from within the Crystal 2008 Designer but not when run from within SAP. Has anybody else seen this error? We have tried importing it into SAP and checking the connections of the report and subreport etc but to no avail.

    Sastry,
    The main report is a document layout with the sub report linked into it using the DocEntry key field from SAP. The subreport should display data based on that link.
    This main report only has the one sub report and when you preview in Crystal it returns data, when you preview using the same criteria but inside of SAP, it is not displayed.
    Thanks
    Mark

  • Create trigger not audited when run from sql developer Version 3.2.20.09

    Creating or editing a trigger is not being stored in the audit table when run from sql developer.
    Here is a sample script to show the issue:
    Grant Connect,create table,create trigger To testuser Identified By testuser;
    create table testuser.testtab(t1 number);
    Select Count(*) From Dba_Audit_Trail Where Owner='TESTUSER';
    CREATE OR REPLACE TRIGGER testuser.testtab_bi_trg BEFORE
      Insert
          ON testuser.testtab FOR EACH ROW
    begin
      null;
    end;
    Select Count(*) From Dba_Audit_Trail  Where Owner='TESTUSER';
    drop user testuser cascade;
    If I run the script from sql developer the CREATE TRIGGER statement does not get audited.
    If I run the script from sql plus or All Arround Automations PL/SQL Developer the CREATE TRIGGER statement does get audited.
    If I edit the trigger from sql developer the CREATE TRIGGER statement does not get audited.
    If I edit the trigger from  All Arround Automations PL/SQL Developer the CREATE TRIGGER statement does get audited.

    DoyleFreeman wrote:
    Not sure what you mean by "perform the audit".
    Have you tested my script? Does the "Select Count(*) From Dba_Audit_Trail  Where Owner='TESTUSER';" increment by 1 after each of the ddl statements or only after the Create table statement.
    Your question doesn't have ANYTHING to do with sql developer and should be posted in the Database General forum
    https://forums.oracle.com/community/developer/english/oracle_database/general_questions
    Yes - and it works just fine once you ENABLE AUDITING. Your scripIt  does NOT include the statements or code used to ENABLE auditing and, specifically, enable auditing for triggers.
    Auditing doesn't just 'happen'; you have to enable it and you have to specify any non-default auditing that you want to perform.
    Have you read any of the extensive documentation about auditing to learn how to use it?
    See the Database Security Guide
    http://docs.oracle.com/cd/E11882_01/network.112/e16543/auditing.htm
    Also see 'Auditing Functions, Procedures, Packages, and Triggers
    http://docs.oracle.com/cd/E11882_01/network.112/e16543/auditing.htm#BCGBEAGC
    And see the AUDIT statement in the SQL language doc for how to specify auditing of specific operations.
    http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_4007.htm
    Select count(*) From Dba_Audit_Trail  Where (Owner='SCOTT' or username = 'SCOTT')
    and action_name = 'CREATE TRIGGER';
    COUNT(*)
    0
    audit create trigger by scott
    CREATE OR REPLACE TRIGGER emp_copy_bi_trg BEFORE
      Insert
          ON emp_copy FOR EACH ROW
    begin
      null;
    end;
    Select count(*) From Dba_Audit_Trail  Where (Owner='SCOTT' or username = 'SCOTT')
    and action_name = 'CREATE TRIGGER';
    COUNT(*)
    1

  • Failed to initialize  Databank exception when run from OLT

    HI All,
    I've created a script with an associated databank,that runs perfectly fine when run from OpenScript. But when I run from OLT, the following waring is encountered.
    Start failure message from agent "OLT Server": oracle.oats.common.databank.DatabankException: Failed to initialize Databank 'Forms.forms'
    Stopped Autopilot because of error on agent "OLT Server".
    Name of my DB is : forms
    and Script name is :Forms
    Please let me know the solution for this.
    Regards,
    Karthik
    Edited by: user777720 on May 21, 2013 5:00 AM

    Have you tried changing the parameter in the Assets/Databank "Save Path" from "Relative to current script" to "Relative to a repository"?
    Regards, Ian.

  • Hizzing / bad sound when running from battery power (Ups)?:

    Why is my computer (Imac) emitting a hizzing sound when running from the UPS (battery)? I am testing a offline UPS type: POWERWARE Eaton Protection Station UPS 500VA 250W. My Imac is suppose to use max 200 watts of electrity (Imac 24 inch. intel 2.8 Ghz, 4 GB memory). When running from AC there is no sound. When testing (pulling out the cord on the UPS the Imac starts emitting a disturbing hizz / sound)???

    I solved it my self. It was OK (no buzz and fuzz) when it was plugged in (when the electicity line was down once and I was running on the UPS battery).....

  • Hyperlink in pdf is missing when run from server.

    Hello,
    I create a link for a field in a report (using Hyperlink tab Hyperlink information).  When I export the pdf from Crystal Report, I could see the link when mouse over the field.  But when I run the report from opendocumentfrom server) , the link is missing.  Does Crystal Report support hyperlink in pdf when run from server?  Or do I miss anything?
    Thanks for your help in advance.

    Moving to BusinessObject forum

  • Microsoft Dynamics AX WebSession() is null in Enterprise Portal when running from a List Page.

    Microsoft Dynamics AX WebSession() is null in Enterprise Portal (EP) when running from a List Page.  
    The WebSession() works for a detail page, but nor a list page in EP.
    Does anyone know of a workaround to this issue?
    Thanks.
    Scott

    Hello,
    You should ask in the Microsoft Dynamics Community Forums.
    Karl
    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog: Unlock PowerShell
    My Book:
    Windows PowerShell 2.0 Bible
    My E-mail: -join ('6F6C646B61726C406F75746C6F6F6B2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})

  • Scim makes leafpad take a while to load, except when run from terminal

    Leafpad normally loads up in an instant. But with scim running (More specifically with the required environment variables exported. Scim simply running without the environment variables does not cause the problem, but then scim does not work.), although it shows up immediately, the scrollbar, menubar etc are greyed out for a few seconds and the program cannot be used until it is fully loaded.
    I'm sure this is specifically a leafpad problem, because there is no noticable lag in other programs. (Mousepad for example is fine.) However, the fact that it loads immediately when run from a terminal scares me. Why doesn't gmrun (and the fvwm menu) work just like a terminal? Is there a possible fix to this problem?

    droog wrote:
    I'm not having this problem as far as i can see, I use fvwm and scim already so installed leafpad to test and it starts instantly from fvwm's menu or terminal.
    from gmrun leafpad starts instantly too so maybe i'm missing something.
    what are you exporting?
    Just the normal:
    export XMODIFIERS=@im=SCIM
    export GTK_IM_MODULE="scim"
    export QT_IM_MODULE="scim"

  • Has anyone else noticed that: "The OS X Lion v10.7.3 Update includes Safari 5.1.3 and fixes that: Resolve a Wi-Fi connection issue when waking from sleep" didn't work?

    I installed OS X Lion v10.7.3 because of the following claim.
    The OS X Lion v10.7.3 Update includes Safari 5.1.3 and fixes that:
    Resolve a Wi-Fi connection issue when waking from sleep
    It continues to be a real pain having to reconnect to the network each time I wake my MacBook Air from sleep.
    Does anyone have a suggestion for the resolution to this problem?

    It seems the update fixed old problems for some and caused new problems for others. Sorry to hear you're in the latter group.
    Here are some things to try.
    1. Go to System Preferences > Network, and click the gear icon under the network interfaces like so:
    Whatever service order you have set, drag Wi-Fi either to the top (assuming it's not already there) or someplace else in the list. Click OK and then Apply. Sleep the system then wake it again to observe any changes.
    2. Click Wi-Fi in the above then click Advanced. Select all the networks your computer has ever joined and delete them with the "-" button. OK then Apply again. Select your network under the AirPort icon to re-join it. Sleep and wake again to see if that did anything.
    3. Try creating a new, temporary user account. Log in under that account to see if its behavior is any different.
    You may have done all of these already but perhaps there is something you have not thought of. If nothing helps we may just have to wait a bit longer for Apple to release a fix.

  • Java application behaving differently when run from netbeans

    Hi,
    When i run my program from netbeans it receives packets from ip addresses which are not in my subnet
    but when i run it from outside netbeans it doesn't receives packets from ip addresses which are not in my subnet.
    Can anybody explains why my application is showing different behavior when run from netbeans and when run independently?
    Thanks.

    Bingo! My script started the rmiregistry and continued on to start the servers. Apparently, it was too quick. I put a 10 second delay after the rmiregistry startup and all is working as it should.
    Thanks for your help. You get the Duke dollars if I can figure out how that works.

Maybe you are looking for

  • HOw do I save a dvd so I can watch it on my tv? dvd

    How do I save a dvd so I can play it on my TV ? Mp4 does not work nor m4v.

  • Aperture 2.0 - Many Pictures now Seeing RED in lighted areas and BLUE

    Here's my problem, I just upgraded to Aperture 2.0 and many of my pictures now have bright lighted areas (like a light) showing up as RED in the viewer. I'm not sure if they will print this way, but I'm a bit concerned. I was able to go into the adju

  • Nokia X1 - Dual sim card

    Hi, I just purchased a Nokia X1. It does not have 2 sim slots. The second one is covered.  User manuel says I can insert 2 sim cards. Do all X1's come standard with 2 slots???

  • My ipod mini jump when writing

    please help me . my ipod mini not working correctly... when writing move or jump sreen! show by video in youtube : http://youtu.be/iTxbN-p9Kzg

  • PeopleSoft Application Performance Testing

    Hi, We are using load runner testing tool for performance testing the peoplesoft application. We want to know whether people soft protocol is the best suited or http/html protocol. Any hints/suggestions will be of great help. Thanks and regards, Sriv