cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Error Accessing MegaRoot via Java API While MEGA Windows Client is Active

ACEstanislao
Super Contributor

I am getting an error running the following Java codes when MEGA Windows Client is currently open or active, on the same machine/server:

 

MegaApplication myapp = new MegaApplication();
        MegaEnvironment myenv = myapp.getEnvironments().get("D:\\Program Files (x86)\\MEGA\\Data Environment\\DEV_ENV");

        myenv.setCurrentAdministrator("mega");
        myenv.setCurrentPassword("megapassword");
        
        MegaTransactions mtransactions = myenv.transactions();
        
        MegaTransaction mytrans = mtransactions.create("Certification", "mega");
        MegaRoot myroot = mytrans.getOwnedDatabase().open();

 

I am getting error at highlighted line above. I cannot get reference to a MegaTransaction instance with the following error:

 

Exception in thread "main" MEGA Error 0x80020009(MegaTransaction.Create) : The application has encountered an error.
If this problem persists contact technical support.
    at com.mega.modeling.api.jni.MegaTransactionsJNI.Create(Native Method)
    at com.mega.modeling.api.jni.MegaTransactionsProxy.create(Unknown Source)
    at com.ace.test.SampleMegaConnection.main(SampleMegaConnection.java:24)

 

The program code is running without error, and I could retrieve and read MegaObjects from the repository whenever  I log-out,and exit the MEGA Windows Client.

 

I used a MEGA admin user to access via API, and I used my Windows-authenticated account to login to MEGA Windows Client.

 

What is wrong with this code line:

MegaTransaction mytrans = mtransactions.create("Certification", "mega");

that I could not start accessing MEGA simultaneously?

 

 

Thank you in advanced.

 

ACE

 

 

 

 

8 Replies

Hi Gregory,

 

THANK YOU VERY MUCH!

 

It now works with empty String argument in getRoot()

 

MegaRoot root = session.getRoot("");

 

It seems that the password argument is not required.

 

 

Cheers,

ACE

Hi, Could you try with just these 2 lines: MegaCurrentSession mysession = new MegaCurrentSession(); MegaRoot myroot = mysession.getRoot(""); ? It works for me Regards, Gregory

Thank you, Greg. I found the javadoc for that getRoot() method as you mentioned. However, I still got the problem getting the reference to the MEGA root:

 

getRoot.GIF

 

 

I have tried searching Google for MEGA Error 0x80010105, but I guess I did not find the right info.

 

MEGA Error.GIF

 

 

Does MEGA have reference for all possible MEGA Error codes it generates to find clues on problems like this?

 

 

Thanks again. Smiley Happy

Spoiler
 

 

 

Cheers,

ACE

 

 

 

 

The documentation is on the page for the MegaCurrentEnvironment interface.

 

Regards

Gregory

Thanks Greg!

 

I am able to detect whether MEGA session is currently open or not, but I tried using the password as argument but I am still getting same errors, and could not get reference to the MegaRoot:

 

Exception in thread "main" MEGA Error 0x80010105
    at com.mega.modeling.api.jni.MegaCurrentEnvironmentJNI.getGetRoot(Native Method)
    at com.mega.modeling.api.jni.MegaCurrentEnvironmentProxy.getRoot(Unknown Source)
    at com.ace.test.SampleMegaConnection.main(SampleMegaConnection.java:44)

 

Where can I get that JavaDoc you mentioned? I attached javadoc for mj_api.jar on my Eclipse project... The following are what I am getting:

 

MegaCurrentSession's parent class- MegaCurrentEnvironmentProxy, where getRoot() method is inherited, does not have documentation:

MegaCurrentSession Doc.png

 

 

 

MegaCurrentSession Doc2.GIF

 

 

I cannot find details for the inherited method: getRoot():

 

MegaCurrentSession Doc3.GIF

 

 

 

Can you please share where I could get the right documentation for MegaCurrentEnvironmentProxy.getRoot() method?

 

 

Thanks again for responding. I really appreciate this.

 

Regards,

ACE

 

 

Hi

 

No, this code works from outside MEGA too (MEGA must be running, if it is not the case this call will launch MEGA and display the connection dialog).

 

If you want to build a batch application it is better for you to use the MegaApplication class, you can run your application in a separate windows session to make sur no MEGA instance is running. 

 

 

This function is documented in the javadoc:

  • getRoot
    MegaRoot getRoot(java.lang.String password)
    Any code using this function should give the password of the current connected user.
    If the password is not given, a message appears in the MEGA session and the connected user can refused the external connection failing the program execution.
    From the 6.1 release, if there is no session already opened, the connection dialog is displayed. This functionality may be deactivate using the SetOpenToken function.
    Parameters: password - Returns: an access to the current repository.


@gquiniou wrote:

Hi ACE,

 

You can only use MegaApplication when the MEGA Windows application is not running.

As an alternative you can use MegaCurrentSession to access the current session when MEGA is open:

 

MegaRoot myRoot = new MegaCurrentSession().getRoot("");

Gregory

 


 

 

 

Hi Gregory,

 

Thanks for the response. Can you confirm: the code that you provided only works when the Java program containing that instruction is invoked (via some sort of Macro) from the current MEGA Windows application, right?

 

I am trying to develop a Java program that runs scheduled process of connecting to MEGA. This program must be able to processes some Mega Objects whether the MEGA Windows application is open or not.

 

Also, what's that empty String parameter here?

new MegaCurrentSession().getRoot("");

 

I tried checking for Java Documentation for MeagaCurrentSession class, unfortunately no JavaDoc is available.

 

 

ACE

 

gquiniou
Retired

Hi ACE,

 

You can only use MegaApplication when the MEGA Windows application is not running.

As an alternative you can use MegaCurrentSession to access the current session when MEGA is open:

 

MegaRoot myRoot = new MegaCurrentSession().getRoot("");

Gregory