Loading an object using a different classloader

I have 2 web-apps which share a common object. I want to store that
common object in a common cache accessible to both web-apps. The problem
is the 2 web-apps have a different classloader, so how do I return an
object that was stored by web-app1 to be used with web-app2 without getting a ClassCastException
-

First question is whether the Web-Apps are on the same JVM - if you're using Tomcat, it is likely that they are. The next question is whether the Web-Apps' classloaders descend from a common parent classloader - again in Tomcat this is the case. If they do, then you should use the common parent classloader to instantiate the classes that need to be shared.
To do this, you need to add the common classes to either the system classpath or to the classpath configured for your servlet/jsp engine. If the Web-Apps' classloaders are standard they will defer any requests initially to their parent classloader which will provide them with the same class definition and make it so that these classes can be shared between the Web-Apps.
Now comes the nitty-gritty of implementation. The best way to share a common object is via a static instance in one of the classes loaded by the parent classloader, using the singleton pattern or the like.
A trivial example would be if you wanted to hold a map of common (thread-safe) objects:public class Shared{
    private static java.util.HashMap sharedMap;
    static{
        // Thread safe, assuming all shared objects are initialised
        // in this static block.
        // If objects are to be created and placed in the
        // sharedMap later, use the synchronized map wrapping
        // methods from the Collections utility class.
        sharedMap = new java.util.HashMap();
        ... //instantiate and store the shared objecs here.
    public static Object getCommonObject(String key){
        return sharedMap.get(key);
}As long as the Shared class comes from an ancestral classloader, both Web-Apps will see the same map of the same objects.
Hope this helps,
Bob B.

Similar Messages

  • Using XMLParser as a single object used by different threads

    Hi,
    I'm trying to use the XMLParser object as a parser used by
    several different objects, probably running under separate
    threads.
    Each such object will implement its own callback, the idea being
    that the callback supplied to the parser upon initialization,
    will actually call the callback implemented by the object that
    called parse. I thought about doing this by using the "context"
    passed to the XMLParser, if I could change it after
    initialization and before each call to XMLParser.parse that I
    would be able to switch between calling objects, and thus allow
    multiple threads to use the same parser.
    The problem here is that the SAX callback implementation
    functions are defined "extern C" and I can't get them in the
    context of an object.
    Is there any way at all to accomplish this?
    Thanks
    J Galore

    Hi,
    You can use "select for update" to lock this row but locking means other sessions will hang and wait until lock is released. If this is ok for you, go for it.
    Other option is to use a flag column which you should set to "1" so that other threads don't use the row with flag vlaue "1"
    Salman

  • Why do vector objects use a different GUI to set colours?

    While teaching Photoshop in a class of mine, I noticed that in CS6 vector objects's colours remain unaffected by the main colour controls, and we have to switch to the object selection tool to display the colour controls in the properties bar.
    Now, this feels very, very disjointed - why would one introduce such a disconnect in the overall user interface? Why not just use the ordinary colour controls? I mean, trying to pick up the colour from a bitmap layer for a vector object takes five steps now: select object with object selection tool, click on the fill button in the properties bar, click on the colour picker, then we can pick up a colour from the image, anc finally click to confirm. And the colour change only gets applied after clicking "okay". No realtime feedback. Have to repeat the last three steps again and again to test for different colours.
    Wow. Just... Wow. :-(
    The Colour swatch palette does not work either with vector objects. Nor the eye dropper tool! Just plain silly, if you ask me.
    Quite a bad workflow, or am I missing something here?
    I compare this to Photoline, where the overall colour controls govern all types of objects, including vector layers and bitmap layers the same way, and with instant feedback. Photoshop CS6's colour picking workflow for vector objects looks extremely convoluted compared.
    Has this workflow been improved at all in Photoshop CC?

    @ JJMack: I used Photoshop in a professional manner since version 3, so I am sort of privy to its overall development throughout the years. ;-)
    My intention is not to start a comparison between Photoline and Photoshop - both have their caveats and benefits. I stopped using Photoshop 9 months ago and switched to Photoline, and on overall, I much prefer PL's workflow now for image editing and compositing. (Comparing Elements with PL is not really a fair fight - PL's feature set, aside from the 3d, scripting, and video components, is 95% feature identical with Photoshop).
    The main reason I still have Photoshop in my professional life is not due to missing features in the alternatives I now use compared to Photoshop (as a matter of fact the combined power of the alternatives are superior in terms of provided features), but merely because the students I teach are taught the "industry standard", and I keep up knowledge-wise.
    Anyway, I am not expecting Photoshop to encompass the same functionality as Illustrator, nor do I want to compare Photoline's vector drawing tools to a dedicated vector illustration package. I am, however, experienced enough as a user (and a UX designer myself) to identify some very odd fragmented user interface behaviours in software.
    The new vector shapes are a very welcome recent addition in PH, though I question the strange disconnected implementation.

  • BW variable: Inconsistent in loading. please check use of deleted objects

    Hi Experts,
    I encountered an error and can not solve it following OSS note.
    When I create a variable in query definition for an infoobject, it prompts an error dialog 'Inconsistent in loading. please check use of deleted objects'.
    I checked the OSS notes 792779, there is a such description:
    The variable existing in the table RSZGLOBV, but not existing in the tables RSZELTDIR or RSZCOMPDIR have inconsistent definition. These situation may return 2 different error messages. When a variable is missing in RSZELTDIR table (or in both together), an attempt to expand a list of variable under a corresponding InfoProvider or a list of text/formula variables will return a message 'Inconsistency in loading...'. All variables which are created for corresponding InfoProvider, text/formula variable are not available. When a variable is missing in the RSZCOMPDIR table only the error message is 'Missing UID XXXXXX... in RSZCOMPDIR! You may continue to work, but this component is not loaded' in Query Designer
    But I checked these tables RSZGLOBV and RSZELTDIR and RSZCOMPDIR. I can find a variable for this infoobject, such as TC_SREG, in these tables. That is, this variable should be availbale in the query definition.
    I don't know why.
    My sap bw is 3.1, without the program 'ANALYZE_RSZ_TABLES'.
    Many thanks for you help.

    Hi,
    While installing business content make grouping as Data Flow before and collection mode as 'Automatic'.  Then expand the Tree in the tree you can see Info Object Catalogue.  All installed and activated object will be in green (Active Mode). those will be normally unchecked to install anyway cross check and if found anything check deselect them.  Go for Simulation Installation to identify unforeseen errors.  Install the same and activate entire data-flow.
    Hope your issue will be resolve
    Thanks
    BVR

  • I created a pdf form and then iported it to Forms Central for distribute. It is now loaded to my website and setup so a person clicks on the link to open the form. At this point they then have to go to upper right to open form using a different view. I wo

    I created a pdf form and then imported it to Forms Central for distribute. It is now loaded to my website and setup so a person clicks on the link to open the form. At this point they then have to go to upper right to open form using a different view. I would like the form to open directly in Adobe Reader form to make it easier to enter information. Thanks, Ike

    If you created it in Forms Central, you have to edit it there. I believe Forms Central is similar to LiveCycle Designer in that the form created is no longer able to be edited in Acrobat. I might be wrong, but that is my understanding. You add the submit button in Forms Central. Within Acrobat, you should be able to go to the forms menu and Manage Data to save the data to an Excel file. Others better with forms should be by to clarify things, but this should get you started. In the future you might find it better to post a forms question in the forms discussions.

  • How to load an applet using custom classloader ?

    Hi All,
    How to load an applet using custom classloader rather than using default browsers classloader i.e AppletClassLoader usually ?
    Regards,
    Kumar.

    I would guess that that would require two applets.
    The first does nothing but create the custom class loader and then load the second applet.

  • Tal Mngt Area of Responsibility - use of different object from OrgUnit

    Hi all,
    One of my clients has a requirement to use a different object from an OrgUnit as the Area of Responsibility (e.g. S A 741 O > S A 741 01 where 01 is a new object). Basically, 01 is an OrgArea object that is linked to one or more OrgUnits and some positions.
    My initial thought is that is such an integral part of EhP4 Talent Management security that it would not be possible. Therefore, if anybody knows differently please tell!
    Many thanks in advance,
    Luke

    >
    Luke Marson wrote:
    > Hi all,
    >
    > One of my clients has a requirement to use a different object from an OrgUnit as the Area of Responsibility (e.g. S A 741 O > S A 741 01 where 01 is a new object). Basically, 01 is an OrgArea object that is linked to one or more OrgUnits and some positions.
    >
    > My initial thought is that is such an integral part of EhP4 Talent Management security that it would not be possible. Therefore, if anybody knows differently please tell!
    >
    > Many thanks in advance,
    >
    > Luke
    Hi Luke, from the OM perspective, relationship perspective all of it could be done.  What would be interesting is that I highly doubt the SAP standard TREX index will work correctly. 
    HRTMC Relation S O Area of Responsibility
    AND
    HRTMC Structural authority
    cool thing to test out though, let us know,.,

  • WAR within EAR is using the same classloader as the EAR

    Hi all,
    From documentation, I understand that each WAR web application that are packaged within EAR should have a separate (child) classloader and should not be using the same classloader as the EAR. I have two WAR files and some JAR files all packaged and deployed as an EAR. Using the Classloader Analysis Tool, I think the two web applications (WARs) are actually using the same classloader as the EAR. I say this because:
    1. The application class loader listed for the web apps has the same hashcode as the class loader listed for the EAR.
    2. I tried to add the <prefer-web-inf-classes> element within the WAR's weblogic.xml file and it doesn't seem to work. The web app is still using classes loaded in the EAR. This is consistent with my observation that the classloader for the WARs has the same hashcode as the classloader for the EAR - therefore I think they are using the same classloader.
    I don't understand this behavior. I thought WARs are supposed to be using different/child classloaders from the EAR by default. Do I have to specifically declare my own customer <classloader-structure> within weblogic-application.xml in order to have child classloaders for the WARs within my EAR?
    Thanks for any help.

    We are doing it currently as we are switching over from Exchange 5.5 to OCS. We set up a profile using the Oracle connector and then go into properties and add the Exchange account. We used this method to move files from the Exchange server to the Oracle server by having both profiles running.

  • Use two different printer services in one web template?

    Hi!
    Is it possible to use two different help services for printing in the same web template (for the same table item)?
    Print1:
    <param name="HELP_SERVICE" value="HELP_SERVICE_PRINT"/>
    <param name="HELP_SERVICE_CLASS" value="ZCL_RSR_XLS_HELP_WINDOW_PRINT"/>
    Print 2:
    <param name="HELP_SERVICE" value="ZPRINTING"/>
    <param name="HELP_SERVICE_CLASS" value="ZBW_PRINT_HELP_SERVICE"/>
    I was thinking that you maybe could change the param name values for the "Help_service" and the "help_service_class" at runtime using the properties for the table item, so that you could choose which one to use, but I havne't been able to do that so far.
    Does anyone have an idea?

    This is not a problem. Just put the print service for the print to excel on an object other than the table web item. As long as these print services exist on any web item, you should be able to invoke them. I've tested this with putting the "Print with Excel" service on the Navigation Block Web Item and the other print service on the table web item. Hope that helps!
    Prakash

  • Sharing object across 2 different web application

    Hello,
         I do not know if this is a right place to ask this kind of question...
         I have two different web applications running on 2 different tomcat servers.
         One of them creates one object ( say myComplexClassObject) which is serializable..
         and I want to share this object in another web applications.
         Both the apps are developed using JSP and servlets.
         Is there any way, I can make this object available in another application ?
         As the request object can not be used across 2 different contexts, I can not set it as attribute on request.
         I tried serializing myComplexClassObject in some test.dat. Problem going by this way is that
         how do I send this file to another application ?
         What I did is as follows....
         In the first app , I created the object and serialized it in one file test.dat. In the same app I read
         test.dat and send the content as query parameter to a JSP in another app. That JSP collects all the query parameters
         and constructs a big string out of it and then writes it to a file, test2.dat and tries to deserialize this.
         File sizes come out to be same. But it gives me StreamCorruptedException.
         Any idea, where I am doing wrong ? or any other way to share this object or to send the file to another app?
         I can not use FTP for some reasons. Size of the test.dat file is more than 10 KB.

    Some possible solutions:
    Use a webservice calls to pass the object,
    Use JAXB to convert the object to XML, pass the XMLover HTTP or a socket and use JAXB to convert the XML back into an object.
    Store the object as a blob in a database.
    Store the object in a Java aware database that can handle Java objects.
    Store the data in the object in a database.
    I am curious as to what information ot functionality is contained in this object that you feel the need to pass it between two servers.

  • Load multiple files using the same data load location

    has anybody tried loading multiple files using the same load locations. I need to do this as the data in these multiple files will need to be exported from FDM as a single export file. the problem i am facing is more user related. since these files will be received at different points of time, users will need a way to tell them what has been loaded and what is yet to be loaded.
    is it possible to throw a window on the web broser with OK and Cancel buttons from an event script?
    any pointers to possible solutions will be helpful

    was able to resolve this. the implementation method is as follows
    take a back up of previously imported data in the befcleardata event script. then in the beffileimport event append the data to the import file. there are many other intricacies but this is the broad implementation logic. it allowed my users to load multiple files without worrying about append or replace import type choices

  • How to use the different class for each screen as well as function.

    Hi Experts,
    How to use the different class for each screen as well as function.
    With BestRegards,
    M.Thippa Reddy.

    Hi ThippaReddy,
    see this sample code
    Public Class ClsMenInBlack
    #Region "Declarations"
        'Class objects
        'UI and Di objects
        Dim objForm As SAPbouiCOM.Form
        'Variables
        Dim strQuery As String
    #End Region
    #Region "Methods"
        Private Function GeRate() As Double
                Return Double
        End Function
    #End Region
    Public Sub SBO_Appln_MenuEvent(ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean)
            If pVal.BeforeAction = True Then
                If pVal.MenuUID = "ENV_Menu_MIB" Then
                End If
            Else ' Before Action False
                End If
        End Sub
    #End Region
    End Class
    End Class
    Rgds
    Micheal
    Vasu Anna Regional Feeling a???? Just Kidding
    Edited by: micheal willis on Jul 27, 2009 5:49 PM
    Edited by: micheal willis on Jul 27, 2009 5:50 PM

  • Using a different Rich Text Editor ?

    Hi,
    I'd like to know if you're using a different Rich Text Editor other than the one provided by Oracle ?
    Are you satisfied with it ? Especially in the management of images ?
    Thanks
    Max.

    there is a textflow component
    http://blog.flexexamples.com/2009/07/25/exporting-a-textflow-object-in-flex-4/
    still exports to font tags unfortunately, but its closer than the richtexteditor. Its basically at the point where you could even write your own small parser and adapt the output to the format you desire.

  • How to backup files to ensure future access and use using a different mac

    I recently attempted access backed up data on my LaCie drive from a different Mac notebook. I was blocked. I didn't write down the message, but it essentially advised that the data was locked and I wasn't allowed access. I wasn't given a chance to enter any kind of system password to bypass the lock.
    Here is my problem: I recently spilled some wine into my keyboard. Since then, the system has slowed to a crawl and occasionally weird things begin to happen, regardless of which software I am using [eg iPhoto, Quickbooks, idvd, Photoshop, email, and even dashboard]. I know I am very lucky to have any access to my files at all. While I do, I need to back everything up so that I can have access to my files later on. I plan to have my Mac serviced this week. I don't know if it needs to be replaced, or whether it can be repaired.
    *+If it can't be repaired, how do I back up my files to ensure future access and use using a different mac?+*

    I'll check the example you linked. I appreciate you responding.
    I was not trying to boot another system at all. Actually, I was working on a newer mac laptop. I attempted to load a dvd I had created in my idvd on the other mac from the LaCie. I was using a mac because I knew it had all the iLife software I needed in order to work with my idvd components. Honestly though, I don't know if the mac I was using is intel based. I hadn't considered it. Does Apple sell macbooks with intel? No matter.
    So, let's see -- I was using the other powerbook to read the LaCie via firewire -- and yes, the LaCie has its own power supply.
    If I remember correctly, the denial I received [when attempting to load the idvd file] knew that I had created it. I got the feeling that it wasn't allowing me into the file for security reasons. I just don't remember setting security. Incidentally, I just checked and I do not have a master password set nor do I have FileVault protection turned on.
    I'll check that link you sent. Thx again, M~

  • How to load the object library at run time from within the script.

    What i am trying to do from my library is that I wanted to load the object library file (.properties) file at run time through the script. I know that open script has a deprecated method "ft.loadObjectLibrary". Is there any other method other than the deprecated one?. Also is there a way that I can unload the library?
    Thanks,
    Sri

    Object.border.fill.color.value = "255,255,255";
    if you want to use rawValue of textfields to insert in there you will have to do
    Object.border.fill.color.value = R.rawValue + "," + G.rawValue + "," + B.rawValue

Maybe you are looking for