CHESTERVILLE, Ontario — Inside garage-sized containers at one end of a cavernous warehouse in a former Nestlé factory south of Ottawa are rows of marijuana plants stacked atop each other, basking in the unearthly glow of grow lights.

They belong to Hamed Asi, an Ontario businessman who calls them his “vertical farm.” He has no background in growing marijuana, or in any kind of agriculture. His other line of business is installing office furniture; cubicles, filing cabinets and desk chairs fill the opposite end of the warehouse.

A financial boom not seen since the dot-com mania of the late 1990s has overtaken Canada. The legalization of recreational marijuana, scheduled for this autumn, is not only a momentous social change and public health challenge, but also a rare opportunity for entrepreneurs like Mr. Asi to be in on the birth of what they hope will become a multibillion-dollar industry.

Early signs of a boom abound: Marijuana growers have plowed millions into investments that, without having recorded profits yet, have stock-market values measured in billions. Down-on-their-luck towns like Chesterville, Ontario, hope that marijuana will reverse economic decline. Former politicians and law-enforcement officials who once opposed legalizing recreational marijuana have now joined or formed companies to cash in on it.