When to construct and when to throw an Exception?

I have searched the forums but couldn't find anything specific to this.
Example code:
public exampleObject{
//constructor
public exampleObject()throws Exception{
public example2Object{
//declaration
private exampleObject = new exampleObject();
In JDK1.3 the compiling of example2Object throws an Exception
In JDK1.4 it doesn't throw an exception.
Why.......Should I not be constructing these objects in the declaration?
Thanks

I don't quite get you; the compilation doesn't throw an exception, does it? Possibly it may signal an error.
If I'm not wrong, your example is exactly the same as this:
public example2Object{
//declaration
private exampleObject;
//constructor
public example2Object() {
this.exampleObject = new exampleObject();
Thus, I believe that the constructor could throw an Exception (which it's signature doesn't say). It is generally a good idea to instantiate new objects in the constructor, instead of in the declaration of object variables. That's my opinion though...

Similar Messages

  • GetBlobReferenceFromServerAsync (and non-async) throw an exception with 404 (not found) if the blob doesn't exist.

    I'm trying to determine if a particular file exists in a blob store. I'm using container.GetBlobReferenceFromServerAsync and if the named blob does't exist I get an exception with a 404. ICloudBlob (which is returned by the method) defines an Exists method
    but it's functionally useless because the GetBlobReferenceFromServerAsync method call itself throws the exception. I do get the behavior I'm looking for if I call container.GetBlockBlobReference instead but there's no async version of that method.

    As I said I'd found that GetBlockBlobReference works but there's no async version of that method. I'm trying to determine IF a blob exists not create one. Since the GetBlobReferenceFromServer returns an ICloudBlob and ICloudBlob defines and Exists method
    you'd assume that it could be used to determine if a blob exists. I'd argue that the fact that it throws and exception when the blob does not exist is a bug in the implementation because it makes the Exist method on the ICloudBlob object functionally useless.
    Also, it seems like a fairly significant miss that there's no async version of GetBlockBlobReference. A query to a cloud resource is exactly the perfect use case for the async/await pattern.
    Does anyone know of an async way to check for the existence of a blob that doesn't involve catching a 404 exception?

  • How to Throw an Exception in a SapServer

    Hello,
    We have successfully implemented SAPServer in our external process.
    The only thinks that doesn't work perfectly is that we can't throw an exception in the implementation of remote function module.
    The ABAP Program that is calling our fontion waits on expetion 0, 1, 2, 3 and 4. But when we throw the exception like this : throw new RfcException( "Error" );
    the ABAP catch this exception, but as exception 4 (others) and not as 3 (Error)
    Can someone help. Thanks

    Hello
    Thanks for the answer.
    In the while we tried the following:
    RfcAbapException( "ERROR" );
    but it doesn't work.
    The solution was to call this method with 2 parameters:
    RfcAbapException( "ERROR", "Some error text...");
    And now OK.

  • FM used in background job throws an Exception-NO_BATCH

    Hi,
    I have one normal ABAP report with selection screen, where selection parameters are file names and they are used for uploading data from excel to internal table and then internal table to excel respectively.
    Now I want to put this as a background job. So I saved the variant and now while running the job there is an exception.
    Reason for the same as I could find out is:
    while uploading function module (KCD_EXCEL_OLE_TO_INT_CONVERT or ALSM_EXCEL_TO_INTERNAL_TABLE) is called, it has some front-end  services called.
    That is in case of first function module, it is CLPB_IMPORT which in turn calls WS_QUERY where GUI_EXIST is checked and there it throws an exception.
    And in the later case it is cl_gui_frontend_services class and its some method is called.
    So basically, frontend services are called in any case and I still want this as a background job.
    Can Anyone clear it conceptually?

    Hello Krupa,
    The rule is pretty much simple: <i>Anything that you do in batch / background, cannot have anything to do with the front-end / desktop.</i>
    The Excel sheet you use is an application that runs on the Frontend, right? So you cannot do it in batch. The reason, to put it crudely, is that a background job is run by a different workprocess altogether and that work process is not capable of accessing the front-end. Ideally, a background job should be run-able even without a GUI!!
    SO what you can do in a background job, is to operate on the files present on the application server (that is where the job runs).
    Hope that is clear. If not, get back.
    Regards,
    Anand Mandalika.
    Regards,
    Anand Mandalika.

  • SU DeploymentException - when to throw and when to return a failed status

    When a SUManager's deploy method is invoked and the operation fails is it a matter of preference to throw a DeploymentException with a XML message containing the component-task-result like the ri-component examples do or to simply return a XML message containing the component-task-result with a status of failure for the operation?

    The general rule is to have the SUM.deploy() method return an XML result/status string (as defined in section 6.9). This produces a structured result that is returned to the admin tool, allowing it to produce a detailed, human-friendly error message.
    Alternatively a DeploymentException can be thrown. I am not aware of any circumstances where this must be used instead of the return value to indicate a deploy() failure, but if memory serves the RI team had identified some corner case where such an exception was considered necessary. If you wish, I can follow up with them to get some details.
    Regardless of whether the SUM.deploy() returns a result/status with an ERROR result or if it throws an exception, the DeploymentServiceMBean supplied by the JBI implementation must return a result/status string for the service assembly deployment, throwing an exception only if the entire SA fails to deploy. A result/status string produced from a SUM.deploy DeploymentException won't contain as much information as a result/status string.

  • JNDI: DirContext::list throws on exception when existing context is in LDAP

    I was able to import tutorial.ldif using LDAP Browser/Editor without incident:
    http://www-unix.mcs.anl.gov/~gawor/ldap/
    My LDAP now has the following tree:
    o=JNDITutorial
    ou=Groups
    5 cn entries
    ou=People
    10+ cn entries
    However, when calling DirContext::list("ou=People"), it throws the following exception message:
    javax.naming.NameNotFoundException: [LDAP: error code 32 - No Such Object]; remaining name 'ou=People'
    Here is the code:
         final static String ldapServerName = "backbone.seamonkey";
        public static void main(String[] args) {
         // Set up the environment for creating the initial context
         Hashtable env = new Hashtable(11);
         env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
         env.put(Context.PROVIDER_URL, "ldap://" + ldapServerName +"/o=JNDITutorial");
         try {
             // Create initial context
             DirContext ctx = new InitialDirContext(env);
             // Return enum of people, but throws an exception...
             NamingEnumeration people = ctx.list("ou=People");

    I tried the same with a known LDAP service: OpenLDAP.org, and I get the same exception NameNotFoundException thrown with the following code:
         final static String m_ldapServerName = "OpenLDAP.org";
        public static void main(String[] args) {
         // Set up the environment for creating the initial context
         Hashtable<Object, Object> env = new Hashtable<Object, Object>();
         env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
         env.put(Context.PROVIDER_URL, "ldap://" + m_ldapServerName + ":389/");
         try {
             // Create initial context
             DirContext ctx = new InitialDirContext(env);
             // Return enum of people, but throws an exception...
             NamingEnumeration people = ctx.list("ou=People");

  • I have a production mobile Flex app that uses RemoteObject calls for all data access, and it's working well, except for a new remote call I just added that only fails when running with a release build.  The same call works fine when running on the device

    I have a production mobile Flex app that uses RemoteObject calls for all data access, and it's working well, except for a new remote call I just added that only fails when running with a release build. The same call works fine when running on the device (iPhone) using debug build. When running with a release build, the result handler is never called (nor is the fault handler called). Viewing the BlazeDS logs in debug mode, the call is received and send back with data. I've narrowed it down to what seems to be a data size issue.
    I have targeted one specific data call that returns in the String value a string length of 44kb, which fails in the release build (result or fault handler never called), but the result handler is called as expected in debug build. When I do not populate the String value (in server side Java code) on the object (just set it empty string), the result handler is then called, and the object is returned (release build).
    The custom object being returned in the call is a very a simple object, with getters/setters for simple types boolean, int, String, and one org.23c.dom.Document type. This same object type is used on other other RemoteObject calls (different data) and works fine (release and debug builds). I originally was returning as a Document, but, just to make sure this wasn't the problem, changed the value to be returned to a String, just to rule out XML/Dom issues in serialization.
    I don't understand 1) why the release build vs. debug build behavior is different for a RemoteObject call, 2) why the calls work in debug build when sending over a somewhat large (but, not unreasonable) amount of data in a String object, but not in release build.
    I have't tried to find out exactly where the failure point in size is, but, not sure that's even relevant, since 44kb isn't an unreasonable size to expect.
    By turning on the Debug mode in BlazeDS, I can see the object and it's attributes being serialized and everything looks good there. The calls are received and processed appropriately in BlazeDS for both debug and release build testing.
    Anyone have an idea on other things to try to debug/resolve this?
    Platform testing is BlazeDS 4, Flashbuilder 4.7, Websphere 8 server, iPhone (iOS 7.1.2). Tried using multiple Flex SDK's 4.12 to the latest 4.13, with no change in behavior.
    Thanks!

    After a week's worth of debugging, I found the issue.
    The Java type returned from the call was defined as ArrayList.  Changing it to List resolved the problem.
    I'm not sure why ArrayList isn't a valid return type, I've been looking at the Adobe docs, and still can't see why this isn't valid.  And, why it works in Debug mode and not in Release build is even stranger.  Maybe someone can shed some light on the logic here to me.

  • Ant throws the exception when builds B2B

    Hi,
    Ant throws the exception:
    default.application.xml:
        [style] Processing D:B2B_DEVsap_earmeta-inf.b2bapplication.xml to D:B2B
    _DEVproject_earmeta-inf.b2b_devMETA-INFapplication.xml
        [style] Loading stylesheet D:B2B_DEVbintemplatesapplication.xsl
        [style] Failed to process D:B2B_DEVsap_earmeta-inf.b2bapplication.xml
    BUILD FAILED
    D:B2B_DEVbinbuild.xml:113: The following error occurred while executing this
    line:
    D:B2B_DEVprojectbuildmodification.xml:102: The following error occurred while
    executing this line:
    D:B2B_DEVbinearbuilder.xml:78: The following error occurred while executing t
    his line:
    D:B2B_DEVbinearbuilder.xml:16: javax.xml.transform.TransformerConfigurationEx
    ception: Could not load stylesheet. org.w3c.dom.DOMException: Prefix is 'xmlns',
    but URI is not 'http://www.w3.org/2000/xmlns/' in the qualified name, 'xmlns:xs
    l'
    How to fix it?
    The configuration is MS Windows XP SP2, MS SQL Server 2000 Developer Edition SP4, SAP Web AS 6.40 SP18, Apache Ant 1.6.5, Build Tool, j2sdk1.4.2_07.
    Any help will be appreciated.
    Regards,
    Roman Babkin

    Hi,
    have you tried to urlencode the hash char?
    Might be interesting as well if the problem also occours when you point to a local script in your url. The script should then contain a static link to your xml file.
    cheers,
    jossif

  • I lost my google and facebook username and passwords when i upgraded firefox 3.o to firefox 10.0.2 it saved all username and passwords of other websites except these two

    Today i Upgraded 10.0.2 with my older version after upgradation i started the firefox all my saved passwords are showed in saved password except the passwords from gmail and facebook when i checked the exceptions it shows those passwords will not be saved

    Solved THANK YOU!!!!

  • Cloud service created works fine in local Azure Emulator. But doesnot work when deployed to actual azure and says Restarting (Role has encountered an error and has stopped. Unhandled Exception: System.IO.FileNotFoundException)

    Hi,
    I have a created a cloud service and when i run locally in azure emulator it works fine. But when I am trying to deploy that to azure it says: Restarting (Role has encountered an error and has stopped.
    Unhandled Exception: System.IO.FileNotFoundException)
    Can anyone please help me on this.
    Thanks,
    Satya Chenna

    Any specific reason you are having timer on role start up? are you using thread.sleep for longer duration in the method?
    If you are using azure diagnostics - make sure these things
    1. Azure storage connection string is set to correct storage account and not to the development storage.
    2. Check session state provider - local is not supported on azure.
    Also you can refer this for more information 
    http://blogs.msdn.com/b/kwill/archive/2013/09/06/troubleshooting-scenario-3-role-stuck-in-busy.aspx
    Bhushan | Blog |
    LinkedIn | Twitter

  • Ant throws the exception when builds B2B (E-selling of CRM-ISA)

    Hi,
    Ant throws the exception:
    default.application.xml:
        [style] Processing D:B2B_DEVsap_earmeta-inf.b2bapplication.xml to D:B2B
    _DEVproject_earmeta-inf.b2b_devMETA-INFapplication.xml
        [style] Loading stylesheet D:B2B_DEVbintemplatesapplication.xsl
        [style] Failed to process D:B2B_DEVsap_earmeta-inf.b2bapplication.xml
    BUILD FAILED
    D:B2B_DEVbinbuild.xml:113: The following error occurred while executing this
    line:
    D:B2B_DEVprojectbuildmodification.xml:102: The following error occurred while
    executing this line:
    D:B2B_DEVbinearbuilder.xml:78: The following error occurred while executing t
    his line:
    D:B2B_DEVbinearbuilder.xml:16: javax.xml.transform.TransformerConfigurationEx
    ception: Could not load stylesheet. org.w3c.dom.DOMException: Prefix is 'xmlns',
    but URI is not 'http://www.w3.org/2000/xmlns/' in the qualified name, 'xmlns:xs
    l'
    How to fix it?
    The configuration is MS Windows XP SP2, MS SQL Server 2000 Developer Edition SP2, SAP Web AS 6.40 SP18, Apache Ant 1.6.5, Build Tool.
    Any help will be appreciated.
    Regards,
    Roman Babkin

    Hi,
    Ant throws the exception:
    default.application.xml:
        [style] Processing D:B2B_DEVsap_earmeta-inf.b2bapplication.xml to D:B2B
    _DEVproject_earmeta-inf.b2b_devMETA-INFapplication.xml
        [style] Loading stylesheet D:B2B_DEVbintemplatesapplication.xsl
        [style] Failed to process D:B2B_DEVsap_earmeta-inf.b2bapplication.xml
    BUILD FAILED
    D:B2B_DEVbinbuild.xml:113: The following error occurred while executing this
    line:
    D:B2B_DEVprojectbuildmodification.xml:102: The following error occurred while
    executing this line:
    D:B2B_DEVbinearbuilder.xml:78: The following error occurred while executing t
    his line:
    D:B2B_DEVbinearbuilder.xml:16: javax.xml.transform.TransformerConfigurationEx
    ception: Could not load stylesheet. org.w3c.dom.DOMException: Prefix is 'xmlns',
    but URI is not 'http://www.w3.org/2000/xmlns/' in the qualified name, 'xmlns:xs
    l'
    How to fix it?
    The configuration is MS Windows XP SP2, MS SQL Server 2000 Developer Edition SP2, SAP Web AS 6.40 SP18, Apache Ant 1.6.5, Build Tool.
    Any help will be appreciated.
    Regards,
    Roman Babkin

  • Inventory Control of new houses (construction and sale)

    Colleagues,
    Need  information about controlling inventory of new homes, the business process is from the construction and sale, but using the traditional solution of SAP ECC 6.0, not  EC&O
    Thanks

    it sounds like you have a slow database server, or one that is sending the
    data over a WAN link. When you deleted the database, it had to recover all
    the information in the STR files. Normally, delta scans are done every day
    or so to see if anyting has changed, and then a full scan every five days.
    I would bump this up to 20 since usually there very few workstations that
    will need a full scan.
    For you boss, I would suggest that you nicely inform him that the inventory
    pulled by ZfD is at least 80% accurate but never 100%. If you have a
    workstation that is not being scanned, registered, imported, etc.. you are
    likely to miss it. How do you account for the WS Removal policy which will
    pull out inventory when the machine is not registered for "x" days. If
    anything, use the ZfD inventory as a backup for internal components only.
    Good Luck,
    Ken Puett, CNE,CNI
    > We are running zenworks 4 ir7 on nw6 sp5. Installed it a number of years
    > ago mostly for the purpose of remote control of systems. Inventory got
    > installed but never paid attention to it. Now my boss wants accurate
    > reports on workstations and what was in the inventory was definitely not
    > accurate. Deleted the database files (sybase) and started over. It
    > appears to be working but very slowly. After a week and a half it has
    > discovered 248 systems. Is this normal? Was this originally setup wrong?
    > Any advice is appreciated
    >
    > Thanks
    >
    > James

  • Message says website under construction and that I should replace index htm. I don't know what this means or what to do.

    My website gives a message that it is under construction and says to replace index htm. I don't know what this means and I don't know what to do.

    iWeb has two ways to publish a website - via FTP to the root folder on a server or to a local folder...
    http://www.iwebformusicians.com/iWeb/Publish-Website.html
    With either method, two items are produced - an index.html file and folder with the same name that you gave the site in iWeb.
    When a visitor enters the URL - http://www.domain-name.com/ - this opens the index.html file which, in turn, opens the Home or Landing Page of the site. Without this file nothing will happen.
    If you are attempting to upload your files using the iWeb FTP, try using the settings shown in the first example on the above mentioned page. Leave the Directory/Path field blank so that the files are uploaded to the root folder.
    If you are using an FTP application you need to know the name of the root folder so that you can upload the index.html file and website folder to it. If you are in doubt, ask your hosting service what that is. My own hosting service allows me to create and name the root folder(s) but most others require that you upload to a "public_html" or "www" folder which seems kind of backward to me!
    Find out more about URLs and FTP here...
    http://www.iwebformusicians.com/iWeb/URLs-Favicons.html
    .. and here...
    http://www.iwebformusicians.com/Search-Engine-Optimization/Upload.html
    "I may receive some form of compensation, financial or otherwise, from my recommendation or link."

  • Limit the time of lookup and make the method to throw an Exception

    When I connect from
    Client
    Remote Desktop Client
    Server:
    SUN JAVA SYSTEM APPLICATION SERVER 9.0
    Initial Context object is initialized as per below coding,
    System.setProperty("org.omg.CORBA.ORBInitialHost", prop.getProperty("hostName"));
    System.setProperty("org.omg.CORBA.ORBInitialPort", prop.getProperty("portNumber"));
    InitialContext ctx = new InitialContext();
    while .lookup("globalJndiNameForSessionBean") method is invoked on the InitialContext object and if the server is not available, it is throwing non stop error.
    Please tell me wether I have to add any other Properties to limit the time of lookup and make the method to throw an Exception after two or three second, if the server is not available.

    What do you mean by 'non-stop error'? This can only happen if your code goes into a non-stop loop.
    The default TCP connect timeout is about 75 seconds, which in some circumstances is too long, but two or three seconds definitely isn't long enough. Ten to twenty would be more like it.
    I'm not aware of any system properties that limit the ORB connect timeout but then I'm not aware where the existing J2SE ORB system properties are documented. If anybody has ever found this please let us know.

  • Error when testing a webservice - Exception raised in class CL_SOAP_REGIST

    Dear coleagues,
    I've got an issue concerning the AS ABAP SOAP Runtime. The system is an ERP 6.0 with SP13.
    If I try to test the service in WSADMIN by using the test-button, I just get an exception after the internet browser opens:
    A Soap Core Exception was raised in Method CL_SOAP_REGISTRY::generate_wsdl(6)
    Technical Details of Soap Core Exception
    Message Text: SRT: ASSERT failed: object reference not bound
    Class: CL_SOAP_REGISTRY
    Method: generate_wsdl
    LocationID: 6
    Program: CL_SOAP_REGISTRY==============CP
    Include: CL_SOAP_REGISTRY==============CM00J
    Line: 59
    I did a look into the coding and think that the exception is raised since the methode
    Hi folks,
    I've got an issue concerning the AS ABAP SOAP Runtime. The system is an ERP 6.0 with SP13.
    At first I create a Web Service by using the context menue of an existing rfc-enabled function module. Afterwards the service is visible in SICF. If I try to test the service in WSADMIN by using the test-button I only get an exception in the opening internet browser:
    Cannot download WSDL from http://serverurl:8027/sap/bc/srt/rfc/sap/ZSTMA_FUNKTIONSTEST2?sap-client=100&wsdl=1.1: Invalid Response Code: (400) Bad Request. The requested URL was:"http://ciswi.sap.swm.de:8027/sap/bc/srt/rfc/sap/ZSTMA_FUNKTIONSTEST2?sap-client=100&wsdl=1.1"
    If I go onto the used url I get the following message:
    Your request could not be processed
    SRT: ASSERT failed: object reference not bound
    What has happened?
    A Soap Core Exception was raised in Method CL_SOAP_REGISTRY::generate_wsdl(6)
    Technical Details of Soap Core Exception
    Message Text: SRT: ASSERT failed: object reference not bound
    Class: CL_SOAP_REGISTRY
    Method: generate_wsdl
    LocationID: 6
    Program: CL_SOAP_REGISTRY==============CP
    Include: CL_SOAP_REGISTRY==============CM00J
    Line: 59
    I did a look into the coding and found out that the exception is raised since
    Hi folks,
    I've got an issue concerning the AS ABAP SOAP Runtime. The system is an ERP 6.0 with SP13.
    At first I create a Web Service by using the context menue of an existing rfc-enabled function module. Afterwards the service is visible in SICF. If I try to test the service in WSADMIN by using the test-button I only get an exception in the opening internet browser:
    Cannot download WSDL from http://serverurl:8027/sap/bc/srt/rfc/sap/ZSTMA_FUNKTIONSTEST2?sap-client=100&wsdl=1.1: Invalid Response Code: (400) Bad Request. The requested URL was:"http://ciswi.sap.swm.de:8027/sap/bc/srt/rfc/sap/ZSTMA_FUNKTIONSTEST2?sap-client=100&wsdl=1.1"
    If I go onto the used url I get the following message:
    Your request could not be processed
    SRT: ASSERT failed: object reference not bound
    What has happened?
    A Soap Core Exception was raised in Method CL_SOAP_REGISTRY::generate_wsdl(6)
    Technical Details of Soap Core Exception
    Message Text: SRT: ASSERT failed: object reference not bound
    Class: CL_SOAP_REGISTRY
    Method: generate_wsdl
    LocationID: 6
    Program: CL_SOAP_REGISTRY==============CP
    Include: CL_SOAP_REGISTRY==============CM00J
    Line: 59
    I found out that the exception is raised since CL_SRT_WSDL_GEN_FACTORY=>GET_WSDL_GENERATOR doesn't return an instance of the class referring to the interface IF_SRT_WSDL_GEN.
    If I test that method in SE24 using the name of the service definition in SE80 for the parameter WSD, the value '1' fpr the parameters TYPE and STYLE, an instance of the class CL_SRT_WSDL11_GEN is rendered.
    Could you give any hints how I could debug that issue to verify the import parameters when the static method CL_SRT_WSDL_GEN_FACTORY=>GET_WSDL_GENERATOR is called in the body of the browser call ?
    Or any other hints?
    Thank you very much and best regards
    Stefan

    The issue was due to missing authorizations of the RFC-user (type 'Communication') calling the webservice. The RFC-user itsself has been assigned before to the webservice in the http-service tree (transaction SICF). RFC-User needs (at least) the role SAP_BC_WEBSERVICE.

Maybe you are looking for