SwingUtilities throwing Null Exception

I created the following class to report a bug and came across something interesting:
// Instructions to view bug
// 1) On your favorite windows operated machine (xp in my case) unlock and move your taskbar
//    so that it is along the left pane of your screen.
// 2) Run the following java program
// 3) Maximize the BugCheck window
// 4) Click on the down arrow of the combobox
// 5) You will see the combobox is not dropping to where it should and the dropdown selection text is cutoff.
package com.BugCheck;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
* This simple class will demonstrate a jcombobox being misaligned
* when selected and the user's Windows taskbar is along the LEFT
* side of the screen.
public class BugCheck extends JFrame
    public BugCheck()
        try
            jbInit();
        } catch (Exception ex)
            ex.printStackTrace();
    public static void main(String args[])
        BugCheck f = new BugCheck();
        f.setSize(new Dimension(100, 100));
        f.setVisible(true);
        try {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
            SwingUtilities.updateComponentTreeUI(f);
        } catch (Exception e ) {
            e.printStackTrace();
    private void jbInit() throws Exception
        jComboBox1.addItem("Selection 1");
        jComboBox1.addItem("Selection 2");
        jComboBox1.addItem("Can't");
        jComboBox1.addItem("see");
        jComboBox1.addItem("this.");
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setTitle("BugCheck");
        this.getContentPane().add(jComboBox1, java.awt.BorderLayout.NORTH);
    JComboBox jComboBox1 = new JComboBox();
}I got the exceptions listed below, and after some fiddling it turns out the culprit is the following line of code. When commented out, the exceptions do not happen.
this.getContentPane().add(jComboBox1, java.awt.BorderLayout.NORTH);is causing these exceptions to be thrown:
"C:\Program Files\Java\j2re1.4.2_07\bin\javaw" -classpath "H:\BugCheck\classes;C:\Program Files\Java\j2re1.4.2_07\javaws\javaws.jar;C:\Program Files\Java\j2re1.4.2_07\lib\charsets.jar;C:\Program Files\Java\j2re1.4.2_07\lib\ext\dnsns.jar;C:\Program Files\Java\j2re1.4.2_07\lib\ext\ldapsec.jar;C:\Program Files\Java\j2re1.4.2_07\lib\ext\localedata.jar;C:\Program Files\Java\j2re1.4.2_07\lib\ext\sunjce_provider.jar;C:\Program Files\Java\j2re1.4.2_07\lib\im\indicim.jar;C:\Program Files\Java\j2re1.4.2_07\lib\im\thaiim.jar;C:\Program Files\Java\j2re1.4.2_07\lib\jce.jar;C:\Program Files\Java\j2re1.4.2_07\lib\jsse.jar;C:\Program Files\Java\j2re1.4.2_07\lib\plugin.jar;C:\Program Files\Java\j2re1.4.2_07\lib\rt.jar;C:\Program Files\Java\j2re1.4.2_07\lib\sunrsasign.jar"  com.BugCheck.BugCheck
java.lang.NullPointerException
     at javax.swing.DefaultListCellRenderer.getListCellRendererComponent(Unknown Source)
     at javax.swing.plaf.basic.BasicComboBoxUI.getDisplaySize(Unknown Source)
     at javax.swing.plaf.basic.BasicComboBoxUI.getMinimumSize(Unknown Source)
     at javax.swing.plaf.basic.BasicComboBoxUI.getPreferredSize(Unknown Source)
     at javax.swing.JComponent.getPreferredSize(Unknown Source)
     at java.awt.BorderLayout.layoutContainer(Unknown Source)
     at java.awt.Container.layout(Unknown Source)
     at java.awt.Container.doLayout(Unknown Source)
     at java.awt.Container.validateTree(Unknown Source)
     at java.awt.Container.validateTree(Unknown Source)
     at java.awt.Container.validateTree(Unknown Source)
     at java.awt.Container.validate(Unknown Source)
     at javax.swing.RepaintManager.validateInvalidComponents(Unknown Source)
     at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
     at java.awt.event.InvocationEvent.dispatch(Unknown Source)
     at java.awt.EventQueue.dispatchEvent(Unknown Source)
     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
     at java.awt.EventDispatchThread.run(Unknown Source)
java.lang.NullPointerException
     at javax.swing.plaf.basic.BasicComboBoxUI.isPopupVisible(Unknown Source)
     at javax.swing.plaf.basic.BasicComboBoxUI.paintCurrentValue(Unknown Source)
     at javax.swing.plaf.basic.BasicComboBoxUI.paint(Unknown Source)
     at javax.swing.plaf.ComponentUI.update(Unknown Source)
     at javax.swing.JComponent.paintComponent(Unknown Source)
     at javax.swing.JComponent.paint(Unknown Source)
     at javax.swing.JComponent.paintWithOffscreenBuffer(Unknown Source)
     at javax.swing.JComponent.paintDoubleBuffered(Unknown Source)
     at javax.swing.JComponent._paintImmediately(Unknown Source)
     at javax.swing.JComponent.paintImmediately(Unknown Source)
     at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
     at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
     at java.awt.event.InvocationEvent.dispatch(Unknown Source)
     at java.awt.EventQueue.dispatchEvent(Unknown Source)
     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
     at java.awt.EventDispatchThread.run(Unknown Source)Any comments?

Some thoughts, 1) eliminate all those unnecessary jar
files from your classpath 2) add the bin directory of
the jdk to your PATH variable and call the java
command directly for simplicity ... 3) Only include
on your classpath any jar files that you have created
for your application or 3rd party jar files. In your
example it doesn't look like you need to include any
jar files. 4) I also notice that your package name
and class name are the same. Generally package names
are lower case and Class names are upper case.
java com.bugcheck.BugCheck
None of these address the issue at hand. Although I do commend you for being nitpicky!
Suprisingly, running the same program with Java 1.4.2 b5 (the OP was done with 1.4.2 b7) gives more informaton:
[code
java.lang.NullPointerException
     at javax.swing.DefaultListCellRenderer.getListCellRendererComponent(DefaultListCellRenderer.java:80)
     at javax.swing.plaf.basic.BasicComboBoxUI.getDisplaySize(BasicComboBoxUI.java:1275)
     at javax.swing.plaf.basic.BasicComboBoxUI.getMinimumSize(BasicComboBoxUI.java:969)
     at javax.swing.plaf.basic.BasicComboBoxUI.getPreferredSize(BasicComboBoxUI.java:959)
     at javax.swing.JComponent.getPreferredSize(JComponent.java:1275)
     at java.awt.BorderLayout.layoutContainer(BorderLayout.java:668)
     at java.awt.Container.layout(Container.java:1020)
     at java.awt.Container.doLayout(Container.java:1010)
     at java.awt.Container.validateTree(Container.java:1092)
     at java.awt.Container.validateTree(Container.java:1099)
     at java.awt.Container.validateTree(Container.java:1099)
     at java.awt.Container.validate(Container.java:1067)
     at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:353)
     at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:116)
     at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
     at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
     at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
java.lang.NullPointerException
     at javax.swing.plaf.basic.BasicComboBoxUI.isPopupVisible(BasicComboBoxUI.java:919)
     at javax.swing.plaf.basic.BasicComboBoxUI.paintCurrentValue(BasicComboBoxUI.java:1148)
     at javax.swing.plaf.basic.BasicComboBoxUI.paint(BasicComboBoxUI.java:954)
     at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
     at javax.swing.JComponent.paintComponent(JComponent.java:541)
     at javax.swing.JComponent.paint(JComponent.java:808)
     at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4787)
     at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4740)
     at javax.swing.JComponent._paintImmediately(JComponent.java:4685)
     at javax.swing.JComponent.paintImmediately(JComponent.java:4488)
     at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410)
     at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)
     at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
     at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
     at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

Similar Messages

  • Class.forName() throws null exception in servlet

    Hi, just wondering if anyone having this similar problem:
    when i try to load a class using Class.forName() method inside a servlet, it throws null exception.
    1) The exception thrown is neither ClassNotFoundException nor any other Error, it's "null" exception.
    2) There's nothing wrong with the code, in fact, the same code has been testing in swing before, works perfectly.
    3) I have include all necessary jars/classes into the path, even if i haven't, it should throw ClassNotFoundException instead, not "null" exception.

    I have tried to detect any possible nullable variable, and it is able to run until line 15. The exception thrown is actually null only... not NullPointerException... which is why i have confused...
    the message i received is "PlugInException: null".
    The code is at follow:
    * Load plugin
    * @return ArrayList of plugins
    * @exception PlugInException PlugInException
    01 public ArrayList loadPlugin()
    02 throws PlugInException
    03 {
    04 PlugIn plugin;
    05 ArrayList plugins = new ArrayList();
    06
    07 for (int i = 0; i < configLoader.getPluginTotal(); i++)
    08 {
    09 try
    10 {
    11 if (debugger > 0)
    12 {
    13 System.out.print("Loading " configLoader.getPluginClass(i) "...");
    14 }
    15 if (Class.forName(configLoader.getPluginClass(i)) == null)
    16 {
    17 if (debugger > 0)
    18 {
    19 System.out.print(" not found");
    20 }
    21 }
    22 else
    23 {
    24 if (debugger > 0)
    25 {
    26 System.out.println(" done");
    27 }
    28 plugin = (PlugIn)(Class.forName(configLoader.getPluginClass(i)).newInstance());
    29 plugin.setContainer(container);
    30 plugins.add(plugin);
    31 }
    32 }
    33 catch (Exception e)
    34 {
    35 throw new PlugInException("PlugIn Exception: " + e.toString());
    36 }
    37 }
    38
    39 return plugins;
    40 }

  • Very strange...server based swf tries to access local working copy code, throws null exception...

    Here's one for the strange folder...
    I have my Flex app.  I build the project and copy the resulting swf to my development (192.168.100.110:511/devportal/) server for testing....this works perfectly fine.
    However, some of my testers see an error (including myself) that is odd.  When I run the swf on the server, for one specific function, I get a null exception error.  What's interesting about it is that the stack trace indicates that the error occurred in my local working copy of code:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
        at apps::AsrUtilization/togglePanel()[C:\Users\eloy91100636\Desktop\Portal\UserInterface\htd ocs\LABPortal\src\apps\AsrUtilization.mxml:722]
        at apps::AsrUtilization/__callPanel_click()[C:\Users\eloy91100636\Desktop\Portal\UserInterfa ce\htdocs\LABPortal\src\apps\AsrUtilization.mxml:933]
    How is it that a swf running on a separate machine blows up trying to reference a function in the working code on my pc?
    And, what's more, is that some people run the swf just fine with no error and it works clean while others encounter this error.  I've cleaned and recompiled the project and it doesn't fix the problem.
    HELP!!!
    Adrian

         Good call on the player types...yes, the one's who don't see the error are running release version, the rest are running debug version.
    Thanks!!!!!
    Adrian

  • JAX-WS Client throws NULL Pointer Exception in NW 7.1 SP3 and higher

    All,
    My JAX-WS client is throwing an exception when attempting to create a client to connect to the calculation service. The exception is coming out of the core JAX-WS classes that are part of NetWeaver. (see exception below)
    Caused by: java.lang.NullPointerException
         at com.sap.engine.services.webservices.espbase.client.jaxws.core.SAPServiceDelegate.createDispatchContextExistingPort(SAPServiceDelegate.java:440)
         at com.sap.engine.services.webservices.espbase.client.jaxws.core.SAPServiceDelegate.createDispatchContext(SAPServiceDelegate.java:475)
         at com.sap.engine.services.webservices.espbase.client.jaxws.core.SAPServiceDelegate.createDispatch(SAPServiceDelegate.java:492)
         at com.sap.engine.services.webservices.espbase.client.jaxws.core.SAPServiceDelegate.createDispatch(SAPServiceDelegate.java:484)
         at javax.xml.ws.Service.createDispatch(Service.java:166)
    I have done some research and it appears that as of NetWeaver 7.1 SP3 SAP stopped using the SUN JAX-WS runtime and implemented their own SAP JAX-WS runtime. I also took the time to decompile the jar file that contained the SAPServiceDelegate class which is throwing the null pointer exception. (see method from SAPServiceDelegate below)
        private ClientConfigurationContext createDispatchContextExistingPort(QName portName, JAXBContext jaxbContext)
            BindingData bindingData;
            InterfaceMapping interfaceMap;
            InterfaceData interfaceData;
            bindingData = clientServiceCtx.getServiceData().getBindingData(portName);
            if(bindingData == null)
                throw new WebServiceException((new StringBuilder()).append("Binding data '").append(portName.toString()).append("' is missing!").toString());
            QName bindingQName = new QName(bindingData.getBindingNamespace(), bindingData.getBindingName());
            interfaceMap = getInterfaceMapping(bindingQName, clientServiceCtx);
            interfaceData = getInterfaceData(interfaceMap.getPortType());
            ClientConfigurationContext result = DynamicServiceImpl.createClientConfiguration(bindingData, interfaceData, interfaceMap, null, jaxbContext, getClass().getClassLoader(), clientServiceCtx, new SOAPTransportBinding(), false, 1);
            return result;
            WebserviceClientException x;
            x;
            throw new WebServiceException(x);
    The exception is being throw on the line where the interfaceMap.getPortType() is being passed into the getInterfaceData method. I checked the getInterfaceMapping method which returns the interfaceMap (line above the line throwing the exception). This method returns NULL if an interface cannot be found. (see getInterfaceMapping method  below)
       public static InterfaceMapping getInterfaceMapping(QName bindingQName, ClientServiceContext context)
            InterfaceMapping interfaces[] = context.getMappingRules().getInterface();
            for(int i = 0; i < interfaces.length; i++)
                if(bindingQName.equals(interfaces<i>.getBindingQName()))
                    return interfaces<i>;
            return null;
    What appears to be happening is that the getInterfaceMapping method returns NULL then the next line in the createDispatchContextExistingPort method attempts to call the getPortType() method on a NULL and throws the Null Pointer Exception.
    I have included the code we use to create a client below. It works fine on all the platforms we support with the exception of NetWeaver 7.1 SP3 and higher (I already checked SP5 as well)
          //Create URL for service WSDL
          URL serviceURL = new URL(null, wsEndpointWSDL);
          //create service qname
          QName serviceQName = new QName(targetNamespace, "WSService");
          //create port qname
          QName portQName = new QName(targetNamespace, "WSPortName");
          //create service
          Service service = Service.create(serviceURL, serviceQName);
          //create dispatch on port
          serviceDispatch = service.createDispatch(portQName, Source.class, Service.Mode.PAYLOAD);
    What do I need to change in order to create a JAX-WS dispatch client on top of the SAP JAX-WS runtime?

    Hi Guys,
    I am getting the same error. Any resolution or updates on this.
    Were you able to fix this error.
    Thanks,
    Yomesh

  • WPUMFactory.getUserFactory() throws null pointer exception

    Hi,
    I am trying to use KM API's to read files from KM repository. I am using the below code as mentioned in the blog: How to download KM documents using Web Dynpro Java
    Below is my code:
    IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
    com.sap.security.api.IUser sapUser = wdClientUser.getSAPUser();
    IUser epUser = WPUMFactory.getUserFactory().getEP5User(sapUser);
    However the line WPUMFactory.getUserFactory() throws null pointer exception. Can some one please help on why these happens as these seems to be the standard code to read a file from KM.
    Thanks.
    Regards,
    Ponraj M

    Hi Ponraj ,
    Instead of fetching the current logged on user , use the below line to set the resource context and see if it helps .
    com.sapportals.wcm.repository.IResourceContext resourceContext = ResourceFactory.getInstance().getServiceContext("cmadmin_service");
    cmadmin_service is a existing user that can be used to access KM resources .
    Regards
    Mayank

  • Weblogic throwing "null SOAP element Exception" in multi-part SOAP response

    Hi All,
    I'm using weblogic 10. My application is a webservice client generated using '*clientgen*', which is running on weblogic, and
    is invoking a remotely hosted webservice ( Remotely hoseted webservice may not be running on weblogic).
    I've the wsdl file of remotely hosted webservice.
    Now the problem is with WSDL file (I suppose), have a look at this.
    *&lt;message name="m1"&gt;*
    *&lt;part name="body" element="tns:GetCompanyInfo"/&gt;*
    *&lt;/message&gt;*
    *&lt;message name="m2"&gt;*
    *&lt;part name="body" element="tns:GetCompanyInfoResult"/&gt;*
    *&lt;part name="docs" type="xsd:AnyComplexType"/&gt; ------&gt; assume all elements inside this complex type can be nil or minOccurs set to '0'*
    *&lt;part name="logo" type="xsd:AnyOtherComplexType"/&gt; ------&gt; assume all elements inside this complex type can be nil or minOccurs set to '0'*
    *&lt;/message&gt;*
    &lt;portType name="pt1"&gt;
    &lt;operation name="GetCompanyInfo"&gt;
    &lt;input message="m1"/&gt;
    *&lt;output message="m2"/&gt; -----&gt; multi part message.*
    &lt;/operation&gt;
    &lt;/portType&gt;
    Now here is sample message for the request(I've composed this message for this question):
    &lt;soap:Envelope&gt; MESSAGE1
    &lt;soap:header/&gt;
    &lt;soap:body&gt;
    &lt;tns:m2&gt;
    &lt;tns:GetCompanyInfoResult&gt;
    Blah Blah....
    &lt;/tns:GetCompanyInfoResult&gt;
    &lt;tns:docs&gt;
    Blah Blah....
    &lt;/tns:docs&gt; Assume no data for 'logo', so it's not returned. Since all its elements can be nillable.
    &lt;tns:m2&gt;
    &lt;/soap:body&gt;
    &lt;/soap:Envelope&gt;
    First of all, is this SOAP response is valid? I'm not sure about *'message' and 'parts' in SOAP*, but according to XML schema standards it's invalid.
    Because, according to *'message' m2, 'logo' is missing*, eventhough all it's elements are nillable in such case there should be *&lt;logo/&gt;* at the end.
    I mean valid message should be like below
    &lt;soap:Envelope&gt; '*MESSAGE2*'
    &lt;soap:header/&gt;
    &lt;soap:body&gt;
    &lt;tns:m2&gt;
    &lt;tns:GetCompanyInfoResult&gt;
    Blah Blah....
    &lt;/tns:GetCompanyInfoResult&gt;
    &lt;tns:docs&gt;
    Blah Blah....
    &lt;/tns:docs&gt;
    *&lt;tns:logo/&gt; ------------------&gt; here is the change compared to above message. empty element.*
    &lt;tns:m2&gt;
    &lt;/soap:body&gt;
    &lt;/soap:Envelope&gt;
    Now the concerns are :
    (1) Which is a valid response? Message1 or Message2
    (2) If message1 is valid then why is weblogic throwing an exception 'null SOAP element', I suppose this is due to missing 'logo' element.
    (To confirm this I've used tcpmonitor and found message1 as response but weblogic is still throwing 'null SOAP Element' exception,
    which confirms it needs 'logo' as well, I suppose &lt;logo/&gt; at least). Is there any workaround for this in weblogic for multi-part messages?
    (3) If message1 is invalid according to SOAP standards then You've answered my question. ---&gt; I need to talk to the webservice provider in this case.....
    Thanks in advance...

    Message 1 is not Basic Profile 1.1 compliant. It is specified by BP1.1 in section 4.4.1(http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html#Bindings_and_Parts) that when a wsdl:part element is defined using the type attribute, the serialization of that part in a message is equivalent to an implicit (XML Schema) qualification of a minOccurs attribute with the value "1", a maxOccurs attribute with the value "1" and a nillable attribute with the value "false".

  • Vector.clear() throws null pointer exception

    is there anything wrong in my code. when i try to clear the vector irrespective of whether i add elements to it or not, if there are no elements added to the vector v1.clear() it throws null pointer exception
    Vector v1 = new Vector(1,1);
    v1.clear()

    And the guessing game continues... anyone for a shortctu to duplicate this problem?
    public class NullVectorCreator
        private Vector v1;//just love the name, so clear and unambiguous... :)
        public NullVectorCreator
             Vector v1 = new Vector();//well done - a local variable masquerading as
                                                          // a class member
        public Vector getVector()
             return v1;
        public static void main(String[] args)
               NullVectorCreator nvc = new NullVectorCreator();
                nvc.getVector().clear();//Why does this throw an NPE? why? java is bugged!
    }

  • Throwing Null Pointer Exception

    Throwing Null Pointer Exception on this line:
    secondDVD = dvdArray[j+1].getTitle();
    What could be the problem?
    <code>
    if (menuChoice.equals("1"))
    boolean done = false;
    DVD swapDVD = new DVD();
    int pass;
    int passLimit = dvdArray.length - 1;
    String firstDVD;
    String secondDVD;
    for (pass = 1; !done && pass <= passLimit; pass++)
    done = true;
    for (j=0; j < (dvdArray.length - pass); j++)
    firstDVD = dvdArray[j].getTitle();
    secondDVD = dvdArray[j+1].getTitle();
    if (firstDVD.compareTo(secondDVD) > 0)
    swapDVD = dvdArray[j];
    dvdArray[j] = dvdArray[j+1];
    dvdArray[j+1] = swapDVD;
    done = false;
    for (j=0; j<numOfDVD; j++);
    System.out.println(dvdArray[j].getTitle());
    </code

    ChuckBing wrote:
    Identify the line that is createing the error, and post all of the variable values that are involved in that line. Use a System.out.println statement to get the values, placing it immediately before the line's execution.
    Also. use code tags when posting code:
    [code]...your code here...
    [/code]
    He tried to, he used <code> tags by mistake.

  • Java function with Dynamic config throws null pointer exception

    hi Experts,
       I am using dynamic config using java function in my message mapping.
      The source message has a field called "fname".
      The value of "fname" is the input to my java UDF.
      The java UDF code is:
       public String getDynamicFile(String fname, Container container) throws StreamTransformationException{
       String str = fname + ".xml";
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey FileName = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","FileName");
    conf.put(FileName, str);
    return str;
       When I test this message mapping I get the following exception:
       Runtime Exception:[java.lang.NullPointerException: while trying to invoke the method com.sap.aii.mapping.api.DynamicConfiguration.put(com.sap.aii.mapping.api.DynamicConfigurationKey, java.lang.String) of an object loaded from local variable '<4>'] in class com.sap.xi.tf._<message mapping>_ method getDynamicFile[test, com.sap.aii.mappingtool.tf7.rt.Context@2e52cb31]
    What am I doing wrong in this UDF?
    Thanks
    Gopal

    Hi,
          Your UDF will run fine in an end to end execution,i.e, during runtime. However, if you want to test your message mapping test tab without the dynamic config UDF throwing an exception, encpasulate the code in a try catch block
    public String getDynamicFile(String fname, Container container) throws StreamTransformationException{
    String str = fname + ".xml";
    try{
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey FileName = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","FileName");
    conf.put(FileName, str);
    }catch(Exception ex){}
    return str;
    The above code should run fine when you test in the message mapping test tab.
    Regards

  • Office 365 Sandbox Solution EventReceiver throwing Remote Exception in ItemAdding

    Hi,
    I created a sandbox webpart for O365 with EventReceivers with ItemAdding for Document Library and while i upload a document to library in O365  sharepoint site application throws below exception:-
    System.Runtime.Remoting.RemotingException: Server encountered an internal error. For more information, turn off customErrors in the server's .config file.
    Server stack trace: 
    Exception rethrown at [0]: 
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at Microsoft.SharePoint.Administration.ISPUserCodeExecutionHostProxy.Execute(Type us
    Same code works perfectly on my Development machine, Please help. Below is the Code
    base.EventFiringEnabled = false;
    bool isFile = (properties.AfterProperties["vti_filesize"] != null);
    if (isFile == true)                   
    SPWeb currentWeb = properties.OpenWeb();
    // Get foldername from url like Document/EC10001/filename.txt                       
    string folderName = properties.AfterUrl.Split(new char[] { '/' })[1];
    SPList spList = currentWeb.Lists[properties.List.ID];                       
    SPQuery spQuery = new SPQuery();                       
    spQuery.Query = "<OrderBy><FieldRef Name='Modified' Ascending='FALSE'/></OrderBy>";
    //Getting the folder object from the list                       
    SPFolder folder = spList.RootFolder.SubFolders[folderName];
    //Set the Folder property                       
    spQuery.Folder = folder;
    int fileSequenceId = 0;                      
    SPListItemCollection items = spList.GetItems(spQuery);
    if (items.Count > 0)                       
    string documentID = items[0]["DocumentID"] != null ? items[0]["DocumentID"].ToString() : string.Empty;
    if (!string.IsNullOrEmpty(documentID))                           
    string splitNumber = documentID.Split(new char[] { '-' })[1];                               
    fileSequenceId = Convert.ToInt32(splitNumber) + 1;                           
    else                           
    properties.ErrorMessage = "Unable to generate Document Id";                               
    properties.Cancel = true;                           
    else                       
    fileSequenceId = 1;                       
    // Set DocumentID like EC10001-001                       
    properties.AfterProperties["DocumentID"] = folderName + "-" + fileSequenceId.ToString(ConstantsList(currentWeb, "DocumentID"));      
    // Retrive "EEC000" string from Constant List               
    properties.AfterProperties["vti_title"] = folderName + "-" + fileSequenceId.ToString(ConstantsList(currentWeb, "DocumentID"));   
    // Retrive "EEC000" string from Constant List                
    base.EventFiringEnabled = true;
    Thanks,
    Pranay Chandra Sapa

    Hi,
    According to your description, my understanding is that when you upload document in Office 365 site, the event receiver in sandbox solution throws error.
    Per my knowledge, if you want to use event receiver in Office 365 environment, you need to use remote event receiver instead the normal event receiver in an app.
    Here are some detailed articles for your reference:
    Create a remote event receiver in apps for SharePoint
    Handle events in apps for SharePoint
    Thanks
    Best Regards
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • How to throw bundled exceptions thrown by checkErrors()

    Hi,
    I call pl/sql to do update, and call checkErrors() , the code looks like following, but it doesn't display read friendly message on the screen. What is the right way to throw bundled exception from checkErrors() method?
    try{
    xxg2cGoalPk.startWf (conn,
    new BigDecimal(srpGoalHeaderId),
    new BigDecimal(userId),
    returnStatus,
    msgCount,
    msgData);
    int msgCount1 = 0;
    if(msgCount[0] != null){
    msgCount1 = Integer.parseInt(msgCount[0].toString());
    String returnStatus1 = returnStatus[0];
    String msgData1 = msgData[0];
    OAExceptionUtils.checkErrors(tx,msgCount1, returnStatus1, msgData1);
    catch(OAException e) {
    e.printStackTrace();
    throw new OAException(e.getDetailMessage(),OAException.ERROR);
    thanks
    Lei

    What Shiv said is only an alternative, but what you are using is correct.I haven't tested but as per javadoc of
    OAExceptionUtils.checkErrors(tx,msgCount1, returnStatus1, msgData1);
    will itself raise bundled exceptions. You need to write this line outside try/catch block.
    --Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Why it is throwing null at last  whenever i am running this program

    public static void main(String args[])
              String str;                    
              try     
              FileReader fis = new FileReader(C:\\src\\vinaysingh\\xmlreq.xml");
              BufferedReader br= new BufferedReader(fis);
              do
                   str=br.readLine();
                   System.out.println(str);
              while(!str.equals(null));
    why it is throwing null on last if i am reading any xml file

    get the value of string as the value which u
    had collected from the string instead of nullWhat? That just doesn't make any sense. At all.
    I presume what you're asking is:
    How do I read lines from a text file, ignoring empty lines. Especially how do I know when I've reached the end of the file so that I can stop trying to read more lines.
    this might help some ...
    package krc.utilz.io;
    import java.util.Collection;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.io.File;
    import java.io.Reader;
    import java.io.FileReader;
    import java.io.BufferedReader;
    import java.io.FileWriter;
    import java.io.PrintWriter;
    import java.io.InputStream;
    import java.io.FileInputStream;
    import java.io.Closeable;
    import java.io.IOException;
    import java.io.FileNotFoundException;
    * @class: krc.utilz.io.Filez
    * A collection of static "file handling" helper methods.
    public abstract class Filez
      public static final int BFRSIZE = 4096;
       * reads the given file into one big string.<p>
       * Warning: don't use this on big files. It uses too much RAM!
       * @param String filename - the name of the file to read
       * @return the contents filename
      public static String read(String filename)
        throws FileNotFoundException
        return Filez.read(new FileReader(filename));
       * Reads the contents of the given reader into one big string, and closes
       * the reader.
       * Warning: don't use this on big files. It uses too much RAM!
       * @param java.io.Reader reader - a subclass of Reader to read from.
       * @return the whole contents of the given reader.
      public static String read(Reader in)
        try {
          StringBuffer out = new StringBuffer();
          try {
            char[] bfr = new char[BFRSIZE];
            int n = 0;
            while( (n=in.read(bfr,0,BFRSIZE)) > 0 ) {
              out.append(bfr,0,n);
          } finally {
            if(in!=null)in.close();
          return out.toString();
        } catch (IOException e) {
          throw new RuntimeIOException(e.getMessage(), e);
       * (re)writes the given content to the given filename
       * @param String content - the new contents of the fil
       * @param String filename - the name of the file to write.
      public static void write(String content, String filename) {
        try {
          PrintWriter out = null;
          try {
            out = new PrintWriter(new FileWriter(filename));
            out.write(content);
          } finally {
            if(out!=null)out.close();
        } catch (IOException e) {
          throw new RuntimeIOException(e.getMessage(), e);
       * Appends the given content to the given filename.
       * @param String content - the string to write to the file.
       * @param String filename - the name of the file to write to.
      public static void append(String content, String filename) {
        try {
          PrintWriter out = null;
          try {
            out = new PrintWriter(new FileWriter(filename, true)); //true=append
            out.write(content);
          } finally {
            if(out!=null)out.close();
        } catch (IOException e) {
          throw new RuntimeIOException(e.getMessage(), e);
       * reads each line of the given file into an array of strings.
       * @param String filename - the name of the file to read
       * @return a fixed length array of strings containing file contents.
      public  static String[] readArray(String filename)
        throws FileNotFoundException
        return readList(filename).toArray(new String[0]);
       * reads each line of the given file into an ArrayList of strings.
       * @param String filename - the name of the file to read
       * @return an ArrayList of strings containing file contents.
      public static ArrayList<String> readArrayList(String filename)
        throws FileNotFoundException
        return (ArrayList<String>)readList(filename);
       * reads each line of the given file into a List of strings.
       * @param String filename - the name of the file to read
       * @return an List handle ArrayList of strings containing file contents.
      public static List<String> readList(String filename)
        throws FileNotFoundException
        try {
          BufferedReader in = null;
          List<String> out = new ArrayList<String>();
          try {
            in = new BufferedReader(new FileReader(filename));
            String line = null;
            while ( (line = in.readLine()) != null ) {
              out.add(line);
          } finally {
            if(in!=null)in.close();
          return out;
        } catch (IOException e) {
          throw new RuntimeIOException(e.getMessage(), e);
       * reads the whole of the given file into an array of bytes.
       * @param String filename - the name of the file to read
       * @return an array of bytes containing the file contents.
      public static byte[] readBytes(String filename)
        throws FileNotFoundException
        return( readBytes(new File(filename)) );
       * reads the whole of the given file into an array of bytes.
       * @param File file - the file to read
       * @return an array of bytes containing the file contents.
      public static byte[] readBytes(File file)
        throws FileNotFoundException
        try {
          byte[] out = null;
          InputStream in = null;
          try {
            in = new FileInputStream(file);
            out = new byte[(int)file.length()];
            int size = in.read(out);
          } finally {
            if(in!=null)in.close();
          return out;
        } catch (IOException e) {
          throw new RuntimeIOException(e.getMessage(), e);
       * do files A & B have the same contents
       * @param String filenameA - the first file to compare
       * @param String filenameA - the second file to compare
       * @return boolean do-these-two-files-have-the-same-contents?
      public static boolean isSame(String filenameA, String filenameB)
        throws FileNotFoundException
        try {
          File fileA = new File(filenameA);
          File fileB = new File(filenameB);
          //check for same physical file
          if( fileA.equals(fileB) ) return(true);
          //compare sizes
          if( fileA.length() != fileB.length() ) return(false);
          //compare contents (buffer by buffer)
          boolean same=true;
          InputStream inA = null;
          InputStream inB = null;
          try {
            inA = new FileInputStream(fileA);
            inB = new FileInputStream(fileB);
            byte[] bfrA = new byte[BFRSIZE];
            byte[] bfrB = new byte[BFRSIZE];
            int sizeA=0, sizeB=0;
            do {
              sizeA = inA.read(bfrA);
              sizeB = inA.read(bfrB);
              if ( sizeA != sizeB ) {
                same = false;
              } else if ( sizeA == 0 ) {
                //do nothing
              } else if ( !Arrays.equals(bfrA,bfrB) ) {
                same = false;
            } while (same && sizeA != -1);
          } finally {
            Clozer.close(inA, inB);
          return(same);
        } catch (IOException e) {
          throw new RuntimeIOException(e.getMessage(), e);
       * checks the given filename exists and is readable
       * @param String filename = the name of the file to "open".
       * @param OPTIONAL String type = a short name for the file used to identify
       *  the file in any exception messages.
       *  For example: "input", "input data", "DTD", "XML", or whatever.
       * @return a File object for the given filename.
       * @throw FileNotFoundException if the given file does not exist.
       * @throw IOException if the given file is unreadable (usually permits).
      public static File open(String filename)
        throws FileNotFoundException
        return(open(filename,"input"));
      public static File open(String filename, String type)
        throws FileNotFoundException
        try {
          File file = new File(filename);
          String fullname = file.getCanonicalPath();
          if(!file.exists()) throw new FileNotFoundException(type+" file does not exist: "+fullname);
          if(!file.canRead()) throw new RuntimeIOException(type+" file is not readable: "+fullname);
          return(file);
        } catch (IOException e) {
          throw new RuntimeIOException(e.getMessage(), e);
       * gets the filename-only portion of a canonical-filename, with or without
       * the extension.
       * @param String path - the full name of the file.
       * OPTIONAL @param boolean cutExtension - if true then remove any .ext
       * @return String the filename-only (with or without extension)
      public static String basename(String path) {
        return(basename(path,false));
      public static String basename(String path, boolean cutExtension)
        String fname = (new File(path)).getName();
        if (cutExtension) {
          int i = fname.lastIndexOf(".");
          if(i>0) fname = fname.substring(0,i);
        return(fname);
    }You'll probably want to remove all references to RuntimeIOException... just throw the standard checked IOException instead.

  • JAXB2 marshaller throws Validation Exception

    Hello All.. I am trying to marshall a JAXB Object using JAXB2 marshaller and validate it against an xsd.
    During this process of validation, the parser when reads the xsd fails with the parse error. The schema xsd is a working xsd from a webservice provider. The validation is fine when it is done on XML Spy and SOAP UI. But when this xerces xmlschema validator comes to picture its even not able to parse the XSD for validating against it.
    Here is the head of the xsd..
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
         xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
         xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
         xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
         xmlns:tns="http://com.cyber.space./services"          
         targetNamespace="http://com.cyber.space./services"
         elementFormDefault="qualified"
    and a huge schema followed.
    Step.1: I used this xsd to generate JAXB classes.
    Step2. Used jaxb2marshaller from spring.oxm,
    <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
              <property name="contextPath" value="com.cyberspace.service"/>
              <b><property name="schema" value="classpath:pathtoXsd"/></b>
         </bean>
    so in my application , i have reference to marshaller object.so can use like this.
    request ( the jaxb request object populated with valid values as per the schema)
    result - output -- outgoing xml.
    marshaller.marshall(requsest, result);
    Here comes the problem..The out going xml is like this..
    <?xml version="1.0" encoding="UTF-8" ?>
    <Request xmlns="http://com.cyber.space./services">
    <RequestService>123</RequestService>
    etec etc etc.. son on..
    This xml when converted to soap message and sent over to webservice its accepted as valid request and response is back. But all it happens when i dont validate it against the schema that i have.
    Look at the :
    <b><property name="schema" value="classpath:pathtoXsd"/></b> set as a property to jaxb2 marshaller.
    This makes sure that the xml generated out the jaxb object after marshall process is valid against the XSD schema. Here it fails for some reason.
    If the dont ask the marshaller to validate( removing the schema property ), then the xml is fine able to proceed with next steps of sending the successfull VALID SOAP REQUEST and response is back. But if do a validation by setting the schema property with value as path to xsd.
    The error is :
    Caused by:<b> org.xml.sax.SAXParseException: cvc-datatype-valid.1.2.2: ' ' is not a valid value of list type 'null'.</b>
         at com.sun.org.apache.xerces.internal.jaxp.validation.Util.toSAXParseException(Util.java:109)
         at com.sun.org.apache.xerces.internal.jaxp.validation.ErrorHandlerAdaptor.error(ErrorHandlerAdaptor.java:104)
         at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:382)
         at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
         at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:429)
    ...,more
    Is it a problem with namespace.? If i assume that the resulting xml out of the marshall process when validated against the XSD is failing for some missing data( business data), then the request itself would not be sent as soap requst.
    But the problem is not that with data in the xml. its some thing going on with the strict validation the validator is doing.
    Edited by: cnu_coder on May 22, 2008 7:41 AM
    Edited by: cnu_coder on May 23, 2008 8:14 AM

    Hello,
    The ABAP code looks ok except the missing if error != null statement.
    Please check the similar code for raising exception provided in the below blog:
    /people/ravi.gupta4/blog/2010/02/04/automating-cancellation-of-a-failed-message-in-xi
    Also, Can you check whether exception is raised using Dynamic config UDF and a call to abap mapping is made.
    Check the other approach of raising an exception:
    /people/alessandro.guarneri/blog/2006/01/26/throwing-smart-exceptions-in-xi-graphical-mapping
    -Rahul

  • Can synchronized( someObj ) ever throw an exception?

    I know that object.wait() can throw an exception (IllegalMonitorStateException or InterruptedException) can synchronized ever do the same?
    For example:
    synchronized( obj ) //does this line ever throw an exception?
    }What is that synchronized line in byte code?

    [Section 14.19 of the Java Language Specification|http://java.sun.com/docs/books/jls/third_edition/html/statements.html#255769] says that if the value of obj is null, then a NullPointerException is thrown.

  • Why socket doesn't throw an exception

    Hello,
    I am using following code
    client:
          InetAddress addr = InetAddress.getByName("localhost");
          sock = new Socket(addr, 5551);
          in = new BufferedReader(
            new InputStreamReader(
              sock.getInputStream()));
          out = new PrintWriter(
            new BufferedWriter(
              new OutputStreamWriter(
                sock.getOutputStream())), true);server
    try{
      ServerSocket server = new ServerSocket(port);
      Socket socket = server.accept();
      BufferedReader in = new BufferedReader(
         new InputStreamReader(
           socket.getInputStream()));
      PrintWriter out = new PrintWriter(
        new BufferedWriter(
          new OutputStreamWriter(
           socket.getOutputStream())), true);
      while (true){
         String msg = in.readLine();
         System.out.println(msg);
    catch (SocketException  se){
      System.out.print(se.toString());
    catch (IOException e){
      System.out.print(e.toString());
    catch (Exception ex) {
      System.out.print(ex.toString());
    }When I close client, server is constantly writing null (msg is null). Why doesn't it throw an exception?
    Thank you.

    The moral of the story is avoid using Readers and Writers with Sockets. They swallow exceptionsThat's not so. It is PrintWriters and PrintStreams that swallow exceptions.
    @OP: there is no reason for your code to throw an exception. It keeps reading the socket and encountering EOF, signalled by the null return, at which point any sensible code should exit the loop and close the socket. However as you don't do that, you just read the socket and get the EOF again ...
    You would only get an exception, specifically an EOFException, if you were calling one of the readXXX methods that is specified to throw it. readLine() isn't one of those.

Maybe you are looking for

  • Camera and warrenty issue!

    my camera shutter is stuck both cameras wont work(front and rear facing) And how do i tell if my warrenty is still good? What should i do because apple hung up on me!

  • How to use MP3 file as a clip, not background music

    I have a radio spot as an MP3 file, but when I drag it into the project it automatically thinks I want it as my background music. I actually want it as a clip to play after a commercial.  I have tried saving it out of QT as a movie file but it won't

  • OI have been trying to connect to the on-line chat, but no one seems to be there. It is 8:30 am, too early???

    I am trying to 'restore' my contacts to a new device., The new device is a very basic phone: LG Revere 2. The online instructions warn you to back up your contacts from the old phone before acrivating the new phone. The actual instructions say to do

  • PIXMA MX860, OS X 10.9.4, OS X 10.10. Printer not printing black

    Printer will print black when I print a test page from the printer, but will not print black when I print a selection from either my MacBook (OS X 10.10 Yosemite) or my iMac (OS X 10.9.4 Mavericks).  What gives? I did print a test page from the Canon

  • HT204406 itunes match not working

    iTunes match is not working on my wife's iphone 4s. I have an ipad, my iphone and 2 pc's all linked to the same itunes account and have no problems connecting with them. The problem started this afternoon only on my wife's iphone 4s - trying to conne