Arasu
Arasu

Reputation: 2148

include module routes in play framework

I have created a module in my play application and the structure of the module is

myApp/app/builder/modules/design

In myApp dependencies.yml i have given

# Application dependencies

require:
    - play
    - design -> design

repositories:
    - My modules:
        type:       local
        artifact:   /var/www/html/myApp/app/builder/modules/design
        contains:
            - design

In myApp routes

GET     /                                       Application.index
GET     /home                                   Application.index
GET     /design                                 module:design.index

The application runs successfully but when i access the design page in design module it throws error

10:13:58,247 ERROR ~ Cannot include routes for module design.index (not found)

What should i do to resolve this error.

When i add the module specification in application.conf

module.design=/var/www/html/myApp/app/builder/modules/design

Then it throws an error

The file {module:design}/app/controllers/Design.java could not be compiled. Error raised is : The declared package "builder.modules.design.app.controllers" does not match the expected package "controllers"

Upvotes: 1

Views: 2192

Answers (4)

Jayr Motta
Jayr Motta

Reputation: 718

I had a similar problem and figured that the problem happened because of a hyphen in my module name, I then changed it to underscores and it worked fine.

I can't test it right now but if I get some spare time I'll test whether it's because of the dot in the name of your project.

Upvotes: 0

bopa
bopa

Reputation: 1145

we had the same problem with play 1.2.4

we import our modules over dependencies.yml and got the same error. then, we deleted them from the deps.yml and just import over the application.conf.

works, although it's deprecated.

Upvotes: 1

Arasu
Arasu

Reputation: 2148

@pere i have created the design page and modified the design controller package name to

app.builder.modules.design.controllers

and in application.conf i added

module.design:app/builder/modules/design

and in dependencies.yml as

require:
    - play
    - myApp -> design

While run the console showed deprecation in application.conf and moudle design available in next line

But showed same error Then i I cut the builder folder and put into my myApp folder and changed the design controller package name to controllers and in application.conf

module.design:builder/modules/design

then everything is working

I found the error is in naming of the package So i again cut into the app folder and changed the design controller package name to

builder.modules.design.app.controllers

when i run the application it shows

The file {module:design}/app/controllers/Design.java could not be compiled. Error raised is : The declared package "builder.modules.design.app.controllers" does not match the expected package "controllers"

What could be the error

Upvotes: 1

Pere Villega
Pere Villega

Reputation: 16439

I believe your issue has to do with the location of your controller. Controllers are expected to be under package "controllers". It can be "controllers.subpackage1.subpackage2..."

Your controllers doesn't seem to follow that pattern

Upvotes: 0

Related Questions