Why specifying an exception???

What are the benefits of specifying what kind of exception you are catching as:
try{
    //do something
} catch(RemoteException e){
    e.printStackTrace();
why not
try{
    //do something
} catch(Exception e){
    e.printStackTrace();
RemoteException or Exception... Exception works with all type of exepctions but why should I specify as "RemoteException"???

jschell wrote:
emailkia wrote:
Thank you jduprez for your reply...
but we say I am not intressted of giving any message about RemoteException or do anything about it then "Exception" would be good enough to use??? Because if I am only reading the logg for exception, e.printStackTrace() would provide me complete information about the exception no matter if I use "RemoteException" or "Exception". Am I right?You catch exceptions because you are going to do something with them or because of them.
You don't catch them if you are not going to do something with them.
In general logging is NOT sufficient for catching an exception. It still must do something else. Such as return a default value or throw a different exception.Although there are cases where it's appropriate to just catch and log. For instance, in a top-level processing loop, if processing one element shouldn't stop the loop from continuing on to the next element. However, even in those cases, you'd probably want to catch individual checked exceptions (or root-level checked exceptions by family) individually, and then catch RuntimeExeption to grab all the non-Error unchecked exceptions, and, then maybe Error.
while (!done) {
  try {
    process();
  catch (IOException ex) {
    // log it, possibly handle it
  catch (InterruptedException ex) {
    // log it, possibly rethrow, or call Thread.currentThread().interupt()
  catch (RuntimeExcetpion ex) {
    // log it
  // Maybe, maybe not include the following
  catch (Error ex) {
    // log it
}This way, your main processing loop will continue even if there's a problem, but you're not blindly catching all checked exceptions. If the underlying process() routine adds a new checked exception to its throws clause, you'll be made aware of it next time you compile, and will have to deal with it. If you just caught Exception, that would not be the case.

Similar Messages

  • Office 365 App using NAPA - "The system cannot find the file specified. (Exception from HRESULT: 0x80070002)"

    Hello,
    I am creating an app using NAPA tool in Office 365. I am trying to "Add an attachment" to a custom list item using SPServices. When I am using my code  (jquery code) in content editor web part on a page, its working fine, but when I am adding
    the same code in an app, its giving me error :  "The system cannot find the file specified. (Exception from HRESULT:
    0x80070002)" - 500 Internal Server error.
    (function () {
    // This code runs when the DOM is ready and creates a context object which is
    // needed to use the SharePoint object model
    $(document).ready(function () {
    //alert('In doc ready');
    $('.attachmentButton').change(function(event){
    var listName = 'UploadTest',
    itemId = 2;
    handleFileChange(listName,itemId,event.target.files);
    function handleFileChange(listName,itemId,files){
    alert('In handleFileChange :=' + listName + "" + itemId + "" + files[0]);
    alert('files.length :=' + files.length);
    var filereader = {},
    file = {},
    i=0;
    //loop over each file selected
    for(i = 0; i < files.length; i++) {
    alert('In for loop');
    file = files[i];
    filereader = new FileReader();
    filereader.filename = file.name;
    alert('filereader.filename :=' + filereader.filename);
    filereader.onload = function() {
    var data = this.result;
    var n=data.indexOf(";base64,") + 8;
    //alert('n :=' + n);
    //removing the first part of the dataurl give us the base64 bytes we need to feed to sharepoint
    data= data.substring(n);
    //alert('data :=' + data);
    alert('Above SPServices this.filename :=' + this.filename);
    $().SPServices({
    operation: "AddAttachment",
    listName: listName,
    asynch: false,
    listItemID:itemId,
    fileName: this.filename,
    attachment: data,
    completefunc: function (xData, Status) {
    console.log('attachment upload complete',xData,status);
    alert('Status :=' + Status);
    if (Status.toLowerCase() == "error"){
    alert(xData.responseText);
    alert(xData.status);
    alert(xData.statusText);
    filereader.onabort = function() {
    alert("The upload was aborted.");
    filereader.onerror = function() {
    alert("An error occured while reading the file.");
    //fire the onload function giving it the dataurl
    filereader.readAsDataURL(file);
    alert(xData.responseText); - gives error - " "The system cannot find the file specified. (Exception from HRESULT: 0x80070002)""
    alert(xData.status); - gives error - "500"
    alert(xData.statusText); - gives error - "Internal server error"
    Server Publishing infrastructure and Server publishing features are activated on site collection and site respectively.
    Any suggestions, why I am getting this error in NAPA ?

    Hi,
    According to your post, my understanding is that you have an issue about adding attachments to list items in app.
    To add attachment to list item in the host web, we should first get the list and the list items from the host web, then add the attachments to the list items.
    There are two articles about retrieve the list and list items in the host web, you can refer to them.
    http://www.dotnetcurry.com/showarticle.aspx?ID=1028
    http://www.c-sharpcorner.com/UploadFile/93cb27/retrieve-sharepoint-app-host-web-list-items-in-sharepoint-ho/
    What’s more, we can also use the REST API to achieve the same scenario.
    http://www.c-sharpcorner.com/UploadFile/472cc1/add-attachments-to-list-items-in-sharepoint-2013-using-rest/
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • VSTO.dll The system cannot find the file specified. (Exception from HRESULT: 0x80070002)

    Hello,
    I'm trying to install a VSTO on a clients machine and get the following error message.
    Could this be something wrong with the .Net Version?
    Application Domain:    AWAddinInstaller.exe
    Assembly Codebase:     update files/AWAddinInstaller.exe
    Assembly Full Name:    AWAddinInstaller, Version=9.2.0.14, Culture=neutral, PublicKeyToken=null
    Assembly Version:      9.2.0.14
    Assembly Build Date:   11/12/2013 12:12:58 PM
    Exception Source:      mscorlib
    Exception Type:        System.IO.FileNotFoundException
    Exception Message:     The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
    Exception Target Site: nLoadFile
    ---- Stack Trace ----
       System.Reflection.Assembly.nLoadFile(path As String, evidence As Evidence)
           AWAddinInstaller.exe: N 00000
       System.Reflection.Assembly.LoadFile(path As String)
           AWAddinInstaller.exe: N 00084
       AWAddinInstaller.AWAddinInstaller.RegisterAddin(forceVSTO As Boolean)
           AWAddinInstaller.exe: N 00602

    Hello AntronD,
    The installer complained that The system cannot find the file specified. However I'm confused that why the VSTO is related to AWAddinInstaller.exe.
    Could you please navigate to your %temp% folder and search for your VSTO logs out and paste it here? I need it to check for details.
    Regards,
    Barry
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • The system cannot find the file specified. (Exception from HRESULT: 0x80070002)

    I m getting this error on page load of visual webpart added to the sharepoint site.What could be the issue??I m getting this error like in dev and not in test environment..What could be the issue??
    The system cannot find the file specified. (Exception from HRESULT: 0x80070002)

    could you please share complete stack trace of the error, there could be differnt reason for this error?
    share the stack trace and also check the ULS logs.
    did you try to redeploy the webpart( completely removing and re adding)?
    Please remember to mark your question as answered &Vote helpful,if this solves/helps your problem. ****************************************************************************************** Thanks -WS MCITP(SharePoint 2010, 2013) Blog: http://wscheema.com/blog

  • „The system cannot find the file specified. (Exception from HRESULT: 0x80070002)" - Error when trying to create an new controlled GPO

    Hello,
    we were planning to Upgrade from AGPM 4.0 to AGPM 4.0 SP2. The new AGPM should be placed on a new server. Additionally we created a new service account as the password of the old service account has been lost. We granted the new service account Full Rights
    in "Domain Delegeation" and "Product Delegation", then stopped the AGPM Service on the old server.
    On the new server AGPM was installed using the new service account, then the service was stopped and the archive was copied rom the old to the new server. The customer could edit policies, but not deploy them. Because of this, we changed back to the old
    server, but copied the folders that were changed on the new server to keep them up to date.
    Now creating a controlled Group Policy from a template causes the error
    „The system cannot find the file specified. (Exception from HRESULT: 0x80070002). We tried several templates and even created new ones but the problem persists.
    The following things do work:
    - editing a controlled policy
    - renaming a controlled policy
    - check in/check out of a policy
    - set a uncontrolled policy to controlled (needs to grant the serviceaccount Full rights to the policy before)
    - deletion of a controlled policy
    - creating a template from a policy
    Thank you in advance for your help.

    0x80070002 usually means that the source could not be found or located. Make sue that the FQDN path to your templates is the correct one as well as your DNS is
    properly configured.
    sharing some manuals @: http://1drv.ms/1kk6u6j

  • While creating web application prokect getting error: The system cannot find the file specified. (Exception from HRESULT: 0x80070002)

    I am getting error on creating even the empty web application project. The error message is as given below:
    The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
    I am using following build of Visual Studio:
    Visual Studio Professional 2013. Version 12.0.30723.00 Update 3
    Looks like it is the problem with the installation of the visual studio. But I can't take risk of re-installing now because it would stop my going on development work.
    Any would help to resolve this would be appreciated.
    P.S. I am also having Visual Studio 2010 and Visual Studio 2012 Ultimate on my system.
    Regards, Randeep

    Hello Randeep,
    Will you get the same error when creating any other apps, like C# WinForm?
    If only web application project has the problem, you can try the following to reset the templates:
    Please open Windows Explorer, and navigate to  <Visual Studio Installation Path>\Common7\IDE (by default is C:\Program Files \Microsoft Visual Studio 12.0\Common7\IDE);
    Delete the ItemTemplatesCache, ProjectTemplatesCache folder;
    Open Visual Studio Tools/Developer Command Prompt for VS2013
    under Start menu -> All Programs -> Microsoft Visual Studio 2013 -> Visual Studio Tools (run it with Administrator privilege: right-click the program -> Run as administrator);
    Run the devenv /InstallVSTemplates switch;
    Run the devenv /Setup switch
    If all your projects get this error, please try repair the installaiton from control panel first. By the way, can you use Visual Studio Web projects before you get this error? And have you tried to use the Visual Studio Update 4, I see you still used
    Update 3, is there any reason for you to still use the Update 3 version?
    Best regards,
    Barry
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Invoke-IpamGpoProvisioning : Failed to import GPO. The system cannot find the file specified. (Exception from HRESULT: 0x80070002)

    Hello Im trying to configure IPAM but im getting this error.
    PS C:\Users\Administrator.IPADE.MX> Invoke-IpamGpoProvisioning –Domain actdir.ipade.mx –GpoPrefixName IPAM –IpamServerFq
    dn minte.actdir.ipade.mx –DelegatedGpoUser Administrator -DomainController discovery.actdir.ipade.mx
    Invoke-IpamGpoProvisioning : Failed to import GPO. The system cannot find the file specified. (Exception from HRESULT:
    0x80070002)
    At line:1 char:1
    + Invoke-IpamGpoProvisioning –Domain actdir.ipade.mx –GpoPrefixName IPAM –IpamServ ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [Invoke-IpamGpoProvisioning], Exception
        + FullyQualifiedErrorId : InvalidOperation,Invoke-IpamGpoProvisioning
    In the event viewer  I founf this but I don't know what to do.
    Import of backup failed. Error [The system cannot find the file specified.
    Details -
         Backup
             Directory: The system cannot find the file specified.
             Instance : C:\Users\Administrator.IPADE.MX\AppData\Local\Temp\1\ipamprov
             Comment  : {09673450-4573-42E8-85D0-104144DF0BA3}
             Source GPO:
                 DisplayName: IPAMGPO_DNS
                 ID: IPAMGPO_DNS
                 Domain: {7F345996-1D92-4194-85BF-72BFB5298EDA}
         Destination GPO:
                 DisplayName: ipamtestsetup.com
                 ID: IPAM_DNS
                 Domain: {447E8380-91AF-4C2D-8DAA-2C090A6400E8}

    Hi,
    Before going further, what was name specified in the IPAM provisioning wizard while selecting Group Policy based provisioning method? The GPO prefix name specified in the
    PowerShell command must be same as the one specified in the IPAM provisioning wizard while selecting Group Policy based provisioning method.
    Regarding Invoke-IpamGpoProvisioning, the following article can be referred to as reference.
    Invoke-IpamGpoProvisioning
    http://technet.microsoft.com/en-us/library/jj553805.aspx
    Best regards,
    Frank Shen

  • All my Storage giving "The system cannot find the file specified. (Exception from HRESULT: 0x80070002)"

    I purchased Microsofts "All My Storage Pro" and so fare its been one disappointment after another but I won't go into all the problems I've had just the latest one. I was attempting to upload a file from my c:\Download folder to my OneDrive and
    received a "The system cannot find the file specified. (Exception from HRESULT: 0x80070002)". Now I know the file is there because I just installed it from there, So whats the deal? and can I get my money back from Microsoft
    for this disaster of an app?
    Robert L. Massie

    I purchased Microsofts "All My Storage Pro" and so fare its been one disappointment after another but I won't go into all the problems I've had just the latest one. I was attempting to upload a file from my c:\Download folder to my OneDrive and
    received a "The system cannot find the file specified. (Exception from HRESULT: 0x80070002)". Now I know the file is there because I just installed it from there, So whats the deal? and can I get my money back from Microsoft
    for this disaster of an app?
    Robert L. Massie

  • I am facing a problem while deploying an Entity bean in iPlanet(sp3).I have attached the exception thrown.Why has this exception occured?

    [04/Dec/2001 10:54:00:2] error: EBFP-marshal_internal: internal exception caught in kcp skeleton, ex
    ception = java.lang.NullPointerException
    [04/Dec/2001 10:54:00:2] error: Exception Stack Trace:
    java.lang.NullPointerException
    at java.util.Hashtable.get(Hashtable.java:321)
    at com.netscape.server.ejb.SQLPersistenceManager.<init>(Unknown Source)
    at com.netscape.server.ejb.SQLPersistenceManagerFactory.newInstance(Unknown Source)
    at com.netscape.server.ejb.EntityDelegateManagerImpl.getPersistenceManager(Unknown Source)
    at com.netscape.server.ejb.EntityDelegateManagerImpl.doPersistentFind(Unknown Source)
    at com.netscape.server.ejb.EntityDelegateManagerImpl.find(Unknown Source)
    at com.kivasoft.eb.EBHomeBase.findSingleByParms(Unknown Source)
    at samples.test.ejb.Entity.ejb_home_samples_test_ejb_Entity_TestEntityBean.findByPrimaryKey(
    ejb_home_samples_test_ejb_Entity_TestEntityBean.java:126)
    at samples.test.ejb.Entity.ejb_kcp_skel_TestEntityHome.findByPrimaryKey__samples_test_ejb_En
    tity_TestEntity__int(ejb_kcp_skel_TestEntityHome.java:266)
    at com.kivasoft.ebfp.FPRequest.invokenative(Native Method)
    at com.kivasoft.ebfp.FPRequest.invoke(Unknown Source)
    at samples.test.ejb.Entity.ejb_kcp_stub_TestEntityHome.findByPrimaryKey(ejb_kcp_stub_TestEnt
    ityHome.java:338)
    at samples.test.ejb.Entity.ejb_stub_TestEntityHome.findByPrimaryKey(ejb_stub_TestEntityHome.
    java:85)
    at samples.test.ejb.TestEJB.getGreeting(TestEJB.java:51)

    Hi,
    I think you are trying to test the Hello world EJB example shipped with the product. As a first
    step I would recomend you to go through every line of the document on deploying this application,
    since, I too have experienced many errors while trying to deploy the sample applications, but on
    following the documentation, I subsequently overcame all the errors and have been working with the
    applications. So please follow the steps in documentation and let me know, if you still encounter any
    issues.
    Regards
    Raj
    Sandhya S wrote:
    I am facing a problem while deploying an Entity bean in iPlanet(sp3).I
    have attached the exception thrown.Why has this exception occured?
    [04/Dec/2001 10:54:00:2] error: EBFP-marshal_internal: internal
    exception caught in kcp skeleton, ex
    ception = java.lang.NullPointerException
    [04/Dec/2001 10:54:00:2] error: Exception Stack Trace:
    java.lang.NullPointerException
    at java.util.Hashtable.get(Hashtable.java:321)
    at
    com.netscape.server.ejb.SQLPersistenceManager.<init>(Unknown Source)
    at
    com.netscape.server.ejb.SQLPersistenceManagerFactory.newInstance(Unknown
    Source)
    at
    com.netscape.server.ejb.EntityDelegateManagerImpl.getPersistenceManager(Unknown
    Source)
    at
    com.netscape.server.ejb.EntityDelegateManagerImpl.doPersistentFind(Unknown
    Source)
    at
    com.netscape.server.ejb.EntityDelegateManagerImpl.find(Unknown Source)
    at com.kivasoft.eb.EBHomeBase.findSingleByParms(Unknown
    Source)
    at
    samples.test.ejb.Entity.ejb_home_samples_test_ejb_Entity_TestEntityBean.findByPrimaryKey(
    ejb_home_samples_test_ejb_Entity_TestEntityBean.java:126)
    at
    samples.test.ejb.Entity.ejb_kcp_skel_TestEntityHome.findByPrimaryKey__samples_test_ejb_En
    tity_TestEntity__int(ejb_kcp_skel_TestEntityHome.java:266)
    at com.kivasoft.ebfp.FPRequest.invokenative(Native Method)
    at com.kivasoft.ebfp.FPRequest.invoke(Unknown Source)
    at
    samples.test.ejb.Entity.ejb_kcp_stub_TestEntityHome.findByPrimaryKey(ejb_kcp_stub_TestEnt
    ityHome.java:338)
    at
    samples.test.ejb.Entity.ejb_stub_TestEntityHome.findByPrimaryKey(ejb_stub_TestEntityHome.
    java:85)
    at samples.test.ejb.TestEJB.getGreeting(TestEJB.java:51)
    Try our New Web Based Forum at http://softwareforum.sun.com
    Includes Access to our Product Knowledge Base!

  • Why we use exception ???

    Why we use Exception ??anyone knows what are the 3 keys point below describe about..??
    There are 3 main Advantages of using Exception
    1.Separates error handling code from "regular code
    2.Propagating erros up the call stack (without tedious programming)
    3.Grouping error type and error differentiation
    TQ.

    hi,
    1) you can catch those exceptions and write extra classes for handling/log them, so you do not have to do between the lines of source
    2) if an uncaught exception happens an errorstack will be invoked. On the stack you can see, where the exception started and which classes are involved
    3) you can have very special erros, for example all errors which occurs on files (normally it is an IOException), you can define your own exceptions so you can say, i.e. line 503 doesn't contain what it should.
    With this way you can resolve very well where an exception raises and why it happens.
    hope it answers
    regards
    freak

  • Invalid J2EE application file specified - Nested exception

    Hai,
    I got the following error while i tried to u deploy .ear file into OC4J Portal. the error is
    // error
    Invalid J2EE application file specified - Nested exception Root Cause: Invalid Document Key
    OC4J_INSTANCE_ID:OC4J_Portal;applicationName:protasco; for plugin OC4J.. Invalid Document Key
    OC4J_INSTANCE_ID:OC4J_Portal;applicationName:protasco; for plugin OC4J.
    // error
    what could be the reason.. Due to this the server is down..
    Please help me by ur sugestion
    Thanks in advance
    Damodar

    I'm getting the same error. Any help would be appreciated!

  • Why customize application exception this way?

    hi
    i found too different ways to customize a same application exception
    they actually work the same way but with a little difference that i can not figure out why
    the first one is
    public class BaseAppException extends Exception {
        static final long serialVersionUID = -5829545098534135052L;
         * the message of the BaseAppException.
        private String exceptionMessage;
         * A public constructor for BaseAppException containing no arguments.
        public BaseAppException() {
         * A public constructor for BaseAppException specifying exception message.
         * <p>
         * @param msg
         *            exception message.
        public BaseAppException(String msg) {
            this.exceptionMessage = msg;
        }it uses a private member "exceptionMessage" to store the exception message
    and here is the second piece of code
    public class BaseAppException extends Exception {
        static final long serialVersionUID = -5829545098534135052L;
         * A public constructor for BaseAppException containing no arguments.
        public BaseAppException() {
         * A public constructor for BaseAppException specifying exception message.
         * <p>
         * @param msg
         *            exception message.
        public BaseAppException(String msg) {
             super(msg);
    //        this.exceptionMessage = msg;
        }this one passes the message to the base throwable
    both works but i am wondering why define a private string memeber for message storing and not pass it to the base throwable??

    I'm not sure what you're trying to do here, but at
    first glance "TestK t = new TestK();" inside the for
    loop seemed unusual.
    If you place it before the loop it works fine.I guess what he is trying to ask is that why is that if you use the new operator in the code, you donot get the exception while if you dont use it you do get one. While in any case either you use it or not you are supposed to get a new String as per the String API.
    Well thats an interesting observation and I have no explanation as to why is this happening. I do remember that thread where somebody pointed this out as a use of the String(String original) construtor. Furtehr adding on to that the API states about this constructor the following
    Initializes a newly created String object so that it represents the same sequence of characters as the argument; in other words, the newly created string is a copy of the argument string.
    so I donot get why not using it would cause the exception to be thrown. I have tested the code though and it seems to behave as pointed in the original post.
    Interesting question though, food for thought.

  • Why bad padding exception???

    hi guys
    here i am trying to decrypt the already encrypted string by one different encrpytion algo.
    in the example i have encrypted the string by des and then i tried to decrypt it using blowfish but it gives as the output null instead of a random string...because of a bad padding exception(check line 86). help to remove the exception.
    if we try to decrypt the des encrypted string by des again it give n padding exception. why with blowfish???
    // CIPHER / GENERATORS
    import javax.crypto.Cipher;
    import javax.crypto.SecretKey;
    import javax.crypto.KeyGenerator;
    // KEY SPECIFICATIONS
    import java.security.spec.KeySpec;
    import java.security.spec.AlgorithmParameterSpec;
    import javax.crypto.spec.PBEKeySpec;
    import javax.crypto.SecretKeyFactory;
    import javax.crypto.spec.PBEParameterSpec;
    // EXCEPTIONS
    import java.security.InvalidAlgorithmParameterException;
    import java.security.NoSuchAlgorithmException;
    import java.security.InvalidKeyException;
    import java.security.spec.InvalidKeySpecException;
    import javax.crypto.NoSuchPaddingException;
    import javax.crypto.BadPaddingException;
    import javax.crypto.IllegalBlockSizeException;
    import java.io.UnsupportedEncodingException;
    import java.io.IOException;
    public class StringEncrypter {
    Cipher ecipher;
    Cipher dcipher;
    StringEncrypter(SecretKey key, String algorithm) {
    try {
    ecipher = Cipher.getInstance(algorithm);
    dcipher = Cipher.getInstance(algorithm);
    ecipher.init(Cipher.ENCRYPT_MODE, key);
    dcipher.init(Cipher.DECRYPT_MODE, key);
    } catch (NoSuchPaddingException e) {
    System.out.println("EXCEPTION: NoSuchPaddingException");
    } catch (NoSuchAlgorithmException e) {
    System.out.println("EXCEPTION: NoSuchAlgorithmException");
    } catch (InvalidKeyException e) {
    System.out.println("EXCEPTION: InvalidKeyException");
    public String encrypt(String str) {
    try {
    // Encode the string into bytes using utf-8
    byte[] utf8 = str.getBytes("UTF8");
    // Encrypt
    byte[] enc = ecipher.doFinal(utf8);
    // Encode bytes to base64 to get a string
    return new sun.misc.BASE64Encoder().encode(enc);
    } catch (BadPaddingException e) {
    } catch (IllegalBlockSizeException e) {
    } catch (UnsupportedEncodingException e) {
    } catch (IOException e) {
    return null;
    public String decrypt(String str) {
    try {
    // Decode base64 to get bytes
    byte[] dec = new sun.misc.BASE64Decoder().decodeBuffer(str);
    // Decrypt
    byte[] utf8 = dcipher.doFinal(dec);
    // Decode using utf-8
    return new String(utf8, "UTF8");
    } catch (BadPaddingException e) {
    System.out.println("BAd padding excception");
    } catch (IllegalBlockSizeException e) {
    System.out.println("IllegalBlockSizeException");
    } catch (UnsupportedEncodingException e) {
    System.out.println("UnsupportedEncodingException");
    } catch (IOException e) {
    System.out.println("IOException");
    return null;
    public static void testUsingSecretKey() {
    try {
              String secretString = "code cant be decrypted!";
              SecretKey desKey = KeyGenerator.getInstance("DES").generateKey();
              SecretKey blowfishKey = KeyGenerator.getInstance("Blowfish").generateKey();
         StringEncrypter desEncrypter = new StringEncrypter(desKey, desKey.getAlgorithm());
              StringEncrypter blowfishEncrypter = new StringEncrypter(blowfishKey, blowfishKey.getAlgorithm());
              String desEncrypted = desEncrypter.encrypt(secretString);     
         String desDecrypted = desEncrypter.decrypt(desEncrypted);
         String blowfishDecrypted = blowfishEncrypter.decrypt(desEncrypted);      
         System.out.println(desKey.getAlgorithm() + " Encryption algorithm");
         System.out.println(" Original String : " + secretString);
         System.out.println(" Encrypted String : " + desEncrypted);
         System.out.println(" Decrypted String : " + desDecrypted);
         System.out.println();
         System.out.println(blowfishKey.getAlgorithm() + " Encryption algorithm");
         System.out.println(" Original String : " + desEncrypted);
         System.out.println(" Decrypted String : " + blowfishDecrypted);
         System.out.println();
         } catch (NoSuchAlgorithmException e) {
         public static void main(String[] args) {
         testUsingSecretKey();
    }

    peter_crypt wrote:
    you are right but this is my question. why cant we do that?? it should be possible.by the way i am working on a project for cryptanalysis . there i need to implement it.You need to spend more time studying and less time programming -
    1) Applied Cryptography, Schneier, Wiley, ISBN 0-471-11709-9
    2) Practical Cryptography, Ferguson and Schneier, Wiley, ISBN 0-471-22357-3
    3) Java Cryptography, Knudsen, O'Reilly, ISBN 1-56592-402-9 dated but still a good starting point
    4) Beginning Cryptography with Java, written by David Hook and published by WROX .

  • Cannot find the specified instance exception

    Hello,
    I am having a problem with my Bpel process.
    when I post to XML, i am getting the following:
    <Fault env="http://schemas.xmlsoap.org/soap/envelope/" >
    <faultcode>env:Server</faultcode>
    <faultstring>java.lang.IllegalStateException: Cannot call setRollbackOnly() current thread is NOT associated with a transaction</faultstring>
    </Fault>
    what does this mean ?
    why is it happening ?
    How can resolve this issue ?
    This is urgent,
    Thanks everyone,
    AJ

    sorry, it took a while to respond. are you still facing the issue? this sounds like, there was some system exception where the j2ee container terminated/ended the jta transaction but the exception reached to bpel engine layer where bpel engine trying to set rollback only on an already ended transaction hence this error. the root issue is why the j2ee container ended that jta transaction, is there any other exceptions before this exception in the log file. i assume some kind of timeout or system exceptions happened before reaching the setRollbackOnly call.

  • Why specify Integration server when create Business system?

    Hi, all:
    I had difficult understanding why we need to specify the assigned Integration Server when we create Business System. What is the reason for this? What is the mechanism underbeneath this?
    It is easy to understand that when creating BS, you need to specify TS name, product and SWCV. But why integration server?
    Will you please explain to what your understanding it regarding this topic?
    Thanks,

    This is because the same SLD could be used to connect to more than one Integration Server. This is a typical requirement wherein the system landscape has Dev, Quality & Production systems and all the XI servers uses same SLD. At that time it would be easy to specify which Business system will refer the Integration Server of which XI system.
    Regards,
    Prateek

Maybe you are looking for

  • [Mac] Could not complete your request because of a program error.

    Hello, I've got the problem with opening the file. It was saved in Photoshop CS 6, everything was ok, but after opening the file in few seconds here the message "Could not complete your request because of a program error." What should I do?? It was m

  • MacBook Pro freezes when it connects to internet

    All of a sudden my computer freezes (spinning wheel) anytime I connect it to the internet. Does anyone know what I can do to fix this? I have rebooted several times and have enough memory. What could it be? Thanks in advance

  • Date format in apex items

    Hi, i have a Problem with the formating of a table colum.   , NVL2(p.buchungsdatum,       APEX_ITEM.DISPLAY_AND_SAVE(8,TO_CHAR(p.abschlussdatum,'DD.MM.YYYY')),       APEX_ITEM.DATE_POPUP(8,rownum,p.abschlussdatum,'DD.MM.YYYY',15,30)) abschlussdatum I

  • Solaris 8 (INTEL) - Interrupt handler

    We are developing a device driver for a PCI card. The interrupt level assigned is 10 and the priority level is 6. In the interrupt handler, we first check whether our device has generated the interrupt and if not return with DDI_INTR_UNCLAIMED otherw

  • Formula in Crystal

    Hi, I am trying to use a formula in crystal report. I have a dataset that contains list of customers. I wanna assign different numbers on report to each customer. I dont have any idea how to do it. Any help. Thanks