Search code examples
hyperledger-composer

Namespace is not defined for type org.comp.item


namespace org.comp.item

/* ASSETS */
asset Item identified by itemId {
    o String itemId
    o String itemData
}

namespace org.comp.transaction
import org.comp.item

/**
 * JUST FOR INITIALIZING A DEMO
*/
transaction SetupDemoItem {
}

transaction Get {
}

transaction CreateItem {
    o Item newItem
}

I have one cto file called item with a asset called item. And in other file called transaction a couple transactions.

In the transaction file I have a transaction that needs and asset from the other file. But I can´t make the transaction because i can´t do the import. That the error:

Error found!

t: Namespace is not defined for type org.comp.item


Solution

  • You need to import org.comp.item.* to bring in all the classes from that file or import org.comp.item.Item.

    Your class will then be called "$class": "org.comp.item.Item"