Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Liferay 7.2 JAX-RS CXF or Whiteboard Pattern??
Hello,I have installed Liferay 7.2 for Widfly on my local machine. I have written JAX-RS webservice under 7.0 CE GA3 thats in production and stable. I am migrating my code to 7.2. Can I used the CXF implementation code from my 7.0 GA3 into 7.2.1 CE GA2? Or do I have completey write my code using the Whiteboard Pattern?
My Second question, I was able to successfullly test was greetings sample application using the whiteboard pattern but now while I used the whiteboard pattern I am getting an exception dont know what changed
Caused by: java.lang.NoClassDefFoundError: javax/ws/rs/core/Application
my build.gradledependencies {
compileOnly group: "javax.ws.rs", name: "javax.ws.rs-api", version: "2.0.1"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations", version: "1.3.0"
compileOnly group: "org.osgi", name: "org.osgi.service.jaxrs", version: "1.0.0"
compile 'org.apache.commons:commons-lang3:3.2.1'
compile 'commons-io:commons-io:2.4'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
compile 'com.liferay.portal:com.liferay.portal.kernel:4.0.0'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.5'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.8.5'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.5'
compileOnly project("
rojectManager-api")
}
My Second question, I was able to successfullly test was greetings sample application using the whiteboard pattern but now while I used the whiteboard pattern I am getting an exception dont know what changed
Caused by: java.lang.NoClassDefFoundError: javax/ws/rs/core/Application
my build.gradledependencies {
compileOnly group: "javax.ws.rs", name: "javax.ws.rs-api", version: "2.0.1"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations", version: "1.3.0"
compileOnly group: "org.osgi", name: "org.osgi.service.jaxrs", version: "1.0.0"
compile 'org.apache.commons:commons-lang3:3.2.1'
compile 'commons-io:commons-io:2.4'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
compile 'com.liferay.portal:com.liferay.portal.kernel:4.0.0'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.5'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.8.5'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.5'
compileOnly project("

}
Maybe these two resources can be of help to you. Did you fix all the stuff discussed in these articles? https://liferay.dev/blogs/-/blogs/osgi-module-dependencies
https://portal.liferay.dev/docs/7-0/tutorials/-/knowledge_base/t/adding-third-party-libraries-to-a-module
https://portal.liferay.dev/docs/7-0/tutorials/-/knowledge_base/t/adding-third-party-libraries-to-a-module
Thanks Chandra I will take a look. I was able to get Rest Extender webservice going but now my service Util classes from service builder is throwing a null pointer exception
NoClassDefFoundError's are a pain. But in my experience, I'll stick to looking at the MANIFEST.MF or headers <bundle_id> on the gogo shell, because they are the final source of truth to Liferay / OSGI. They're generated using a combination of bnd tools and gradle/maven. (To me, how they generate Manifest.MF is like black-box :-))
https://portal.liferay.dev/docs/7-0/reference/-/knowledge_base/r/third-party-packages-portal-exports: This article shows what Liferay is already exporting by default. But in my experience, it changes from release to release.
I did a bit of brute-force methods and ended up finding all the packages exported by Liferay portal. I shared it in a blog here:
https://liferay.dev/blogs/-/blogs/using-apache-felix-web-console
After reading this article, if you compare what your LR 7.0 and LR 7.2 are exporting by default, you might see the culprit. Otherwise, you can always include them on your bundle-classpath as discussed in https://liferay.dev/blogs/-/blogs/osgi-module-dependencies
https://portal.liferay.dev/docs/7-0/reference/-/knowledge_base/r/third-party-packages-portal-exports: This article shows what Liferay is already exporting by default. But in my experience, it changes from release to release.
I did a bit of brute-force methods and ended up finding all the packages exported by Liferay portal. I shared it in a blog here:
https://liferay.dev/blogs/-/blogs/using-apache-felix-web-console
After reading this article, if you compare what your LR 7.0 and LR 7.2 are exporting by default, you might see the culprit. Otherwise, you can always include them on your bundle-classpath as discussed in https://liferay.dev/blogs/-/blogs/osgi-module-dependencies
<p>Hi Chandra, it seems my services are not being registered in the OSGI container. As I did a inspect cap service <bundle id> and it returned service [EMPTY]. I am not sure why all my services are empty as I took the same exact code from my 7.0 working production version and rebuild on 7.2 local machine. Is there specific way of registering service builder services in 7.2</p>
For 7.2 we use 2.1, maybe this fixes the issue:
compileOnly group: "javax.ws.rs", name: "javax.ws.rs-api", version: "2.1"
It seems, both ways work in 7.2, jax-rs and Whiteboard. But the recommended way is to switch to Whiteboard. It isn't even a lot of work to do that, for our projects only the annotations changed (and of course those configuration files + bnd line could be removed). The first service is probably some work till you figure out which annotations you need.
compileOnly group: "javax.ws.rs", name: "javax.ws.rs-api", version: "2.1"
It seems, both ways work in 7.2, jax-rs and Whiteboard. But the recommended way is to switch to Whiteboard. It isn't even a lot of work to do that, for our projects only the annotations changed (and of course those configuration files + bnd line could be removed). The first service is probably some work till you figure out which annotations you need.
Christoph Rabel:
Hi Christopher,
For 7.2 we use 2.1, maybe this fixes the issue:
compileOnly group: "javax.ws.rs", name: "javax.ws.rs-api", version: "2.1"
It seems, both ways work in 7.2, jax-rs and Whiteboard. But the recommended way is to switch to Whiteboard. It isn't even a lot of work to do that, for our projects only the annotations changed (and of course those configuration files + bnd line could be removed). The first service is probably some work till you figure out which annotations you need.
My REST service is running now. As you suggested, I used whiteboard pattern, jax-rs version 2.1 and remove some entries from bnd file and kept the default generated content i.e version and bundle name. Now when I integrate my service layer I am getting null pointer exception. I went and did a inspect cap service <bundle_id> and got service [EMPTY]. I attached the liferay log file. It seems my services are not being registered in the OSGI container using the same code from 7.0.
Question: Can I port and re-compile my existing service builder source code from 7.0 to 7.2? Just note, that I had to rebuild using 7.2 service builder but update my build.gradle to used portal kernel 4.0.0 and I kept the same configuration in my bnd file the same as in my 7.0. I would think that 7.2. Would service builder in 7.2 would be backward compatible.?
Ok, so the rest service works, you only have a service builder problem, right? There was one really important SB change, maybe it affects you.
https://liferay.dev/blogs/-/blogs/important-7-2-service-builder-changes
You have a NPE here:
com.fdc.artifact.builder.service.VAR_SchedulerLocalServiceUtil.retrieveSchedulerDetails(VAR_SchedulerLocalServiceUtil.java:295)
What are you doing in that line? (See the breaking changes link above)
In general, taking the 7.0 source, changing the build.gradle and calling buildService should work.
https://liferay.dev/blogs/-/blogs/important-7-2-service-builder-changes
You have a NPE here:
com.fdc.artifact.builder.service.VAR_SchedulerLocalServiceUtil.retrieveSchedulerDetails(VAR_SchedulerLocalServiceUtil.java:295)
What are you doing in that line? (See the breaking changes link above)
In general, taking the 7.0 source, changing the build.gradle and calling buildService should work.
Christoph Rabel:
Hi Chris,
Ok, so the rest service works, you only have a service builder problem, right? There was one really important SB change, maybe it affects you.
https://liferay.dev/blogs/-/blogs/important-7-2-service-builder-changes
You have a NPE here:
com.fdc.artifact.builder.service.VAR_SchedulerLocalServiceUtil.retrieveSchedulerDetails(VAR_SchedulerLocalServiceUtil.java:295)
What are you doing in that line? (See the breaking changes link above)
In general, taking the 7.0 source, changing the build.gradle and calling buildService should work.
Yes its only service builder problem. The NPE is pretty much all my service builder generated wrapper UTIL classes.The method retrieve scheduler details from the DB. I am using UTIL classes and not injecting my local service references to access my impl classes. The code is kept the same as-is in LR 7.0 Production version that is working. Now I have it running under 7.2 I get this NPE. Could this be because my VAR_Scheduler bundle is not registered in the OSGI container? I making the assumption that's why I am getting this NPE.
Impossible to tell without seeing some sourcecode. What is VAR_SchedulerLocalService? Is it (and the util class) service builder generated? Is it something you wrote? I generally try to avoid using the util classes since Liferay 7.0 since it makes several errors much more visible,
Is everything registered correctly? lb/diag in gogo shell. Can you try to inject that class? Is it available?
Is everything registered correctly? lb/diag in gogo shell. Can you try to inject that class? Is it available?
Christoph Rabel:
What is VAR_SchedulerLocalService? VAR_SchedulerLocalService is generated by Service builder from whats define in service.xml file . See below
Impossible to tell without seeing some sourcecode. What is VAR_SchedulerLocalService? Is it (and the util class) service builder generated? Is it something you wrote? I generally try to avoid using the util classes since Liferay 7.0 since it makes several errors much more visible,
Is everything registered correctly? lb/diag in gogo shell. Can you try to inject that class? Is it available?
<entity local-service="true" name="VAR_Scheduler" remote-service="true" uuid="true" cache-enabled="false">. The Util class is also generated by service builder. Is it (and the util class) service builder generated? yesIs it something you wrote? No but I wrote VAR_SchedulerLocalServiceImpl that have my finder methods.
Is everything registered correctly? It seems to be registered successfully now that i add
@ProviderType
@Transactional(isolation = Isolation.PORTAL, rollbackFor = {
PortalException.class, SystemException.class})
public interface VAR_SchedulerLocalService extends BaseLocalService,
PersistedModelLocalService {
/*
* NOTE FOR DEVELOPERS:
*
* Never modify or reference this interface directly. Always use {@link VAR_SchedulerLocalServiceUtil} to access the var_ scheduler local service. Add custom service methods to {@link com.fdc.artifact.builder.service.impl.VAR_SchedulerLocalServiceImpl} and rerun ServiceBuilder to automatically copy the method declarations to this interface.
*/
Do you use the @Reference annotation?
Is the apache Felix Container different in Liferay7.2 vs 7.0. I notice when I interact using gogo shell command bundle <bundle id> I get different outputs. See attach logs.Should I use the Declarative Services (DS) vs Spring Injector for service builder? Is there any sample code in Github I can reference?
Attachments:
Liferay generates two packages. -api and -service.
api contains the interface and the UTIL classes. Service contains the implementation. The problem with the Util classes is that they can contain null References. The Api works even if the implementation isn't there. This behavior hides errors. Your problem is likely with the -service.
Just to check everything:
-service is deployed
-service is STARTED
Try to create a little component, something like this:
@Component
public class Test {
Does it start? Is the service set?
My best guess is that it isn't.
api contains the interface and the UTIL classes. Service contains the implementation. The problem with the Util classes is that they can contain null References. The Api works even if the implementation isn't there. This behavior hides errors. Your problem is likely with the -service.
Just to check everything:
-service is deployed
-service is STARTED
Try to create a little component, something like this:
@Component
public class Test {
@Reference
protected void setVAR_SchedulerLocalService(VAR_SchedulerLocalService var) {
LOGGER.info("Set: " + VAR_SchedulerLocalService);
}
}Does it start? Is the service set?
My best guess is that it isn't.
Christoph Rabel:
Hi Chris
Liferay generates two packages. -api and -service.
api contains the interface and the UTIL classes. Service contains the implementation. The problem with the Util classes is that they can contain null References. The Api works even if the implementation isn't there. This behavior hides errors. Your problem is likely with the -service.
Just to check everything:
-service is deployed
-service is STARTED
Try to create a little component, something like this:
@Component
public class Test {}@Reference protected void setVAR_SchedulerLocalService(VAR_SchedulerLocalService var) { LOGGER.info("Set: " + VAR_SchedulerLocalService); }
Does it start? Is the service set?
My best guess is that it isn't.
I get "no services available" when I include the @reference for my component VAR_SchedulerLocalService . But when I take it out my REST service is available. Do you know what could be causing my service not available whenever inject my service reference. Its weird because it works for @reference userLocalservice. It seems when I add inject my service the bundle doesn't get activated as @Activate.
Here is my class in my jax-rs bundle that integrates with my service layer:
@Component(
property = {
JaxrsWhiteboardConstants.JAX_RS_APPLICATION_BASE + "=/portal-api",
JaxrsWhiteboardConstants.JAX_RS_NAME + "=Portal-Api.Rest",
"oauth2.scopechecker.type=none",
"auth.verifier.guest.allowed=true",
},
service = Application.class
)
public class ArtifactResourceApplication extends Application {
@Activate
@Modified
protected void activate() {
log.info("*** Rest Service has been activated/updated on " + new Date().toString()+ " ***");
}
/**
* @Desription: Service API used to expose to retrieve USER's list base on emailAddress
* @return
* @throws PortalException
*/
@GET
@Path("/artifact/users")
@Produces("text/plain")
public String getUsers() throws PortalException {
StringBuilder result = new StringBuilder(); for (User user : _userLocalService.getUsers(-1, -1)) {
result.append(user.getFullName()).append(",\n");
}
return result.toString();
}
@Reference
protected void setVAR_SchedulerLocalService(VAR_SchedulerLocalService var) {
log.info("Set: " + var);
}
private UserLocalService _userLocalService;
@Reference
public void setUserLocalService(UserLocalService userLocalService) {
this._userLocalService = userLocalService;
}
}
Yes, I thought so. The implementation of your service is not available.
Check using "lb" in gogo shell. You should see both of your packages, VAR-api and VAR-service. If VAR-service it isn't there at all, maybe it isn't even built/deployed? If the file is there, something is broken in the jar file.
If the service is in there, but not started, try "diag <bundleId of VAR Service>". It should tell you, what your the problem with your service is.
Check using "lb" in gogo shell. You should see both of your packages, VAR-api and VAR-service. If VAR-service it isn't there at all, maybe it isn't even built/deployed? If the file is there, something is broken in the jar file.
If the service is in there, but not started, try "diag <bundleId of VAR Service>". It should tell you, what your the problem with your service is.
Christoph Rabel:
I ran a command a gogo shell command to check for unregistered DM services dm na and seems that the dependency manager services (service bundles) are unavailable. The question is whats making it unavailable and how to make it available. Seing in the gogo shell console output below there us a release schema version>=2.00 dont know what that means.
Yes, I thought so. The implementation of your service is not available.
Check using "lb" in gogo shell. You should see both of your packages, VAR-api and VAR-service. If VAR-service it isn't there at all, maybe it isn't even built/deployed? If the file is there, something is broken in the jar file.
If the service is in there, but not started, try "diag <bundleId of VAR Service>". It should tell you, what your the problem with your service is.
[1065] artifactprojectmanager-service
[53] com.liferay.portal.spring.extender.internal.configuration.ServiceConfigurationInitializer unregistered
com.liferay.portal.kernel.model.Release (&(release.bundle.symbolic.name=artifactprojectmanager-service)(&(release.schema.version>=1.0.0)(!(release.schema.version>=2.0.0)))(|(!(release.state=*))(release.state=0))) service required unavailable
[54] com.liferay.portal.spring.extender.internal.context.ModuleApplicationContextRegistrator unregistered
com.liferay.portal.kernel.model.Release (&(release.bundle.symbolic.name=artifactprojectmanager-service)(&(release.schema.version>=1.0.0)(!(release.schema.version>=1.1.0)))(|(!(release.state=*))(release.state=0))) service required unavailable
com.liferay.portal.kernel.configuration.Configuration (&(origin.bundle.symbolic.name=artifactprojectmanager-service)(name=service)) service required unavailable
I also did dm wtf
g! dm wtf
2 unregistered components found
-------------------------------
Please note that the following bundles are in the RESOLVED state:
* [1066] ArtifactRestServiceManager
Please note that the following bundles are in the INSTALLED state:
* [1063] application.list.taglib.jsp.hook
The following service(s) are missing:
* com.liferay.portal.kernel.model.Release (&(release.bundle.symbolic.name=artifactprojectmanager-service)(&(release.schema.version>=1.0.0)(!(release.schema.version>=1.1.0)))(|(!(release.state=*))(release.state=0))) for bundle artifactprojectmanager-service
* com.liferay.portal.kernel.configuration.Configuration (&(origin.bundle.symbolic.name=artifactprojectmanager-service)(name=service)) for bundle artifactprojectmanager-service
* com.liferay.portal.kernel.model.Release (&(release.bundle.symbolic.name=artifactprojectmanager-service)(&(release.schema.version>=1.0.0)(!(release.schema.version>=2.0.0)))(|(!(release.state=*))(release.state=0))) for bundle artifactprojectmanager-service
I turned on dependency check for DM servuce:
2020-03-06 23:01:27.950 WARN [Spring Extender Unavailable Component Scanner][UnavailableComponentScanner:101] _Bundle {id: 1065, name: artifactprojectmanager-service, version: 1.0.0}._ Component with ID 58 is unavailable due to missing required dependencies:_ service dependency [com.liferay.portal.kernel.model.Release (&(release.bundle.symbolic.name=artifactprojectmanager-service)(&(release.schema.version>=5.1.0)(!(release.schema.version>=5.2.0)))(|(!(release.state=*))(release.state=0)))]_ service dependency [com.liferay.portal.kernel.configuration.Configuration (&(origin.bundle.symbolic.name=artifactprojectmanager-service)(name=service))]_Bundle {id: 1065, name: artifactprojectmanager-service, version: 1.0.0}._ Component with ID 57 is unavailable due to missing required dependencies:_ service dependency [com.liferay.portal.kernel.model.Release (&(release.bundle.symbolic.name=artifactprojectmanager-service)(&(release.schema.version>=5.1.0)(!(release.schema.version>=6.0.0)))(|
I was looking at this blog and this person seems to have a similar problem https://liferay.dev/forums/-/message_boards/message/111639071 . His erros are differnt and he ran an upgrade process.From looking at that forum message , I notice that the my service builder module is not in my release table Release_.
Can you show me the build.gradle of the service? Or check it yourself. Are the requested versions correct?
I have generated a new dummy project for 7.2 now, these are the versions I get: (Please check especially the kernel version)
apply plugin: "com.liferay.portal.tools.service.builder"
dependencies {
compileOnly group: "com.liferay", name: "com.liferay.petra.io", version: "3.0.0"
compileOnly group: "com.liferay", name: "com.liferay.petra.lang", version: "3.0.0"
compileOnly group: "com.liferay", name: "com.liferay.petra.string", version: "3.0.0"
compileOnly group: "com.liferay", name: "com.liferay.portal.aop.api", version: "1.0.0"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "4.4.0"
compileOnly group: "org.osgi", name: "org.osgi.annotation.versioning", version: "1.1.0"
compileOnly group: "org.osgi", name: "org.osgi.core", version: "6.0.0"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations", version: "1.3.0"
compileOnly project(":y-api")
}
I have generated a new dummy project for 7.2 now, these are the versions I get: (Please check especially the kernel version)
apply plugin: "com.liferay.portal.tools.service.builder"
dependencies {
compileOnly group: "com.liferay", name: "com.liferay.petra.io", version: "3.0.0"
compileOnly group: "com.liferay", name: "com.liferay.petra.lang", version: "3.0.0"
compileOnly group: "com.liferay", name: "com.liferay.petra.string", version: "3.0.0"
compileOnly group: "com.liferay", name: "com.liferay.portal.aop.api", version: "1.0.0"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "4.4.0"
compileOnly group: "org.osgi", name: "org.osgi.annotation.versioning", version: "1.1.0"
compileOnly group: "org.osgi", name: "org.osgi.core", version: "6.0.0"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations", version: "1.3.0"
compileOnly project(":y-api")
}
Christoph Rabel:
What tool did you use to generate your project. I used Liferay IDE. Did you use blade, workspace , Liferay IDE ? I used liferay IDE create new project and it only default to Liferay version 7.1Here is my service build.gradle.
Can you show me the build.gradle of the service? Or check it yourself. Are the requested versions correct?
I have generated a new dummy project for 7.2 now, these are the versions I get: (Please check especially the kernel version)
apply plugin: "com.liferay.portal.tools.service.builder"
dependencies {
compileOnly group: "com.liferay", name: "com.liferay.petra.io", version: "3.0.0"
compileOnly group: "com.liferay", name: "com.liferay.petra.lang", version: "3.0.0"
compileOnly group: "com.liferay", name: "com.liferay.petra.string", version: "3.0.0"
compileOnly group: "com.liferay", name: "com.liferay.portal.aop.api", version: "1.0.0"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "4.4.0"
compileOnly group: "org.osgi", name: "org.osgi.annotation.versioning", version: "1.1.0"
compileOnly group: "org.osgi", name: "org.osgi.core", version: "6.0.0"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations", version: "1.3.0"
compileOnly project(":y-api")
}
apply plugin: "com.liferay.portal.tools.service.builder"dependencies {
compileOnly group: "biz.aQute.bnd", name: "biz.aQute.bndlib", version: "3.1.0"
compileOnly group: "com.liferay", name: "com.liferay.osgi.util", version: "3.0.0"
compileOnly group: "com.liferay", name: "com.liferay.portal.spring.extender", version: "2.0.0"
//compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "2.6.0"
serviceBuilder group: "com.liferay", name: "com.liferay.portal.tools.service.builder", version: "1.0.202"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "4.0.0"
compileOnly group: "com.liferay", name: "com.liferay.petra.string", version: "2.0.0"
compile 'org.apache.commons:commons-lang3:3.2.1'
compile 'commons-io:commons-io:2.4'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
//compileOnly group: "com.liferay:com.liferay.portal.aop.api", version: "1.0.0"
//compile group: 'com.liferay:com.liferay', name: 'com.liferay.portal.aop.api', version: '1.0.0'
compileOnly project(":ArtifactProjectManager-api")
dbSupport group: 'mysql', name: 'mysql-connector-java', version: '5.1.6'
dbSupportTool group: "com.liferay", name: "com.liferay.portal.tools.db.support", version: "1.0.6"
}buildService {
apiDir = "../ArtifactProjectManager-api/src/main/java"
osgiModule = true
propsUtil = "com.fdc.artifact.builder.service.util.PropsUtil"
}cleanServiceBuilder {
propertiesFile = "jdbc.properties"
}
I have used blade (latest version) with the -v 7.2 parameter to create a dummy service builder project and copied the build.gradle from there. While the kernel 4.0.0 probably does not matter, maybe petra.string 2.0 vs. 3.0 causes an issue?
The issue could also be in the bnd file, but the build.gradle is the most likely culprit.
What happens if you create a 7.2 SB project from scratch. Does the service get installed?
The issue could also be in the bnd file, but the build.gradle is the most likely culprit.
What happens if you create a 7.2 SB project from scratch. Does the service get installed?
Christoph Rabel:
I have used blade (latest version) with the -v 7.2 parameter to create a dummy service builder project and copied the build.gradle from there. While the kernel 4.0.0 probably does not matter, maybe petra.string 2.0 vs. 3.0 causes an issue?
The issue could also be in the bnd file, but the build.gradle is the most likely culprit.
What happens if you create a 7.2 SB project from scratch. Does the service get installed?
So I am going to do 2 things.
I had created the service builder from scratch using the IDE but it only game the dependencies I shared with you portal kernel version 2.65. I replace your build.gradle and got errors in the all the service generated class files. Sp, i reverted back to kernel 2.65 and got resolution errors. OSGI container looking to load the dependencies , If I want to make 7.2 backward compatibile.
2020-03-07 11:41:01.706 ERROR [fileinstall-C:/liferay-ce-portal-7.2.1-ga2/osgi/modules][LogService:93] Error while starting bundle: file:/C:/liferay-ce-portal-7.2.1-ga2/osgi/modules/artifactprojectmanager-api-1.0.0.jar
org.osgi.framework.BundleException: Could not resolve module: artifactprojectmanager-api [1064]_ Unresolved requirement: Import-Package: com.liferay.expando.kernel.model; version="[1.0.0,2.0.0)"_ [Sanitized]
Should I add the dependency "com.liferay.expando.kernel.model; version="[1.0.0,2.0.0)" in my BND file. ?
Option 1. I am going to create service builder from scratch with latest blade as you did Option 2. If option 1 doesn't work, I am going to modify the BND file to include the required dependencies for com.liferauexpando.kernel.model.
Hi Chris,
I downloaded a new liferay workspace. Did everything over from scratch as you suggested got the same build.gradle you gave me ran the service but get forbidden . Not sure why I am getting a 403 as I have set "oauth2.scopechecker.type=none" The good news is I see my service package in the release table and the all the services are activated HTTP/1.1 403 Forbidden
X-Powered-By: Undertow/1
Set-Cookie: JSESSIONID=G2zU-GM3App1foM58I_CbI6nLFO1d9X99WoaaBhS.lfdc8xs4nq2; path=/; HttpOnly
Server: WildFly/11
X-XSS-Protection: 1
X-Frame-Options: SAMEORIGIN
Date: Wed, 11 Mar 2020 19:06:06 GMT
Connection: keep-alive
X-Content-Type-Options: nosniff
Content-Type: application/octet-stream
Content-Length: 179<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Forbidden><message>Access denied to com.fiserv.rest.application.ArtifactMangerRestApplication#working</message></Forbidden>
build.gradle
dependencies {
compileOnly group: "com.liferay", name: "com.liferay.petra.io"
compileOnly group: "com.liferay", name: "com.liferay.petra.lang"
compileOnly group: "com.liferay", name: "com.liferay.petra.string"
compileOnly group: "com.liferay", name: "com.liferay.portal.aop.api"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"
compileOnly group: "org.osgi", name: "org.osgi.annotation.versioning"
compileOnly group: "org.osgi", name: "org.osgi.core"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations"
compile 'org.apache.commons:commons-lang3:3.2.1'
compile 'commons-io:commons-io:2.4'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
compileOnly project(":modules:ArtifactManagerService:ArtifactManagerService-api")
}buildService {
apiDir = "../ArtifactManagerService-api/src/main/java"
}group = "com.fiserv.artm.service"
I downloaded a new liferay workspace. Did everything over from scratch as you suggested got the same build.gradle you gave me ran the service but get forbidden . Not sure why I am getting a 403 as I have set "oauth2.scopechecker.type=none" The good news is I see my service package in the release table and the all the services are activated HTTP/1.1 403 Forbidden
X-Powered-By: Undertow/1
Set-Cookie: JSESSIONID=G2zU-GM3App1foM58I_CbI6nLFO1d9X99WoaaBhS.lfdc8xs4nq2; path=/; HttpOnly
Server: WildFly/11
X-XSS-Protection: 1
X-Frame-Options: SAMEORIGIN
Date: Wed, 11 Mar 2020 19:06:06 GMT
Connection: keep-alive
X-Content-Type-Options: nosniff
Content-Type: application/octet-stream
Content-Length: 179<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Forbidden><message>Access denied to com.fiserv.rest.application.ArtifactMangerRestApplication#working</message></Forbidden>
build.gradle
dependencies {
compileOnly group: "com.liferay", name: "com.liferay.petra.io"
compileOnly group: "com.liferay", name: "com.liferay.petra.lang"
compileOnly group: "com.liferay", name: "com.liferay.petra.string"
compileOnly group: "com.liferay", name: "com.liferay.portal.aop.api"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"
compileOnly group: "org.osgi", name: "org.osgi.annotation.versioning"
compileOnly group: "org.osgi", name: "org.osgi.core"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations"
compile 'org.apache.commons:commons-lang3:3.2.1'
compile 'commons-io:commons-io:2.4'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
compileOnly project(":modules:ArtifactManagerService:ArtifactManagerService-api")
}buildService {
apiDir = "../ArtifactManagerService-api/src/main/java"
}group = "com.fiserv.artm.service"
Kevin Matthews:
Hi Chris,
I downloaded a new liferay workspace. Did everything over from scratch as you suggested got the same build.gradle you gave me ran the service but get forbidden . Not sure why I am getting a 403 as I have set "oauth2.scopechecker.type=none" The good news is I see my service package in the release table and the all the services are activated HTTP/1.1 403 Forbidden
X-Powered-By: Undertow/1
Set-Cookie: JSESSIONID=G2zU-GM3App1foM58I_CbI6nLFO1d9X99WoaaBhS.lfdc8xs4nq2; path=/; HttpOnly
Server: WildFly/11
X-XSS-Protection: 1
X-Frame-Options: SAMEORIGIN
Date: Wed, 11 Mar 2020 19:06:06 GMT
Connection: keep-alive
X-Content-Type-Options: nosniff
Content-Type: application/octet-stream
Content-Length: 179<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Forbidden><message>Access denied to com.fiserv.rest.application.ArtifactMangerRestApplication#working</message></Forbidden>
build.gradle
dependencies {
compileOnly group: "com.liferay", name: "com.liferay.petra.io"
compileOnly group: "com.liferay", name: "com.liferay.petra.lang"
compileOnly group: "com.liferay", name: "com.liferay.petra.string"
compileOnly group: "com.liferay", name: "com.liferay.portal.aop.api"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"
compileOnly group: "org.osgi", name: "org.osgi.annotation.versioning"
compileOnly group: "org.osgi", name: "org.osgi.core"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations"
compile 'org.apache.commons:commons-lang3:3.2.1'
compile 'commons-io:commons-io:2.4'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
compileOnly project(":modules:ArtifactManagerService:ArtifactManagerService-api")
}buildService {
apiDir = "../ArtifactManagerService-api/src/main/java"
}group = "com.fiserv.artm.service"
The 403 permission i figure out by refering to this link
https://portal.liferay.dev/docs/7-2/deploy/-/knowledge_base/d/service-access-policies#managing-service-access-policies
<p>Hi Chris,<br />
By re-building from scratch using new Liferay IDE built in withvlade, I was able to get the service builder service running.</p>
<p> </p>
<p>However, when I deploy my restful service I get the following error</p>
<p><code>2020-03-17 15:05:07.239 ERROR [default task-45][JAXRSUtils:102] No message body reader has been found for class com.fiserv.rest.model.ArtifactRequest, ContentType: application/json<br />
2020-03-17 15:05:07.241 WARN [default task-45][WebApplicationExceptionMapper:107] javax.ws.rs.WebApplicationException: HTTP 415 Unsupported Media Type__ at org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBody(JAXRSUtils.java:1327)__ at org.apache.com. </code></p>
<p>Do you know what could be possibly causing this error?</p>
<p> </p>
<p>This is my RequestObject.</p>
@XmlRootElement(name="ArtifactRequest")
//@JsonPropertyOrder("active")
public class ArtifactRequest
{
public ArtifactRequest() {} public String getTppid() {
return tppid;
} public void setTppid(String tppid) {
this.tppid = tppid;
} public String getFirstname() {
return firstname;
} public void setFirstname(String firstname) {
this.firstname = firstname;
} public String getLastname() {
return lastname;
} public void setLastname(String lastname) {
this.lastname = lastname;
} public String getEmailAddress() {
return emailAddress;
} public void setEmailAddress(String emailAddress) {
this.emailAddress = emailAddress;
} public boolean isActive() {
return isActive;
} public void setActive(boolean isActive) {
this.isActive = isActive;
} public String getUserId() {
return userId;
} public void setUserId(String userId) {
this.userId = userId;
} public List<String> getSpecificationNames() {
return specificationNames;
} public void setSpecificationNames(List<String> specificationNames) {
this.specificationNames = specificationNames;
} private String tppid; private String firstname; private String lastname; private String emailAddress; private boolean isActive; private String userId; private List<String> specificationNames;
}
By re-building from scratch using new Liferay IDE built in withvlade, I was able to get the service builder service running.</p>
<p> </p>
<p>However, when I deploy my restful service I get the following error</p>
<p><code>2020-03-17 15:05:07.239 ERROR [default task-45][JAXRSUtils:102] No message body reader has been found for class com.fiserv.rest.model.ArtifactRequest, ContentType: application/json<br />
2020-03-17 15:05:07.241 WARN [default task-45][WebApplicationExceptionMapper:107] javax.ws.rs.WebApplicationException: HTTP 415 Unsupported Media Type__ at org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBody(JAXRSUtils.java:1327)__ at org.apache.com. </code></p>
<p>Do you know what could be possibly causing this error?</p>
<p> </p>
<p>This is my RequestObject.</p>
@XmlRootElement(name="ArtifactRequest")
//@JsonPropertyOrder("active")
public class ArtifactRequest
{
public ArtifactRequest() {} public String getTppid() {
return tppid;
} public void setTppid(String tppid) {
this.tppid = tppid;
} public String getFirstname() {
return firstname;
} public void setFirstname(String firstname) {
this.firstname = firstname;
} public String getLastname() {
return lastname;
} public void setLastname(String lastname) {
this.lastname = lastname;
} public String getEmailAddress() {
return emailAddress;
} public void setEmailAddress(String emailAddress) {
this.emailAddress = emailAddress;
} public boolean isActive() {
return isActive;
} public void setActive(boolean isActive) {
this.isActive = isActive;
} public String getUserId() {
return userId;
} public void setUserId(String userId) {
this.userId = userId;
} public List<String> getSpecificationNames() {
return specificationNames;
} public void setSpecificationNames(List<String> specificationNames) {
this.specificationNames = specificationNames;
} private String tppid; private String firstname; private String lastname; private String emailAddress; private boolean isActive; private String userId; private List<String> specificationNames;
}
Probably the Jackson provider is missing:
https://liferay.dev/forums/-/message_boards/message/118712218
https://liferay.dev/forums/-/message_boards/message/118712218
Yes I was just googleing on how to register a jackson provider using JAX-RS whiteboard pattern . Thanks for the link I will take a look
Christoph Rabel:
Probably the Jackson provider is missing:
https://liferay.dev/forums/-/message_boards/message/118712218
Hi Chris, thanks for sharing the post. I got Jackson provider registered in my component as shown below.
@Component(property = { JaxrsWhiteboardConstants.JAX_RS_APPLICATION_BASE + "=/portal-api",
JaxrsWhiteboardConstants.JAX_RS_NAME + "=Portal-Api.Rest", "oauth2.scopechecker.type=none",
"auth.verifier.guest.allowed=true", "osgi.jaxrs.extension.select=(osgi.jaxrs.name=jaxb-json)"
// "osgi.jaxrs.extension.select=(component.name=your.user.context.provider.extension)"
}, service = Application.class)
The service work and I refactored my code to replace <entity>LocalUtil wrapper classes with service @Reference classes <entity>LocalService. I have been testing using service builder generated api classes using dependency injection and it works. But I notice something odd at times, if I put in a print statement or I altered a method in my code by simply removing a statement or anything at times on/off i get this nuisance error "No services have been found." after the bundle is deployed and started. For Liferay JAX-RS services what are list of cases that will result in generating this message "No services found". The service has been running before it happens on and off when I rebuild using my IDE. When I look in my liferay log file this is all I see:
2020-03-25 14:26:06.808 WARN [default task-92][ServletController:107] Can't find the request for [url=http://localhost:8081/o/portal-api/ArtifactService's Observer ]http://localhost:8081/o/portal-api/ArtifactService's Observer
Is there any specific way to debug this "No services found"? Is there a checklist you can recommend to validate everything is ok with my service? I know if I use any of the Util wrapper classes the service will not run.
Please advise
Kevin
Sorry, no idea. I can just do some wild guesses.
This error seems to be cxf related. Maybe you could check rest extenders and CXF configuration? Maybe you have invalid entries in there, from previous tests per chance?
Also, I am not sure about your project "base". If you used cxf previously and use Whiteboard now, you can remove those configuration files and the configuration entry in the bnd file.
This error seems to be cxf related. Maybe you could check rest extenders and CXF configuration? Maybe you have invalid entries in there, from previous tests per chance?
Also, I am not sure about your project "base". If you used cxf previously and use Whiteboard now, you can remove those configuration files and the configuration entry in the bnd file.
Christoph Rabel:
Sorry, no idea. I can just do some wild guesses.
This error seems to be cxf related. Maybe you could check rest extenders and CXF configuration? If I am using Liferay 7.2 do I need to configure rest extenders and CXF configuration the same that I did in Liferay 7.0? I thought since 7.2 now using DS and leveraging the OSGI 7+ spec Whiteboard Pattern we just need to add annotation and the container will pick it from there without any configuration changes in the portal?
Maybe you have invalid entries in there, from previous tests per chance? I revisited the entries and it was working before with 7.2. Also, if I remove any of the entries/dependencies I get an unresolved errors. Please my gradle build and bnd configuration below.
Also, I am not sure about your project "base". If you used cxf previously and use Whiteboard now, you can remove those configuration files and the configuration entry in the bnd file. Below is the bdn and gradle build file for my project base. The application was working before fetching from the document API the document info using _dLFileEntryLocalService.getFileEntry. But I notice when I used the MetadataLocalService I was getting a null pointer exception _dLFileEntryMetadataLocalService.getFileEntryMetadata(ddmStructure.getStructureId(), fileVersion.getFileVersionId()); However, I am unable to see error becuase now I am getting "No services have been found"REST BUNDLE CONFIGbnd.bdn:Bundle-Name: ArtifactManger-rest
Bundle-SymbolicName: com.fiserv.rest
Bundle-Version: 1.0.0Import-Package:\
!com.google.gson,\
!org.apache.commons.vfs2.*,\
*
-includeresource:\
@gson*.jar,\
@commons-io*.jar,\
@commons-lang3*.jarbuild.gradle:dependencies {
compileOnly group: "javax.ws.rs", name: "javax.ws.rs-api"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations"
compileOnly group: "org.osgi", name: "org.osgi.service.jaxrs"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"
compile 'org.apache.commons:commons-lang3:3.2.1'
compile 'commons-io:commons-io:2.6'
//compile group: 'commons-io', name: 'commons-io', version: '2.0'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.5'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.5'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.8.5'
//compile group: 'com.fasterxml.jackson.jaxrs', name: 'jackson-jaxrs-json-provider', version: '2.10.3'
compileOnly project(":modules:ArtifactManagerService:ArtifactManagerService-api")
compileOnly project(":modules:ArtifactManagerService:ArtifactManagerService-service")
}
SERVICE BUILDER API CONFIG:bnd:bnd:Bundle-Name: ArtifactManagerService-api
Bundle-SymbolicName: com.fiserv.artm.service.api
Bundle-Version: 1.0.0
Export-Package:\
com.fiserv.artm.service.exception,\
com.fiserv.artm.service.model,\
com.fiserv.artm.service.service,\
com.fiserv.artm.service.service.persistence
-check: EXPORTS
-includeresource: META-INF/service.xml=../ArtifactManagerService-service/service.xml
build.gradle:dependencies {
compileOnly group: "com.liferay", name: "com.liferay.petra.lang"
compileOnly group: "com.liferay", name: "com.liferay.petra.string"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"
compileOnly group: "org.osgi", name: "org.osgi.annotation.versioning"
compileOnly group: "org.osgi", name: "org.osgi.core"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations"
}
SERVICE BUILDER SERVICE CONFIG:
bnd.bnd:Bundle-Name: ArtifactManagerService-service
Bundle-SymbolicName: com.fiserv.artm.service.service
Bundle-Version: 1.0.0
Liferay-Require-SchemaVersion: 1.0.0
Liferay-Service: true-includeresource:\
@commons-lang3*.jar,\
@gson*.jar-dsannotations-options: inherit
build.gradle:dependencies {
compileOnly group: "com.liferay", name: "com.liferay.petra.io"
compileOnly group: "com.liferay", name: "com.liferay.petra.lang"
compileOnly group: "com.liferay", name: "com.liferay.petra.string"
compileOnly group: "com.liferay", name: "com.liferay.portal.aop.api"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"
compileOnly group: "org.osgi", name: "org.osgi.annotation.versioning"
compileOnly group: "org.osgi", name: "org.osgi.core"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations"
compile 'org.apache.commons:commons-lang3:3.2.1'
compile 'commons-io:commons-io:2.4'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
compileOnly project(":modules:ArtifactManagerService:ArtifactManagerService-api")
}buildService {
apiDir = "../ArtifactManagerService-api/src/main/java"
}group = "com.xxx.xxx.service"
I finally figure out what I believe the problem was and now my REST service is available. When I mention that previously when I received a null pointer from MetadataLocalService in the log. I revisited my code and notice I only delclared the private member variable but did not inject the service reference setter method :
@Reference(unbind = "-")
public void set_dLFileEntryMetadataLocalService(DLFileEntryMetadataLocalService _dLFileEntryMetadataLocalService) {
this._dLFileEntryMetadataLocalService = _dLFileEntryMetadataLocalService;
}
Also, once I made the modification I cleaned out all the jars from C:\liferay-ce-portal-7.2.1-ga2\osgi\modules and rebuild and deploy the jars in the deploy folder by copying the jar from my IDE. In Addition, it seems the deploy gradle task doent work from my IDE even thiugh I seldom use it.
Kevin Matthews
Bundle-SymbolicName: com.fiserv.rest
Bundle-Version: 1.0.0Import-Package:\
!com.google.gson,\
!org.apache.commons.vfs2.*,\
*
-includeresource:\
@gson*.jar,\
@commons-io*.jar,\
@commons-lang3*.jarbuild.gradle:dependencies {
compileOnly group: "javax.ws.rs", name: "javax.ws.rs-api"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations"
compileOnly group: "org.osgi", name: "org.osgi.service.jaxrs"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"
compile 'org.apache.commons:commons-lang3:3.2.1'
compile 'commons-io:commons-io:2.6'
//compile group: 'commons-io', name: 'commons-io', version: '2.0'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.5'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.5'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.8.5'
//compile group: 'com.fasterxml.jackson.jaxrs', name: 'jackson-jaxrs-json-provider', version: '2.10.3'
compileOnly project(":modules:ArtifactManagerService:ArtifactManagerService-api")
compileOnly project(":modules:ArtifactManagerService:ArtifactManagerService-service")
}
SERVICE BUILDER API CONFIG:bnd:bnd:Bundle-Name: ArtifactManagerService-api
Bundle-SymbolicName: com.fiserv.artm.service.api
Bundle-Version: 1.0.0
Export-Package:\
com.fiserv.artm.service.exception,\
com.fiserv.artm.service.model,\
com.fiserv.artm.service.service,\
com.fiserv.artm.service.service.persistence
-check: EXPORTS
-includeresource: META-INF/service.xml=../ArtifactManagerService-service/service.xml
build.gradle:dependencies {
compileOnly group: "com.liferay", name: "com.liferay.petra.lang"
compileOnly group: "com.liferay", name: "com.liferay.petra.string"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"
compileOnly group: "org.osgi", name: "org.osgi.annotation.versioning"
compileOnly group: "org.osgi", name: "org.osgi.core"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations"
}
SERVICE BUILDER SERVICE CONFIG:
bnd.bnd:Bundle-Name: ArtifactManagerService-service
Bundle-SymbolicName: com.fiserv.artm.service.service
Bundle-Version: 1.0.0
Liferay-Require-SchemaVersion: 1.0.0
Liferay-Service: true-includeresource:\
@commons-lang3*.jar,\
@gson*.jar-dsannotations-options: inherit
build.gradle:dependencies {
compileOnly group: "com.liferay", name: "com.liferay.petra.io"
compileOnly group: "com.liferay", name: "com.liferay.petra.lang"
compileOnly group: "com.liferay", name: "com.liferay.petra.string"
compileOnly group: "com.liferay", name: "com.liferay.portal.aop.api"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"
compileOnly group: "org.osgi", name: "org.osgi.annotation.versioning"
compileOnly group: "org.osgi", name: "org.osgi.core"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations"
compile 'org.apache.commons:commons-lang3:3.2.1'
compile 'commons-io:commons-io:2.4'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
compileOnly project(":modules:ArtifactManagerService:ArtifactManagerService-api")
}buildService {
apiDir = "../ArtifactManagerService-api/src/main/java"
}group = "com.xxx.xxx.service"
@Reference(unbind = "-")
public void set_dLFileEntryMetadataLocalService(DLFileEntryMetadataLocalService _dLFileEntryMetadataLocalService) {
this._dLFileEntryMetadataLocalService = _dLFileEntryMetadataLocalService;
}
Also, once I made the modification I cleaned out all the jars from C:\liferay-ce-portal-7.2.1-ga2\osgi\modules and rebuild and deploy the jars in the deploy folder by copying the jar from my IDE. In Addition, it seems the deploy gradle task doent work from my IDE even thiugh I seldom use it.
Kevin Matthews
Christoph Rabel:
Sorry, no idea. I can just do some wild guesses.
This error seems to be cxf related. Maybe you could check rest extenders and CXF configuration? If I am using Liferay 7.2 do I need to configure rest extenders and CXF configuration the same that I did in Liferay 7.0? I thought since 7.2 now using DS and leveraging the OSGI 7+ spec Whiteboard Pattern we just need to add annotation and the container will pick it from there without any configuration changes in the portal?
Maybe you have invalid entries in there, from previous tests per chance? I revisited the entries and it was working before with 7.2. Also, if I remove any of the entries/dependencies I get an unresolved errors. Please my gradle build and bnd configuration below.
Also, I am not sure about your project "base". If you used cxf previously and use Whiteboard now, you can remove those configuration files and the configuration entry in the bnd file. Below is the bdn and gradle build file for my project base. The application was working before fetching from the document API the document info using _dLFileEntryLocalService.getFileEntry. But I notice when I used the MetadataLocalService I was getting a null pointer exception _dLFileEntryMetadataLocalService.getFileEntryMetadata(ddmStructure.getStructureId(), fileVersion.getFileVersionId()); However, I am unable to see error becuase now I am getting "No services have been found"REST BUNDLE CONFIGbnd.bdn:Bundle-Name: ArtifactManger-rest
Bundle-SymbolicName: com.fiserv.rest
Bundle-Version: 1.0.0Import-Package:\
!com.google.gson,\
!org.apache.commons.vfs2.*,\
*
-includeresource:\
@gson*.jar,\
@commons-io*.jar,\
@commons-lang3*.jarbuild.gradle:dependencies {
compileOnly group: "javax.ws.rs", name: "javax.ws.rs-api"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations"
compileOnly group: "org.osgi", name: "org.osgi.service.jaxrs"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"
compile 'org.apache.commons:commons-lang3:3.2.1'
compile 'commons-io:commons-io:2.6'
//compile group: 'commons-io', name: 'commons-io', version: '2.0'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.5'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.5'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.8.5'
//compile group: 'com.fasterxml.jackson.jaxrs', name: 'jackson-jaxrs-json-provider', version: '2.10.3'
compileOnly project(":modules:ArtifactManagerService:ArtifactManagerService-api")
compileOnly project(":modules:ArtifactManagerService:ArtifactManagerService-service")
}
SERVICE BUILDER API CONFIG:bnd:bnd:Bundle-Name: ArtifactManagerService-api
Bundle-SymbolicName: com.fiserv.artm.service.api
Bundle-Version: 1.0.0
Export-Package:\
com.fiserv.artm.service.exception,\
com.fiserv.artm.service.model,\
com.fiserv.artm.service.service,\
com.fiserv.artm.service.service.persistence
-check: EXPORTS
-includeresource: META-INF/service.xml=../ArtifactManagerService-service/service.xml
build.gradle:dependencies {
compileOnly group: "com.liferay", name: "com.liferay.petra.lang"
compileOnly group: "com.liferay", name: "com.liferay.petra.string"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"
compileOnly group: "org.osgi", name: "org.osgi.annotation.versioning"
compileOnly group: "org.osgi", name: "org.osgi.core"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations"
}
SERVICE BUILDER SERVICE CONFIG:
bnd.bnd:Bundle-Name: ArtifactManagerService-service
Bundle-SymbolicName: com.fiserv.artm.service.service
Bundle-Version: 1.0.0
Liferay-Require-SchemaVersion: 1.0.0
Liferay-Service: true-includeresource:\
@commons-lang3*.jar,\
@gson*.jar-dsannotations-options: inherit
build.gradle:dependencies {
compileOnly group: "com.liferay", name: "com.liferay.petra.io"
compileOnly group: "com.liferay", name: "com.liferay.petra.lang"
compileOnly group: "com.liferay", name: "com.liferay.petra.string"
compileOnly group: "com.liferay", name: "com.liferay.portal.aop.api"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"
compileOnly group: "org.osgi", name: "org.osgi.annotation.versioning"
compileOnly group: "org.osgi", name: "org.osgi.core"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations"
compile 'org.apache.commons:commons-lang3:3.2.1'
compile 'commons-io:commons-io:2.4'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
compileOnly project(":modules:ArtifactManagerService:ArtifactManagerService-api")
}buildService {
apiDir = "../ArtifactManagerService-api/src/main/java"
}group = "com.xxx.xxx.service"
Hi Chris,
Its very odd because this service was running yesterday with the following bundle resolution error below. I started my liferay 7.2 local server and watching the console I see my REST service unavailable. I would guess is because OSGI container is unable to resolve a package in the bundle. It's trying to resolve the import exception package from my service builder bundles. Does liferay attempts to re-install the bundle if you stop/start the server?
Its very odd because this service was running yesterday with the following bundle resolution error below. I started my liferay 7.2 local server and watching the console I see my REST service unavailable. I would guess is because OSGI container is unable to resolve a package in the bundle. It's trying to resolve the import exception package from my service builder bundles. Does liferay attempts to re-install the bundle if you stop/start the server?
14:55:09,016 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 11.0.0.Final (WildFly Core 3.0.8.Final) started in 79315ms - Started 1746 of 1971 services (349 services are lazy, passive or on-demand)
2020-03-27 14:55:20.152 INFO [pipe-stop 1117][BundleStartStopLogger:42] STOPPED com.fiserv.rest_1.0.0 [1117]
2020-03-27 14:55:20.417 INFO [pipe-start 1117][ArtifactMangerRestApplication:83] *** Artifact Manager Rest Service Version 1.2 has been activated/updated on Fri Mar 27 14:55:20 GMT 2020 ***
2020-03-27 14:55:20.465 INFO [pipe-start 1117][BundleStartStopLogger:39] STARTED com.fiserv.rest_1.0.0 [1117]
2020-03-27 14:55:22.586 INFO [pipe-stop 1118][BundleStartStopLogger:42] STOPPED com.fiserv.artm.service.api_1.0.0 [1118]
2020-03-27 14:55:22.727 INFO [pipe-start 1118][BundleStartStopLogger:39] STARTED com.fiserv.artm.service.api_1.0.0 [1118]
2020-03-27 14:55:24.887 INFO [pipe-stop 1119][BundleStartStopLogger:42] STOPPED com.fiserv.artm.service.service_1.0.0 [1119]
2020-03-27 14:55:25.355 INFO [pipe-start 1119][ArtifactMangerRestApplication:83] *** Artifact Manager Rest Service Version 1.2 has been activated/updated on Fri Mar 27 14:55:25 GMT 2020 ***
2020-03-27 14:55:25.425 INFO [pipe-start 1119][BundleStartStopLogger:39] STARTED com.fiserv.artm.service.service_1.0.0 [1119]
2020-03-27 14:57:24.968 INFO [fileinstall-C:/liferay-ce-portal-7.2.1-ga2/osgi/modules][BundleStartStopLogger:42] STOPPED com.fiserv.artm.service.api_1.0.0 [1118]
2020-03-27 14:57:25.010 INFO [fileinstall-C:/liferay-ce-portal-7.2.1-ga2/osgi/modules][BundleStartStopLogger:42] STOPPED com.fiserv.artm.service.service_1.0.0 [1119]
2020-03-27 14:57:25.018 INFO [fileinstall-C:/liferay-ce-portal-7.2.1-ga2/osgi/modules][BundleStartStopLogger:42] STOPPED com.fiserv.rest_1.0.0 [1117]
2020-03-27 14:59:20.742 INFO [com.liferay.portal.kernel.deploy.auto.AutoDeployScanner][AutoDeployDir:259] Processing com.fiserv.rest-1.0.0.jar
2020-03-27 14:59:30.081 ERROR [fileinstall-C:/liferay-ce-portal-7.2.1-ga2/osgi/modules][LogService:93] Error while starting bundle: file:/C:/liferay-ce-portal-7.2.1-ga2/osgi/modules/com.fiserv.rest-1.0.0.jar
org.osgi.framework.BundleException: Could not resolve module: com.fiserv.rest [1120]_ Unresolved requirement: Import-Package: com.fiserv.artm.service.exception; version="[1.0.0,2.0.0)"_ [Sanitized]
at org.eclipse.osgi.container.Module.start(Module.java:444)
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:428)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1275)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1248)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:520)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316)
2020-03-27 14:59:35.749 INFO [com.liferay.portal.kernel.deploy.auto.AutoDeployScanner][AutoDeployDir:259] Processing com.fiserv.artm.service.api-1.0.0.jar
2020-03-27 14:59:45.207 INFO [Refresh Thread: Equinox Container: a848069b-aa29-4ab3-85f9-761e68a69183][BundleStartStopLogger:39] STARTED com.fiserv.rest_1.0.0 [1120]
2020-03-27 14:59:45.209 INFO [fileinstall-C:/liferay-ce-portal-7.2.1-ga2/osgi/modules][BundleStartStopLogger:39] STARTED com.fiserv.artm.service.api_1.0.0 [1121]
2020-03-27 14:59:47.754 INFO [com.liferay.portal.kernel.deploy.auto.AutoDeployScanner][AutoDeployDir:259] Processing com.fiserv.artm.service.service-1.0.0.jar
2020-03-27 14:59:55.520 INFO [fileinstall-C:/liferay-ce-portal-7.2.1-ga2/osgi/modules][ArtifactMangerRestApplication:83] *** Artifact Manager Rest Service Version 1.2 has been activated/updated on Fri Mar 27 14:59:55 GMT 2020 ***
2020-03-27 14:59:55.573 INFO [fileinstall-C:/liferay-ce-portal-7.2.1-ga2/osgi/modules][BundleStartStopLogger:39] STARTED com.fiserv.artm.service.service_1.0.0 [1122]
Kevin Matthews:
I finally figure out what I believe the problem was and now my REST service is available. When I mention that previously when I received a null pointer from MetadataLocalService in the log. I revisited my code and notice I only delclared the private member variable but did not inject the service reference setter method :
@Reference(unbind = "-")
public void set_dLFileEntryMetadataLocalService(DLFileEntryMetadataLocalService _dLFileEntryMetadataLocalService) {
this._dLFileEntryMetadataLocalService = _dLFileEntryMetadataLocalService;
}
Also, once I made the modification I cleaned out all the jars from C:\liferay-ce-portal-7.2.1-ga2\osgi\modules and rebuild and deploy the jars in the deploy folder by copying the jar from my IDE. In Addition, it seems the deploy gradle task doent work from my IDE even thiugh I seldom use it.
Kevin MatthewsChristoph Rabel:
Sorry, no idea. I can just do some wild guesses.
This error seems to be cxf related. Maybe you could check rest extenders and CXF configuration? If I am using Liferay 7.2 do I need to configure rest extenders and CXF configuration the same that I did in Liferay 7.0? I thought since 7.2 now using DS and leveraging the OSGI 7+ spec Whiteboard Pattern we just need to add annotation and the container will pick it from there without any configuration changes in the portal?Maybe you have invalid entries in there, from previous tests per chance? I revisited the entries and it was working before with 7.2. Also, if I remove any of the entries/dependencies I get an unresolved errors. Please my gradle build and bnd configuration below.Also, I am not sure about your project "base". If you used cxf previously and use Whiteboard now, you can remove those configuration files and the configuration entry in the bnd file. Below is the bdn and gradle build file for my project base. The application was working before fetching from the document API the document info using _dLFileEntryLocalService.getFileEntry. But I notice when I used the MetadataLocalService I was getting a null pointer exception _dLFileEntryMetadataLocalService.getFileEntryMetadata(ddmStructure.getStructureId(), fileVersion.getFileVersionId()); However, I am unable to see error becuase now I am getting "No services have been found"REST BUNDLE CONFIGbnd.bdn:Bundle-Name: ArtifactManger-rest
Bundle-SymbolicName: com.fiserv.rest
Bundle-Version: 1.0.0Import-Package:\
!com.google.gson,\
!org.apache.commons.vfs2.*,\
*
-includeresource:\
@gson*.jar,\
@commons-io*.jar,\
@commons-lang3*.jarbuild.gradle:dependencies {
compileOnly group: "javax.ws.rs", name: "javax.ws.rs-api"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations"
compileOnly group: "org.osgi", name: "org.osgi.service.jaxrs"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"
compile 'org.apache.commons:commons-lang3:3.2.1'
compile 'commons-io:commons-io:2.6'
//compile group: 'commons-io', name: 'commons-io', version: '2.0'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.5'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.5'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.8.5'
//compile group: 'com.fasterxml.jackson.jaxrs', name: 'jackson-jaxrs-json-provider', version: '2.10.3'
compileOnly project(":modules:ArtifactManagerService:ArtifactManagerService-api")
compileOnly project(":modules:ArtifactManagerService:ArtifactManagerService-service")
}
SERVICE BUILDER API CONFIG:bnd:bnd:Bundle-Name: ArtifactManagerService-api
Bundle-SymbolicName: com.fiserv.artm.service.api
Bundle-Version: 1.0.0
Export-Package:\
com.fiserv.artm.service.exception,\
com.fiserv.artm.service.model,\
com.fiserv.artm.service.service,\
com.fiserv.artm.service.service.persistence
-check: EXPORTS
-includeresource: META-INF/service.xml=../ArtifactManagerService-service/service.xml
build.gradle:dependencies {
compileOnly group: "com.liferay", name: "com.liferay.petra.lang"
compileOnly group: "com.liferay", name: "com.liferay.petra.string"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"
compileOnly group: "org.osgi", name: "org.osgi.annotation.versioning"
compileOnly group: "org.osgi", name: "org.osgi.core"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations"
}
SERVICE BUILDER SERVICE CONFIG:
bnd.bnd:Bundle-Name: ArtifactManagerService-service
Bundle-SymbolicName: com.fiserv.artm.service.service
Bundle-Version: 1.0.0
Liferay-Require-SchemaVersion: 1.0.0
Liferay-Service: true-includeresource:\
@commons-lang3*.jar,\
@gson*.jar-dsannotations-options: inherit
build.gradle:dependencies {
compileOnly group: "com.liferay", name: "com.liferay.petra.io"
compileOnly group: "com.liferay", name: "com.liferay.petra.lang"
compileOnly group: "com.liferay", name: "com.liferay.petra.string"
compileOnly group: "com.liferay", name: "com.liferay.portal.aop.api"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"
compileOnly group: "org.osgi", name: "org.osgi.annotation.versioning"
compileOnly group: "org.osgi", name: "org.osgi.core"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations"
compile 'org.apache.commons:commons-lang3:3.2.1'
compile 'commons-io:commons-io:2.4'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
compileOnly project(":modules:ArtifactManagerService:ArtifactManagerService-api")
}buildService {
apiDir = "../ArtifactManagerService-api/src/main/java"
}group = "com.xxx.xxx.service"
Try to stop the server remove the osgi/state folder and start it again. Does it still happen? (Sometimes, when developing, osgi gets confused and removing the state folder forces it to starts from scratch).
I am not sure about the root cause of your issue. I am sorry I can't help you more, your project is too complicated for remote diagnosis.
Otherwise, I can only give some general advise. Probably it does nothing, but maybe it helps. I would try to remove the "-includeresource: ..." stuff and use compileInclude instead. We always use it and it works pretty well.
https://liferay.dev/blogs/-/blogs/gradle-compile-vs-compileonly-vs-compileinclude
Also, you should try to get rid of the
Import-Package:\
!com.google.gson,\
!org.apache.commons.vfs2.*,\ *
stuff and also the Export-Package:\ ... stuff.
Maybe it is necessary, then you have to keep it, but I would try to get it to a minimum.
I am not sure about the root cause of your issue. I am sorry I can't help you more, your project is too complicated for remote diagnosis.
Otherwise, I can only give some general advise. Probably it does nothing, but maybe it helps. I would try to remove the "-includeresource: ..." stuff and use compileInclude instead. We always use it and it works pretty well.
https://liferay.dev/blogs/-/blogs/gradle-compile-vs-compileonly-vs-compileinclude
Also, you should try to get rid of the
Import-Package:\
!com.google.gson,\
!org.apache.commons.vfs2.*,\ *
stuff and also the Export-Package:\ ... stuff.
Maybe it is necessary, then you have to keep it, but I would try to get it to a minimum.
Hi Chris,
Thanks for your response. I got my JAX-RS and Service builder components running now. The issues were using dependency injection properly using @Reference in my components at which some of my components were missing service reference injection.
Now I will need to convert my 7.0 jsp files (bundle fragments) into 7.2. Hopefully this will be smooth process as I will be creating the module from scratch using the IDE then copy the jsp modify content to new project folder.So, the lessons learned so far is that the Upgrade tool for 7.0 to 7.2 doesn't seem to work well for service builder projects. Also, whenever there is an error such as "No service available" make sure all exceptions is resolved. It doesn't seem that the OSGI container doesn't explicitly tells or point to the root problem in REST components. Its strange, when I restart the server I saw it try install the bundle. I hope when I deleted the osgi state folders it did the trick.
Thanks for your response. I got my JAX-RS and Service builder components running now. The issues were using dependency injection properly using @Reference in my components at which some of my components were missing service reference injection.
Now I will need to convert my 7.0 jsp files (bundle fragments) into 7.2. Hopefully this will be smooth process as I will be creating the module from scratch using the IDE then copy the jsp modify content to new project folder.So, the lessons learned so far is that the Upgrade tool for 7.0 to 7.2 doesn't seem to work well for service builder projects. Also, whenever there is an error such as "No service available" make sure all exceptions is resolved. It doesn't seem that the OSGI container doesn't explicitly tells or point to the root problem in REST components. Its strange, when I restart the server I saw it try install the bundle. I hope when I deleted the osgi state folders it did the trick.
Christoph Rabel:
Try to stop the server remove the osgi/state folder and start it again. Does it still happen? (Sometimes, when developing, osgi gets confused and removing the state folder forces it to starts from scratch).
I am not sure about the root cause of your issue. I am sorry I can't help you more, your project is too complicated for remote diagnosis.
Otherwise, I can only give some general advise. Probably it does nothing, but maybe it helps. I would try to remove the "-includeresource: ..." stuff and use compileInclude instead. We always use it and it works pretty well.
https://liferay.dev/blogs/-/blogs/gradle-compile-vs-compileonly-vs-compileinclude
Also, you should try to get rid of the
Import-Package:\
!com.google.gson,\
!org.apache.commons.vfs2.*,\ *
stuff and also the Export-Package:\ ... stuff.
Maybe it is necessary, then you have to keep it, but I would try to get it to a minimum.
OK I found it. Its located in build folder.
Kevin Matthews:
Hi Chris,
Thanks for your response. I got my JAX-RS and Service builder components running now. The issues were using dependency injection properly using @Reference in my components at which some of my components were missing service reference injection.
Now I will need to convert my 7.0 jsp files (bundle fragments) into 7.2. Hopefully this will be smooth process as I will be creating the module from scratch using the IDE then copy the jsp modify content to new project folder.So, the lessons learned so far is that the Upgrade tool for 7.0 to 7.2 doesn't seem to work well for service builder projects. Also, whenever there is an error such as "No service available" make sure all exceptions is resolved. It doesn't seem that the OSGI container doesn't explicitly tells or point to the root problem in REST components. Its strange, when I restart the server I saw it try install the bundle. I hope when I deleted the osgi state folders it did the trick.Christoph Rabel:
Try to stop the server remove the osgi/state folder and start it again. Does it still happen? (Sometimes, when developing, osgi gets confused and removing the state folder forces it to starts from scratch).
I am not sure about the root cause of your issue. I am sorry I can't help you more, your project is too complicated for remote diagnosis.
Otherwise, I can only give some general advise. Probably it does nothing, but maybe it helps. I would try to remove the "-includeresource: ..." stuff and use compileInclude instead. We always use it and it works pretty well.
https://liferay.dev/blogs/-/blogs/gradle-compile-vs-compileonly-vs-compileinclude
Also, you should try to get rid of the
Import-Package:\
!com.google.gson,\
!org.apache.commons.vfs2.*,\ *
stuff and also the Export-Package:\ ... stuff.
Maybe it is necessary, then you have to keep it, but I would try to get it to a minimum.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™