Spawning threads from within a UnicastRemoteObject

I have a question regarding spawning threads from within a class that extends UnicastRemoteObject. Would it be okay to spawn new thread(s) in the constructor/ remote methods of the class that extends UnicastRemoteObject .? Are there any pitfalls to doing so? Is it against the suggested practice of writing RMI server code?
rajkumar

You can do anything you like in the Class that extends URO.
The classic problem of doing anything within a constructor is that the object under construction may not be available to the threads you are spawning. That is, since the object is not fully constructed, any fields the new threads need may not be available. There have been discussions on this subject in the forums before. You might give a look and see.

Similar Messages

  • Spawning threads from a webapp

    Can I spawn a thread from a webapp the same way I do in a normal java app?
    Is there anything I should know before I get started doing this(i.e. special circumstances)?
    Any comment are welcome, thanks in advance
    silastad

    anyone???, I know that you can spawn a thread from a webapp, I just want to know if there is anything in particular that I should look out for before I begin.
    silastad

  • Starting new threads from within shutdown hooks

    I'd like to discuss this statement from the java 6 API:
    "A shutdown hook is simply an initialized but unstarted thread. When the virtual machine begins its shutdown sequence it will start all registered shutdown hooks in some unspecified order and let them run concurrently. *When all the hooks have finished it will then run all uninvoked finalizers if finalization-on-exit has been enabled. Finally, the virtual machine will halt*. Note that daemon threads will continue to run during the shutdown sequence, as will non-daemon threads if shutdown was initiated by invoking the exit method. "
    Now, my question is this: If I have a hook that starts a new non-daemon thread and then goes on to complete it's run() method, will the JVM finalize and halt? Or will it wait for my new thread to complete as well?
    I trust the specification, and believe that the JVM will either not allow me to create the thread or will finalize and shutdown even if it is running. However it's not explicitly stated anywhere, and I think that it's a hole in the documentation.
    I'm going to write a test case for this now. But chime in if you have thoughts.

    This is what happens if you start a new thread from a shutdown hook and do not wait for it to finish:
    public class ShutdownTest {
        private static class Shutdownhook extends Thread{
            public void run() {
                System.out.println("Shutdownhook starting");
                Thread t = new Thread(){
                    public void run(){
                        System.out.println("Thread successfully started");
                        try{ Thread.sleep(5000); }
                        catch(Throwable e){ System.out.println("Throwable from sleep: "+e); }
                        System.out.println("Thread successfully finished");
                t.start();
                //try {t.join();} catch (InterruptedException e) {}
                System.out.println("Shutdownhook completing");
        public static void main(String[] args) {
            Runtime.getRuntime().addShutdownHook(new Shutdownhook());
            System.out.println("Exiting from main()");
            Runtime.getRuntime().exit(0);
    Exiting from main()
    Shutdownhook starting
    Shutdownhook completing
    Thread successfully startedHowever, as you might expect, if you join() or wait for the thread's isAlive() to return false, you will be able to complete the thread.
    I'll leave someone else to figure out if that new thread gets finalized and if finalizers on exit is on, what happens. Mostly because it doesn't matter for my purposes.
    Enjoy

  • Any way to get CPU-seconds for process or a thread from within my app?

    I'm trying to guage the work by different processes within our application. I'd like to be able to get the number of CPU-seconds before a long task and then again after the task finishes and compute the difference. I'm sure I could poll the % CPU every second and try estimate the value, but I don't think it would be very accurate.
    Is there a MBean or some other way to access the CPU-seconds for the process?
    It would even be better if I could get this at the thread level (which seems possible since JRA recordings can show the 'running' time on a graph drawn in milliseconds).
    Thanks
    -Bill

    We are considering making this available through a MBean in our upcoming R28 release.Do you have a program I can participate in to get beta or pre-releases of new JRockit versions? The purpose would be to do preliminary performance testing so we can get official releases to our development team more quickly once they are formally released.
    I'm also hoping to find cumulative disk i/o bytes and cumulative network i/o bytes on a thread or even at the JVM levelI don't think we have that in JRockit today... What would you use it for?The use would be for performance monitoring. In a large system or a busy system, the effect of code changes can be hard to measure just based on clock time or traditional measurements like % CPU or bytes/sec at a specific instant. Knowing how much 'work' is getting done (together with the clock time) gives a better picture.
    I like cumulative numbers like cpu-sec and # of bytes because I only need two measures (before and after) instead of continuous polling and summing. Some of my processes get created on their own threads, so I could potentially get these measures of work on my customer's production systems with a lot of other activity going on. By comparing samples over time, we can tell if processes are running longer due to 'more work' or due to resource bottlenecks.
    I think it could be useful on shared threads too even though i don't know yet if I can see which threads specific requests are using.
    -Bill

  • Threads/Locks within EJBs

    I'm trying to get a good handle on the reason there are restrictions on threading/locking
    semantics used from within application code dealing with EJBs. I think the idea
    is the application code shouldn't do anything to interfere with the locking of
    the ejbs done from within the container at various stages in their lifecycle.
    So, I shouldn't subject the bean implemenation class to any explicit synch. But
    what about spawning threads from within my EJBs? In 3rd party classes used by
    my EJBs?
    Any clear explanation is gratefully appreciated.
    Max

    Max
    See section 24.1.2 "Programming restrictions" in the ejb20 final release specification.
    Thanks
    Jim
    Max wrote:
    I'm trying to get a good handle on the reason there are restrictions on threading/locking
    semantics used from within application code dealing with EJBs. I think the idea
    is the application code shouldn't do anything to interfere with the locking of
    the ejbs done from within the container at various stages in their lifecycle.
    So, I shouldn't subject the bean implemenation class to any explicit synch. But
    what about spawning threads from within my EJBs? In 3rd party classes used by
    my EJBs?
    Any clear explanation is gratefully appreciated.
    Max[Reply.vcf]

  • User Thread from OC4J

    Hi,
    I am trying to start a new thread from within my web application.
    but every time it gives me an error -
    javax.naming.NamingException - Not in application scope - start OC4J with the -userThreads switch if using user created threads.
    Can anyone suggest what changes in the server setting do i need to make to the Oracle application server ? I am using 10g version.

    Hi,
    use Enterprise Manager to get to the application server, select your OC4J container, select administration, go to server attributes and put the switch -userThreads to the OC4J options. Restart the container.
    That should do it.
    Timo

  • Threads from threads

    hi,
    just wondering if it's ok to start a thread from within another thread?
    e.g. mythread extends runnable
    run{
    mySubThread sub = mySubThread();
    sub.start();
    }

    Everything in java is running in a thread. Therefore the answer to your question is YES.
    matfud

  • Spawning new entry processors from within an existing entry processor

    Is it possible / legal to spawn a new entry processor (to operate within a different cache) from within an existing entry processor.
    E.g we have a parent and a child cache, We will receive an update of the parent and start an entry processor to do this. Off the back of the parent update we will also need to update some child entries in another cache and need to start a new entry processor for the child entries. Is it legal to do this?

    Hi Ghanshyam,
    yes, in case of (a), you would be mixing different types in the same cache. There is nothing wrong with that from Coherence's point of view, as long as all code which is supposed to access such objects in their deserialized form is able to handle this situation.
    This means that you need to use special extractors for creating indexes, and you need to write your filters, entry processors and aggregators appropriately to take this into account. But that's all it means.
    The EntryProcessor on the child could be invoked, so long as there are more service
    threads configured. This allows retaining partition affinity. I don't think this is technically
    illegal.It is problematic, as invoking an entry-processor from another entry-processor in the same cache service can lead to deadlock/livelock situations. You won't find it out in a simple test as you get an exception or not.
    But even if it is technically not guarded against, firing a second entry-processor consumes an additional thread from the thread-pool. Now if you get to a situation when all (or at least more than half of the thread-pool size) of your entry-processors try to fire an additional entry-processor, and there are no more threads in the thread-pool, then some or all would be waiting for a thread to be available, and of course none would be available, because there are not enough single-thread entry-processors to leave to get a thread to everyone.
    However, none of them can back off as all are waiting for the fired entry-processor to complete. Poof, no processing is possible on your cache service.
    Another problematic situation which can arise if entry processors are fired from entry processors is that your entry-processors may deadlock on entries (entry processors executing on some entries and trying to execute on another entry on which another entry processor executes and also tries to execute on the first entry). In this case the entry-processors would wait on each other to execute.
    No code running in the cache server invoked by Coherence is supposed to access a cache service from code running in the threads of the same cache service, except for a couple of specifically named operations which only release resources but not consume additional new ones.
    Best regards,
    Robert

  • Change a UI text field from within a Thread

    My program has a thread that's busy churning away. It's a runnable called from within my classes main. The UI element is built by a method in the class.
    If I try to report something from within the thread by doing a myText.setText("success"); I get a crash:
    Exception in thread "Thread-1" org.eclipse.swt.SWTException: Invalid thread access
    followed by a bunch of SWT.error messages related to that line. The field myText is defined globally for the class.
    What is a good way to be able to write stuff to a UI from within a thread? I could do it when the extended Thread was defined within my main() by creating a runnable also in my main() that got called through a syncExec. But I want to keep the main simple.

    edit Noticed you're working with SWT
    #

  • I'm operating OS X 10.8.5, Mail 6.6, and I can't seem to extract jpgs or pdfs from within an email thread.  Any suggestions as to how I can retrieve these files?

    I"m operating OS X 10.8.5,  Mail 6.6 and have discovered I can not extract jpgs from within an email thread.  If I catch it upon arrival, everything's fine, but if I reply and continue the thread, the file is no longer extractable.  Any advice?
    Thank you,
    April Snow

    Thanks Eric,
    I would try that if I could see the jpeg file.  The problem is that once the original email has been responded to, and the thread continued, the jpg files disappear from the body of the original email.  Hmmm.  They must be there somewhere, but I can not locate them.

  • Data Model damaged, Cannot connect to Access 2013 from within Excel 2013

    Hello,
    Recently I am not able to use PowerPivot for Excel 2013 and I cannot connect to my Access 2013 database tables from within Excel 2013. Whenever I try to click on a slicer in my Excel worksheet, it gives me the following error: "Excel was unable to load
    a necessary component. This component might have been damaged or deleted. Reinstall the client software or data source driver software for your database."
    I am using Microsoft Office Pro Plus 2013 on Windows 7, 64-bit version. I have tried reinstalling Microsoft SQL Compact Edition 2005 and reinstalling Office 2013. I have run out of ideas and am a loss what to do next ? 
    Can anyone help point in the right direction for a possible solution to this problem ??? 
    Would appreciate all help.
    Thank you.
    ~Maneesh
    The problem with being punctual is, there's nobody there to appreciate it !!!

    Hi
    This is the forum to discuss questions about apps for office develop. For your question is more about Excel, I will move this thread to the TechNet forum for
    Excel
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly
    can either share their knowledge or learn from your interaction with us.
    Thank you for your understanding.
    Best Regards
    Lan
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How do I change the Apple ID that the AppStore on my iPhone defaults to? In settings I am logged into one account, but when I try and update various Apps from within the AppStore the default account that comes up, asking for my password, is different.

    Eg, the phone automatically brings up an old (defunct) AppleID account login every time I try to update my Apps. I don't know the pword for this account, nor does it have current data about me.
    But when I go to settings: store it shows me logged into the correct account.
    I have already tried:
    logging out and logging back in
    downloading a new App from within AppStore (in that case it doesn't ask me for my password or bring up the old AppleID)
    Syncing the phone, confirming that I have the right AppleID account set up on iTunes
    I don't want to have to delete all my paid apps just because I downloaded them long ago with an older Apple ID.
    Help please!

    The very similar situation with mine:
    https://discussions.apple.com/thread/3492726
    I can't find any solution. I don't even remember when I changed my apple ID! So does that means I cant recovered my purchased apps from my " old" account? I am totally innocent, for I did not intend to "Change" my account name

  • Using APEX_MAIL from within a procedure invoked from DBMS_JOB

    I have done a lot of googling and wasted a couple of days getting nowhere and would appreciate some help. But I do know that in order to use APEX_MAIL from within a DBMS_JOB that I should
    "In order to call the APEX_MAIL package from outside the context of an Application Express application, you must call apex_util.set_security_group_id as in the following example:
    for c1 in (
    select workspace_id
    from apex_applications
    where application_id = p_app_id )
    loop
    apex_util.set_security_group_id(p_security_group_id =>
    c1.workspace_id);
    end loop;
    I have created a procedure that includes the above (look towards the end)
    create or replace procedure VACANCIES_MAILOUT
    (p_application_nbr number,
    p_page_nbr number,
    p_sender varchar2)
    AS
    Purpose: Email all people registerd in MAILMAN [email protected]
    with details of any new vacancies that started listing today.
    Exception
    when no_data_found
    then null;
    when others then raise;
    l_body CLOB;
    l_body_html CLOB;
    l_vacancy_desc VARCHAR2(350);
    to_headline varchar2(200);
    to_org varchar2(100);
    l_vacancies_desc varchar2(2000);
    to_workspace_id number(22);
    CURSOR vacancies_data IS
    select DISTINCT v.headline to_headline,
    ou.org_name to_org
    from VACANCIES v,
    Org_UNITS ou
    where
    ou.org_numb = v.Org_Numb
    and v.public_email_sent_date is Null
    Order by ou.org_name, v.headline;
    BEGIN
    BEGIN
    FOR vacancies_rec in vacancies_data
    -- build a list of vacancies
    loop
    BEGIN
    l_vacancy_desc := '<br><b>' ||
    vacancies_rec.to_org || '<br>' ||
    vacancies_rec.to_headline || '</b><br>';
    -- l_vacancy_desc :=
    -- vacancies_rec.to_org || ' - ' ||
    -- vacancies_rec.to_headline ;
    l_vacancies_desc := l_vacancies_desc || l_vacancy_desc;
    END;
    END LOOP;
    END;
    l_body := 'To view the content of this message, please use an HTML enabled mail client.'||utl_tcp.crlf;
    l_body_html :=
    '<html>
    <head>
    <style type="text/css">
    body{font-family:  Verdana, Arial, sans-serif;
                                   font-size:11pt;
                                   margin:30px;
                                   background-color:white;}
    span.sig{font-style:italic;
    font-weight:bold;
    color:#811919;}
    </style>
    </head>
    <body>'||utl_tcp.crlf;
    l_body_html := l_body_html || l_vacancies_desc
    || '<p>-----------------------------------------------------------------------------------------------------------------</strong></p>'
    ||utl_tcp.crlf
    || '<p>The above new vacancies have been posted on the <strong>Jobs At Murdoch</strong> website.</p>'
    ||utl_tcp.crlf
    ||'<p>For futher information about these vacancies, please select the following link</p>'
    ||utl_tcp.crlf
    ||'<p> Jobs At Murdoch </p>'
    ||utl_tcp.crlf
    ||'<p></p>'
    ||utl_tcp.crlf;
    l_body_html := l_body_html
    ||' Regards
    '||utl_tcp.crlf
    ||' <span class="sig">Office of Human Resources</span>
    '||utl_tcp.crlf;
    for c1 in (
    select workspace_id
    from apex_applications
    where application_id = 1901)
    loop
    apex_util.set_security_group_id(p_security_group_id => c1.workspace_id);
    end loop;
    apex_mail.send(
    p_to => '[email protected]',
    p_from => '[email protected]',
    p_body => l_body,
    p_body_html => l_body_html,
    p_subj => 'Jobs At Murdoch - new vacancy(s) listed');
    update VACANCIES
    set public_email_sent_date = trunc(sysdate,'DDD')
    where public_email_sent_date is null;
    commit;
    END;
    but still get the error
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    ORACLE_HOME = /oracle
    System name: Linux
    Node name: node
    Release: 2.6.18-194.17.1.el5
    Version: #1 SMP Mon Sep 20 07:12:06 EDT 2010
    Machine: x86_64
    Instance name: instance1
    Redo thread mounted by this instance: 1
    Oracle process number: 25
    Unix process pid: 5092, image: (J000)
    *** 2011-07-12 09:45:03.637
    *** SESSION ID:(125.50849) 2011-07-12 09:45:03.637
    *** CLIENT ID:() 2011-07-12 09:45:03.637
    *** SERVICE NAME:(SYS$USERS) 2011-07-12 09:45:03.637
    *** MODULE NAME:() 2011-07-12 09:45:03.637
    *** ACTION NAME:() 2011-07-12 09:45:03.637
    ORA-12012: error on auto execute of job 19039
    ORA-20001: This procedure must be invoked from within an application session.
    ORA-06512: at "APEX_040000.WWV_FLOW_MAIL", line 290
    ORA-06512: at "APEX_040000.WWV_FLOW_MAIL", line 325
    ORA-06512: at "APEX_040000.WWV_FLOW_MAIL", line 367
    ORA-06512: at "HRSMENU_TEST.VACANCIES_MAILOUT", line 94
    ORA-06512: at line 1
    Can someone please tell me what what stupid thing I am doing wrong? The procedure worked when invokded from SQL Workshop but fails in a DBMS_JOB.
    much thanks Peter

    I think that might help...
    http://www.easyapex.com/index.php?p=502
    Thanks to EasyApex..
    LK

  • WPF UI running in seperate runspace - able to set/get controls via synchronized hash table, but referencing the control via the hash table from within an event handler causes both runspaces to hang.

    I am trying to build a proof of concept where a WPF form is hosted in a seperate runspace and updates are handled from the primary shell/runspace. I have had some success thanks to a great article by Boe Prox, but I am having an issue I wanted to open up
    to see if anyone had a suggestion.
    My goals are as follows:
    1.) Set control properties from the primary runspace (Completed)
    2.) Get control properties from the primary runspace (Completed)
    3.) Respond to WPF form events in the UI runspace from the primary runspace (Kind of broken).
    I have the ability to read/write values to the form, but I am having difficulty with events. Specifically, I can fire and handle events, but the minute I try to reference the $SyncHash from within the event it appears to cause a blocking condition hanging both
    runspaces. As a result, I am unable to update the form based on an event being fired by a control.
    In the example below, the form is loaded and the following steps occur:
    1.) Update-Combobox is called and it populates the combobox with a list of service names and selects the first item.
    2.) update-textbox is called and sets the Text property of the textbox.
    3.) The Text value of the textbox is read by the function read-textbox and output using write-host.
    4.) An event handle is registered for the SelectionChanged event for the combobox to call the update-textbox function used earlier.
    5.) If you change the selection on the combobox, the shell and UI hangs as soon as $SyncHash is referenced. I suspect this is causing some sort of blocking condition from multiple threads trying to access the synchronized nature of the hash table, but I am
    unsure as to why / how to work around it. If you comment out the line "$SyncHash.TXT_Output.Dispatcher.Invoke("Send",[action]{$SyncHash.TXT_Output.Text = $Value})" within update-textbox the event handler will execute/complete.
    $UI_JobScript =
    try{
    Function New-Form ([XML]$XAML_Form){
    $XML_Node_Reader=(New-Object System.Xml.XmlNodeReader $XAML_Form)
    [Windows.Markup.XamlReader]::Load($XML_Node_Reader)
    try{
    Add-Type –AssemblyName PresentationFramework
    Add-Type –AssemblyName PresentationCore
    Add-Type –AssemblyName WindowsBase
    catch{
    Throw "Unable to load the requisite Windows Presentation Foundation assemblies. Please verify that the .NET Framework 3.5 Service Pack 1 or later is installed on this system."
    $Form = New-Form -XAML_Form $SyncHash.XAML_Form
    $SyncHash.Form = $Form
    $SyncHash.CMB_Services = $SyncHash.Form.FindName("CMB_Services")
    $SyncHash.TXT_Output = $SyncHash.Form.FindName("TXT_Output")
    $SyncHash.Form.ShowDialog() | Out-Null
    $SyncHash.Error = $Error
    catch{
    write-host $_.Exception.Message
    #End UI_JobScript
    #Begin Main
    add-type -AssemblyName WindowsBase
    [XML]$XAML_Form = @"
    <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Window.Resources>
    <DataTemplate x:Key="DTMPL_Name">
    <TextBlock Text="{Binding Path=Name}" />
    </DataTemplate>
    </Window.Resources>
    <DockPanel LastChildFill="True">
    <StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
    <Label Name="LBL_Services" Content="Services:" />
    <ComboBox Name="CMB_Services" ItemTemplate="{StaticResource DTMPL_Name}"/>
    </StackPanel>
    <TextBox Name="TXT_Output"/>
    </DockPanel>
    </Window>
    $SyncHash = [hashtable]::Synchronized(@{})
    $SyncHash.Add("XAML_Form",$XAML_Form)
    $SyncHash.Add("InitialScript", $InitialScript)
    $Normal = [System.Windows.Threading.DispatcherPriority]::Normal
    $UI_Runspace =[RunspaceFactory]::CreateRunspace()
    $UI_Runspace.ApartmentState = [System.Threading.ApartmentState]::STA
    $UI_Runspace.ThreadOptions = [System.Management.Automation.Runspaces.PSThreadOptions]::ReuseThread
    $UI_Runspace.Open()
    $UI_Runspace.SessionStateProxy.SetVariable("SyncHash",$SyncHash)
    $UI_Pipeline = [PowerShell]::Create()
    $UI_Pipeline.Runspace=$UI_Runspace
    $UI_Pipeline.AddScript($UI_JobScript) | out-Null
    $Job = $UI_Pipeline.BeginInvoke()
    $SyncHash.ServiceList = get-service | select name, status | Sort-Object -Property Name
    Function Update-Combobox{
    write-host "`nBegin Update-Combobox [$(get-date)]"
    $SyncHash.CMB_Services.Dispatcher.Invoke($Normal,[action]{$SyncHash.CMB_Services.ItemsSource = $SyncHash.ServiceList})
    $SyncHash.CMB_Services.Dispatcher.Invoke($Normal,[action]{$SyncHash.CMB_Services.SelectedIndex = 0})
    write-host "`End Update-Combobox [$(get-date)]"
    Function Update-Textbox([string]$Value){
    write-host "`nBegin Update-Textbox [$(get-date)]"
    $SyncHash.TXT_Output.Dispatcher.Invoke("Send",[action]{$SyncHash.TXT_Output.Text = $Value})
    write-host "End Update-Textbox [$(get-date)]"
    Function Read-Textbox(){
    write-host "`nBegin Read-Textbox [$(get-date)]"
    $SyncHash.TXT_Output.Dispatcher.Invoke($Normal,[action]{$Global:Return = $SyncHash.TXT_Output.Text})
    $Global:Return
    remove-variable -Name Return -scope Global
    write-host "End Read-Textbox [$(get-date)]"
    #Give the form some time to load in the other runspace
    $MaxWaitCycles = 5
    while (($SyncHash.Form.IsInitialized -eq $Null)-and ($MaxWaitCycles -gt 0)){
    Start-Sleep -Milliseconds 200
    $MaxWaitCycles--
    Update-ComboBox
    Update-Textbox -Value $("Initial Load: $(get-date)")
    Write-Host "Value Read From Textbox: $(Read-TextBox)"
    Register-ObjectEvent -InputObject $SyncHash.CMB_Services -EventName SelectionChanged -SourceIdentifier "CMB_Services.SelectionChanged" -action {Update-Textbox -Value $("From Selection Changed Event: $(get-date)")}

    Thanks again for the responses. This may not be possible, but I thought I would throw it out there. I appreciate your help in looking into this.
    To clarify the "Respond to control events in the main runspace"... I'm would like to have an event generated by a form object in the UI runspace (ex: combo box selectionchanged event) trigger a delegate within the main runspace and have that delegate in
    the main runspace update the form in the UI runspace.
    ex:
    1.) User changes selection on combo box generating form event
    2.) Event calls delegate (which I have gotten to work)
    3.) Delegate does some basic processing (works)
    4.) Delegate attempts to update form in UI runspace (hangs)
    As to the delegates / which runspace they are running in. I see the $synchash variable if I run get-var within a delegate, but I do not see the $Form variable so I am assuming that they are in the main runspace. Do you agree with that assumption?

  • Reading files from within helper classes

    From within a servlet, I can get the servlet context to get a path to the "web" directory of my project and easily access properties files for my project. If I create another package in my project to hold helper classes that perform some specific function and want to create and/or read from a properties file, I get a path to the bin directory of my servlet container:
    Servlet Path: D:\Documents and Settings\Josh\My Documents\Josh\Projects\ServletSandBox\build\web\
    Helper Class File Path: D:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\bin\test
    I'd like to develop my helper packages as reusable APIs, so they're not tied directly to my project or to a servlet in general, but I'd like the properties files to stay somewhere in my project folder, preferably in the WEB-INF directory with the servlet's own specific properties file.
    I can't figure out the best way to handle this. I wanted to just be able to pass the helper class a String if somebody wanted to specify a filename other than the default filename. Does it make sense to specify a file URL instead? Is there any other way to get the calling servlet's context path without having to pass in a variable?
    Thanks

    It seems that the helper API shouldn't need to be given a path to its own config file. I would like to have code that will load the file regardless of whether or not its in a stand alone java app or a servlet. Whenever the helper API is jarred up and imported into my servlet, it can't find the config file unless it's in the "D:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\bin\test" directory. OR, if I use the current thread to get the loader, it will locate it in the "classes" folder, which is the only solution I can come up with that will let me write code to load the file that will work, regardless of its implementation.
    The "project" folder I'm talking about is just the NetBeans "project" folder for the servlet, or the "ServetSandBox" folder in my example. I guess that doesn't really matter in the context of the servlet though.
    So is using the current thread the appropriate way to do this? When you say that code will work if I put the resource in the WEB-INF directory, that seems to only be true if I try to load it from the servlet itself, not the helper class. The helper class doesn't find the resource in the WEB-INF directory.
    Also, I would like to be able to write the default values to a new config file if one doesn't exist. How in the heck do I get a pointer to the "classes" folder, or any other folder that I can also read from using the classloader, so I can write to a new file?

Maybe you are looking for

  • XMl Publisher Preview Error

    Hi, We are using Oracle application 11.5.10 and I installed the BI Publisher Desktop 5.6.3. I developed the template. Loaded the sample .xml file. There are no error when I validate the template. When try to see the preview in PDF document received t

  • How to Populate Values in Report for Fields

    Hi Experts, I have a Report requirement where in I need to Populate values for FROM Period & TO Period based on the user i/p for Quarter variable. For Eg; Fiscal year : 2009 Quarter : 3 Mat     Year         From period    ToPeriod          QTY   A   

  • Camera connection device not recognised

    Bought iPad 2 yesterday and camera connection kit, with express need to upload pictures. When we plug in camera connection get error 'device not recognised' , camera is EOS 350d. Any ideas please?

  • Formatted Search Query for BatchNo

    Dear All, I am using the following query as formated search for Identifying the batches availble during the creation of  Delivary document in a user defined column at row level. When i click on this field it's showing the Batches for the Item with Ze

  • MySQL problem: can't get log-slow-queries to work

    I've edited added the requisite lines to /etc/my.cnf (which is being read on start up): [slowqueries] longquerytime = 5 log-slow-queries=/var/log/mysql-slow-queries.log And I've tried different locations for the log file, and I've chown'd it to :whee