Vishwanath
Vishwanath

Reputation: 11

shopping-api module classes not found in shopping-web

I have created liferay project using versionportal-7.1-ga3. In web module, While trying to fetch list of Products and iterating that list in Web module ViewProductsMVCRenderCommand class, That time getting javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/project/demo/model/Product, In this point api model classes and service classes not accessible in web-module .

I have exported model as well as service packages in shopping-api bnd.bnd file and Imported those packages in shopping-web bnd.bnd file, I also tried to import those service builder generated modeles and services with Import-Service OSGi manifest headers, But still getting same error. Here is my project github repository link https://github.com/vishwa-np/demo.git. After adding dependencies, package export and import, shopping-api and shopping-service module classes not finding in shopping web module.

Shopping-api bnd.bnd

Bundle-Name: shopping-api
Bundle-SymbolicName: com.project.demo.api
Bundle-Version: 1.0.0
Export-Package:\
    com.project.demo.exception,\
    com.project.demo.model,\
    com.project.demo.service.persistence,\
    com.project.demo.service

-check: EXPORTS
-includeresource: META-INF/service.xml=../shopping-service/service.xml

Shopping-service bnd.bnd

Bundle-Name: shopping-service
Bundle-SymbolicName: com.project.demo.service
Bundle-Version: 1.0.0
Liferay-Require-SchemaVersion: 1.0.0
Liferay-Service: true

Export-Package: \
    com.project.demo.service.*,\
    com.project.demo.model.impl.*

Shopping-web bnd.bnd

Bundle-Name: shopping-web
Bundle-SymbolicName: com.web.project.demo
Bundle-Version: 1.0.0
Export-Package: com.web.project.demo.constants

Import-Package: \
    !com.project.demo.exception.*,\
    !com.project.demo.model.*,\
    !com.project.demo.service.persistence.*,\
    !com.project.demo.service.*,\
    !com.project.demo.model.impl.*,\
    !com.project.demo.service.impl.*,\
    *

Import-Service: \
    !com.project.demo.exception.*,\
    !com.project.demo.model.*,\
    !com.project.demo.service.persistence.*,\
    !com.project.demo.service.*,\
    *

Upvotes: 0

Views: 50

Answers (1)

Olaf Kock
Olaf Kock

Reputation: 48057

In your shopping-web you are explicitly forbidding the imports (see the "!"):

Import-Package: \
    !com.pro...

I'd expect bnd to do the wiring for you if your dependencies are declared well, so you'd need not a single explicit import in bnd.bnd

When the module is generated for you, the wiring should be good. Or compare your code with this sample (use the branch for your version)

Upvotes: 0

Related Questions