Cannot use class defined in another namespace even with package mapping

Primary tabs

Hi,

I have two namespaces

  1. In the first one, I have defined a class which Extends (%Persistent, Ens.Util.MessageBodyMethods), we'll call it NSOne.Msg.Req
  2. In the second namespace NSTwo, I want to use the previous class with something like SET pInput = ##class(NSOne.Msg.Req).%New()

I mapped the NSOne.Msg.Req package in namespace NSOne. In Atelier, I can see NSOne.Msg.Req in my NSOne. But, when I try to execute line 2 above, it tells me :

{
    "status": {
        "errors": [
            {
                "error": "ERROR #5002: ObjectScript error: <PROTECT>^NStwo.Api.1 ^|^^/folder/NSONE_SRC/|NSOne.Msg.Req.1",
                "code": 5002,
                "domain": "%ObjectErrors",
                "id": "ObjectScriptError",
                "params": [
                    "<PROTECT>^NStwo.Api.1 ^|^^/folder/NSOne_SRC/|NSOne.Msg.RQ.Patient.1"
                ]
            }
        ],
        "summary": "ERROR #5002: ObjectScript error: <PROTECT>^NSTwo.Api.1 ^|^^/folder/NSONE_SRC/|NSOne.Msg.Req.1"
    },
    "content": null
}

 

Please note that if I open an IRIS session, set current namespace as NSTwo then it works:

NStwo > SET pInput = ##class(NSOne.Msg.Req).%New()

What did I miss ?

Replies

<PROTECT> error means you can't access database in the /folder/NSOne_SRC/ directory.

Give the user required rights (at the very least R on that DB) and start a new session.

You are right, my calling code is inside a web application, so I need to give the ressource %NSone_SRC to the web application.

Thank you.