Can't get ClassLoader from static method.

I'm trying to get the ClassLoader within a static method getInstance().
public class PropertyManager {
public static PropertyManager getInstance(String fileName) {
//The following line returns null
ClassLoader cl = (new Object()).getClass().getClassLoader();
URL url = cl.getResource(fileName);
etc...
However if getInstance gets called from e.g. a statless session bean, a null
is returned instead of a valid ClassLoader.
The same code executed from a standalone java program (e.g. from
main(String[] args)) returns a valid ClassLoader
Why does getClassLoader behave differently in WebLogic than in a standalone
java program?
Thanks for you help.
Bernie

Sorry for the confusion. I wrote a couple of more test programs and was able
to confirm that WL behaves exacltly the same as java does. For some reason
my intial tests were messed up...
getClassLoader() executed from a static method always returns null (in WL as
well as in a java standalone program).
In this case ClassLoader.getSystemClassLoader() will return a valid class
loader.
Thanks for your help.
Bernie
"Rob Woollen" <[email protected]> wrote in message
news:[email protected]..
Bernhard Lenz wrote:
I tried that as well, but getClassLoader() still returns null when
executed
in WL.
I'm still not clear how getClassLoader() gets affected by running withinWL.
>>
>
Very odd. Where is this class located? in the server's classpath, in ajar or
war file? Does getClass().getClassLoader work from a non-static method inthis
class?
-- Rob
"Rob Woollen" <[email protected]> wrote in message
news:[email protected]..
You want PropertyManager.class.getClassLoader()
-- Rob
Bernhard Lenz wrote:
I'm trying to get the ClassLoader within a static method
getInstance().
>>>>
public class PropertyManager {
public static PropertyManager getInstance(String fileName) {
//The following line returns null
ClassLoader cl = (new Object()).getClass().getClassLoader();
URL url = cl.getResource(fileName);
etc...
However if getInstance gets called from e.g. a statless sessionbean, a
null
is returned instead of a valid ClassLoader.
The same code executed from a standalone java program (e.g. from
main(String[] args)) returns a valid ClassLoader
Why does getClassLoader behave differently in WebLogic than in astandalone
java program?
Thanks for you help.
Bernie

Similar Messages

  • Accesing database from static method on java collaboration

    Hi *,
    I want cache data from a oracle database in a java collaboratioon when java collaboration is enabled by emanager.
    My java collaboration has a oracleOTD
    I did an static method on java collaboration, but I can't access database from static method.
    Thanks
    Hector

    hi hector,
    this wont work!
    regards chris

  • Can you override a public static method?

    Can you override a public static method?

    A static method belongs to a class, not to a particular object, because you can call them without having an object instantiated. Methods are over rided which are inherited from an object. Since Static methods (although inherited) are not bound to a particular object, are not overridden.
    Though you have a method in the subclass with the same signatures but if you try to call super.____() you will get the error
    non-static variable super cannot be referenced from a static context

  • "Can't get Action from Action Reference"?

    I really can't figure out why I get java.lang.IllegalArgumentException with "Can't get Action from Action Reference: BeanName.actionName" message. I specified all properties in faces-config.xml. Bean and its action names are all checked several times, but I still get that exception. Is it a JSF bug, or my simple mistake? Is there anyone who experienced the same problem?
    I'm using two forms in one page. all components' ids are all different. Only one form generated the exception not regarding the order of the forms. (the one is login form and the other (which doesn't generate exception) is leave-comment form.)
    Here is the form code:
                   <h:form id="loginForm" formName="loginForm" >
                        Login >
                        <h:input_text id="loginUserName" valueRef="UserBean.userName">
                             <f:attribute name="style" value="width:64px;"/>
                        </h:input_text>
                        |
                        Password >
                        <h:input_secret id="loginPassword" valueRef="UserBean.password">
                             <f:attribute name="style" value="width:64px;"/>
                        </h:input_secret>
                        |
                        <h:command_button id="loginSubmit" label="login" commandName="loginSubmit" actionRef="UserBean.loginAction" />
                   </h:form>
    and here is managed-bean part:
    <managed-bean>
         <managed-bean-name>UserBean</manager-bean-name>
              <managed-bean-class>
                   net.gleamynode.notes.http.faces.UserBean
              </managed-bean-class>
              <managed-bean-scope>request</managed-bean-scope>
    <managed-property>
    <property-name>idStr</property-name>
    <null-value/>
    </managed-property>
    <managed-property>
    <property-name>userName</property-name>
    <null-value/>
    </managed-property>
              <managed-property>
                   <property-name>password</property-name>
                   <null-value/>
              </managed-property>
         </managed-bean>
    Thanks in advance!

    here goes the source code of NotesBean:
    abstract class NotesBean {
         protected static final String SUCCESS = "success";
         protected static final String FAILURE = "failure";
         private String connectionProfile;
         protected NotesBean() {}
         public String getConnectionProfile() {
              return connectionProfile;
         public void setConnectionProfile(String newProfileName) {
              connectionProfile = newProfileName;
         public abstract Action getCreateAction();
         public abstract Action getDeleteAction();
         public abstract Action getUpdateAction();
         protected Connection getConnection() throws NotesException {
              ConnectionProfile profile = ConnectionProfileFactory.getProfile(connectionProfile);
              return DriverManager.getConnection(profile.getUrl(), profile.getProperties());
    }I think everything is ok with the beans, right?
    By the way: shouldn�t the error message be:
    "Can't get Action from Action Reference: UserBean.loginAction"I just examplified the message using somewhat generic name. Sorry for confusion :)
    As a final try, here is the whole JSP code: (ignore korean texts)
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://gleamynode.net/notes" prefix="notes" %>
    <html>
    <head>
         <title>gleamynode.net :: gathering of my mentality</title>
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
         <link rel="stylesheet" HREF="css/gleamynode.css" type="text/css" />
    </head>
    <body>
    <f:use_faces>
    <notes:useNotes>
         <c:choose>
              <c:when test="${empty param['id']}">
                   <notes:getPages var="pages" />
                   <c:forEach var="p" items="${pages}" begin="0" end="0">
                        <c:set var="p" value="${p}" scope="request"/>
                   </c:forEach>
              </c:when>
              <c:otherwise>
                   <notes:getPage var="p" pageId="${param['id']}" />
              </c:otherwise>
         </c:choose>
         <div id="header">
              <h:command_hyperlink href="index.jsp" label="gleamynode.net :: gathering of my mentality"/>
         </div>
         <div id="menu">
              About | Essays | Projects | Others | Links
         </div>
         <div id="content">
              <div id="page">
                   <div id="pageTitle">
                        #${p.id}. ${p.title}
                   </div>
                   <div id="pageContent">
                        ${p.content}
                        <div id="pageTimestamp">
                             ${p.timestamp}
                        </div>
                   </div>
              </div>
              <c:choose>
                   <c:when test="${fn:length(p.comments) > 0}">
                        <div id="comments">
                             <div id="teaser">
                                  ${fn:length(p.comments)} ?? ??? ????
                             </div>
                             <c:forEach var="c" items="${p.comments}">
                                  <div id="commentHeader">
                                       #${c.id}. ${c.userName}
                                  </div>
                                  <div id="commentContent">
                                       ${c.content}
                                       <div id="commentTimestamp">
                                            ${c.timestamp}
                                       </div>
                                  </div>
                             </c:forEach>
                        </div>
                   </c:when>
              </c:choose>
              <div id="commentForm">
                   <jsp:useBean id="CommentBean" class="net.gleamynode.notes.http.faces.CommentBean" scope="request" />
                   <jsp:setProperty name="CommentBean" property="pageIdStr" value="${p.id}"/>
                   <jsp:setProperty name="CommentBean" property="content" value=""/>
                   <div id="teaser">
                   </div>
                   <h:form id="commmentForm" formName="commentForm" >
                        <input type="hidden" name="id" value="${p.id}"/>
                        <h:input_hidden id="pageId" valueRef="CommentBean.pageIdStr"/>
                        <table width="95%">
                             <tr>
                                  <td class="name" width="9%">Name:</td>
                                  <td class="value" width="25%">
                                       <h:input_text id="userName" valueRef="CommentBean.userName">
                                            <f:attribute name="style" value="width:75%;"/>
                                       </h:input_text>
                                  </td>
                                  <td class="name" width="8%">Email:</td>
                                  <td class="value" width="25%">
                                       <h:input_text id="userEmail" valueRef="CommentBean.userEmail">
                                            <f:attribute name="style" value="width:75%;"/>
                                       </h:input_text>
                                  </td>
                                  <td class="name" width="8%">URL:</td>
                                  <td class="value" width="25%">
                                       <h:input_text id="userURL" valueRef="CommentBean.userURL">
                                            <f:attribute name="style" value="width:100%;"/>
                                       </h:input_text>
                                  </td>
                             </tr>
                             <tr>
                                  <td colspan="6">
                                       <h:input_textarea id="content" valueRef="CommentBean.content">
                                            <f:attribute name="style" value="width:100%; height: 12em;"/>
                                       </h:input_textarea>
                                  </td>
                             </tr>
                             <tr>
                                  <td class="buttons" colspan="6">
                                       <h:command_button id="submit" label="leave a comment" commandName="submit" actionRef="CommentBean.createAction" />
                                  </td>
                             </tr>
                        </table>
                   </h:form>
              </div>
              <div id="loginForm">
                   <div id="teaser">
                   </div>
                   <h:form id="loginForm" formName="loginForm" >
                        Login >
                        <h:input_text id="loginUserName" valueRef="UserBean.userName">
                             <f:attribute name="style" value="width:64px;"/>
                        </h:input_text>
                        |
                        Password >
                        <h:input_secret id="loginPassword" valueRef="UserBean.password">
                             <f:attribute name="style" value="width:64px;"/>
                        </h:input_secret>
                        |
                        <h:command_button id="loginSubmit" label="login" commandName="loginSubmit" actionRef="UserBean.loginAction" />
                   </h:form>
              </div>
              <div id="copyright">
                   Copyright � 1999~ by Trustin Lee, All Rights Reserved.
              </div>
         </div>
         <div id="footer">
         </div>
    </notes:useNotes>
    </f:use_faces>
    </body>
    </html>and, here is the whole faces-config.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE faces-config PUBLIC
              "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
              "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
    <faces-config>
        <navigation-rule>
            <from-tree-id>/index.jsp</from-tree-id>
            <navigation-case>
                <from-outcome>success</from-outcome>
                <to-tree-id>/index.jsp</to-tree-id>
            </navigation-case>
            <navigation-case>
                <from-outcome>failure</from-outcome>
                <to-tree-id>/failure.jsp</to-tree-id>
            </navigation-case>
        </navigation-rule>
         <managed-bean>
              <managed-bean-name>PageBean</managed-bean-name>
              <managed-bean-class>
                   net.gleamynode.notes.http.faces.PageBean
              </managed-bean-class>
              <managed-bean-scope>request</managed-bean-scope>
            <managed-property>
                <property-name>idStr</property-name>
                <null-value/>
            </managed-property>
              <managed-property>
                   <property-name>title</property-name>
                   <null-value/>
              </managed-property>
              <managed-property>
                   <property-name>content</property-name>
                   <null-value/>
              </managed-property>
         </managed-bean>
         <managed-bean>
              <managed-bean-name>CommentBean</managed-bean-name>
              <managed-bean-class>
                   net.gleamynode.notes.http.faces.CommentBean
              </managed-bean-class>
              <managed-bean-scope>request</managed-bean-scope>
            <managed-property>
                <property-name>idStr</property-name>
                <null-value/>
            </managed-property>
            <managed-property>
                <property-name>pageIdStr</property-name>
                <null-value/>
            </managed-property>
              <managed-property>
                   <property-name>userName</property-name>
                   <null-value/>
              </managed-property>
              <managed-property>
                   <property-name>userEmail</property-name>
                   <null-value/>
              </managed-property>
              <managed-property>
                   <property-name>userURL</property-name>
                   <null-value/>
              </managed-property>
              <managed-property>
                   <property-name>content</property-name>
                   <null-value/>
              </managed-property>
         </managed-bean>
        <managed-bean>
             <managed-bean-name>UserBean</manager-bean-name>
              <managed-bean-class>
                   net.gleamynode.notes.http.faces.UserBean
              </managed-bean-class>
              <managed-bean-scope>request</managed-bean-scope>
            <managed-property>
                <property-name>idStr</property-name>
                <null-value/>
            </managed-property>
            <managed-property>
                <property-name>userName</property-name>
                <null-value/>
            </managed-property>
              <managed-property>
                   <property-name>password</property-name>
                   <null-value/>
              </managed-property>
         </managed-bean>
    </faces-config>Thank you for your continuous help, Rene! Learned alot from you about JSF :)

  • Problem with calling dispose() from static method

    I have one class, where I have this:
    EditorWindow.disposeWindow();and class EditorWindow, where I have static method
    protected static void disposeWindow() {
        dispose();
    }But, dispose() cant be called from static method. Is there any way to hide or close the EditorWindow window?

    kaneeec wrote:
    I dont have references of these windows, because it would be too difficult. They are created just by new Window().setVisible(true);It's not difficult:
    Window w = new Window();
    w.setVisible(true);Now you have a reference (w) to your window that you can later call dispose() on.
    w.dispose();dispose() isn't a static method, so you have no choice but to call it on a specific instance.

  • Found an error related to "can't get video from Camera"

    So, I am back with the same issue: it is now 3-4 months I can't Video chat because iChat AV tells me "can't get video from camera". I disable the firewall (for the test), I forwarded nearly ALL the TCP and UDP packets from my router to the mac, I stopped any application such as PostgreSQL or others which might interfeer. I checked I didn't have any strange firewall rules still on even when switched of from UserPreferences (sudo ipfw list)...
    Well, I can see myself with the camera but it won't get the image of the party I am connecting to. So... I looked in the console and:
    2006-03-04 19:09:14.926 iChat[9245] WARNING: Freeze-frame failed: couldn't get local buffer for layer Local!
    Each time, this is the message.
    I did the downgrade Quicktime test I also reinstalled the combined update... nothing worked.
    It seems CRAZY that nobody at Apple can at least tell me WHERE to have a look. After all the message is not very clear. Where is the problem? My mac, my router, iChat?
    I filed a bug BTW... because it DID work in the past and now stoped working, so my netgear router can't be in fault (I also checked the logs of the router and of the firewall... nothing seemed to be stoped)
    Alex

    Hi Alexander,
    Defcom aslo has a Netgear And I will let him come back on that side.
    On the error front iChat has about 4 standard messages.
    1) User did not Respond.
    2) Insufficient Bandwidth.
    3) Can not get Video from Camera
    4) Did not get data for 10 secs
    Unfortunately the causes can overlap, hence the lack of Ahaa !!
    The most common feature of all of them is something to do with the way the routing devices are set up.
    This leads us to start with the LAN set up,
    The ports that are open,
    the method used to open them,
    Whether DHCP is being used with Port Forwarding as the IP can change to your computer and the Port Forwarding point to the "wrong" IP
    How many devices are in the link to the Internet ?
    IF you are doing NAT (Port Forwarding or Port Triggering) ?
    Whether your ISP has started dong NAT to your service
    Whether they offer a SIP based Service like VoIP phones.
    11:29 PM Monday; March 6, 2006

  • Can we get data from business views  in CR 2008/XI?

    Hi All,
    Can we get data from business views  in CR 2008/XI?
    If its possible, pls let us know how to get connect with Business View in both of these versions and what is the tool that we have to use to create Business Views.
    Thank you,
    Krishna Pingali

    Hi Krishna,
    Crystal Reports/BusinessObjects Enterprise ( BOE ) Business Views can only be created using the BV build which comes with BOE and installed using the Work Station installer for BOE. for both XI and 2008.
    You cannot mix these two versions on the same PC not can one talk to the other, the BV designer must match the same version as BOE. XI ( version 11.0 ) is no longer available but if you mean XI R2 ( version 11.5 ) then it still is.
    It's not completely clear which Business View you are referring to? BOE has a Business View Designer so not sure if this is just a naming problem or not? If you are referring to the BOE Business View Designer then the above is true. If your reference is about some other BV designer or data source then you need to clarify.
    Contact our Sales department for pricing and availability.
    Thank you
    Don

  • How can I get values from listbox?

    Hi all,
    I need to get price values from Price List (Inventory -> Item Master Data screen). It's important to get values from field 'Price' BEFORE item will be added/updated.
    How can I get values from Pricelist listbox?
    Thanks for any suggestions or short sample code.
    Best regards,
    Andy

    Hi Andy
    Here is som sample code that will get the description of the price list and also the price that is displaying at the time. The item master must be open for this snippet of code
      Public Sub GetItemPriceFromOpenWindow()
            'this is assuming item master is open
            Dim oEdit As SAPbouiCOM.EditText
            oEdit = SBO_Application.Forms.GetForm("150", 1).Items.Item("34").Specific
            SBO_Application.MessageBox(oEdit.Value)
            Dim oCmb As SAPbouiCOM.ComboBox
            oCmb = SBO_Application.Forms.GetForm("150", 1).Items.Item("24").Specific
            SBO_Application.MessageBox(oCmb.Selected.Description)
        End Sub
    Hope it helps

  • HT203167 lost my hard drive how can i get songs from ipod back to new computer

    I lost my hard drive and want to get my music back on my new computer. How can I get songs from my ipod to my computer? I am afraid to sync it and losing what is on my ipod. Any help would be appreciated.

    It has always been very basic to always maintain a backup copy of your computer for this very occasion.
    Use your backup copy to put everything back.
    If for some reason you have failed to maintain a backup, not good, then you can transfer itunes purchases from your ipod:  File>Transfer Purchases

  • How can I get Data from the Sound cart in Labview? Does a VI exist?

    How can I get Data from the Sound cart in Labview? Does a VI exist?

    Yes, there are VIs for acquiring data from Sound cards. And examples too. If you don't have LabVIEW yet, do a search on NI's site for example VIs.
    Khalid

  • Can't get playlists from one one computer to another.  Confident Home Sharing is turned on correctly.  Have imac and macbook Air and Lion.  Using smart lists.

    Can't get playlists from one one computer to another.  Confident Home Sharing is turned on correctly.  Have imac and macbook Air and Lion.  Using smart lists.

    Using Ethernet, I am attempting to stream the movies on my computer to my girlfriends computer through iTunes home sharing. I want to watch the movies that are on one computer on another.

  • Anybody had an issues with mail since upgrading to mountain lion? Can't get emails from one account, tried deleting and recreating but to no avail. Set up a new user and it works fine. Macbook pro 13" mid 2010 model.

    Anybody had an issues with mail since upgrading to mountain lion? Can't get emails from one account, tried deleting and recreating but to no avail. Set up a new user and it works fine. Macbook pro 13" mid 2010 model.

    Anybody had an issues with mail since upgrading to mountain lion? Can't get emails from one account, tried deleting and recreating but to no avail. Set up a new user and it works fine. Macbook pro 13" mid 2010 model.

  • How can i get contacts from my old Nokia phone to iphone 4S

    how can i get contacts from my old Nokia phone to iphone 4S?

    Appreciate the reply thank you
    Issue being is I don't have the lead for the samsung any longer but have the memory card?
    An yes I know I need to get them onto my MAC but how is what i'm struggling with?
    Any help would be appreciated.
    Many thanks

  • How can i get data from another database SQL Server use database link from

    I have a database link from Oracle connect to SQL Server database with user cdit connect default database NorthWind.How can I get data from another database(this database in this SQL Server use this database link)?

    hi,
    u should see following documentation:
    Oracle9i Heterogeneous Connectivity Administrator's Guide
    Release 1 (9.0.1)
    Part Number A88789_01
    in it u just go to chapter no. 4 (using the gateway),,u'll find ur answer there.
    regards
    umar

  • How can I get music from old mac to new mac?

    How can I get music from old mac to new mac please?
    Can't seem to make Migration Assistant work. Doesn't ask about or transfer files.

    I just migrated into a new MBP from an old one.
    It did not bring the music over.  Apple's instructions are to use the Home Sharing feature of iTunes.
    Open iTunes on your old Mac.  Select Home Sharing under the Advanced menu.  Sign in.  Do the same on your new computer.  Then when the library appears under Home Sharing on the left-hand panel on your new computer's iTunes, you can select all and Add To Library.
    That's what Apple says, anyway.

Maybe you are looking for