Liferay rest-build project unresolved requirement problem - rest

I'm trying to deploy a Liferay rest-builder project. These are the steps I follow to do it:
I create a rest-builder project with Liferay Developer Studio wizard.
I edit the *-impl/rest-openapi.yaml file
I launch the buildREST Gradle task
BuildREST task ends successfully
I launch the deploy Gradle task
Deploy task ends successfully
When JAR tries to deploy, it lets this message in log:
Unable to start bundle: file:/C:/devs/testlr73/bundles/osgi/modules/com.liferay.training.service.rest.impl.jar
org.osgi.framework.BundleException: Could not resolve module: com.liferay.training.service.rest.impl [1368]_ Unresolved requirement: Import-Package: com.liferay.portal.vulcan.pagination; version="[1.4.0,2.0.0)"
I tried this operation with versions 7.1, 7.2, 7.3 and 7.4.
Only 7.4 deploys without a problem (after fix the version in the javax.xml.bind dependency).
I was trying found where is set the Import-Package to fix it but I can't found it.

There are two general approaches to fix your problem.
Initialize a new project based on your exact version of Liferay (and copy your code into the created projects)
Try to fix all dependencies manually
I would suggest to go with 1. as this seems the "cleaner" approach to me. But I will try to explain both ways here as much in detail as I can.
FIRST APPROACH: Initialize a new project
When creating a project with blade, you can give it 2 additional / optional parameters:
--product (dxp | portal - for the community version)
-v (version - like 7.2, 7.3,...)
The whole command for a DXP 7.3 would look like this:
blade create --product dxp -v 7.3 -t rest-builder automapper-service
As for the wizard in Dev Studio, you should be able to select the Liferay Version and the Flavor as well for your project - if you use a Liferay Workspace usually you select it once for the workspace.
DevStudio writes this information in your gradle.build of the workspace, so you can change it afterwards, its the liferay.workspace.product and liferay.workspace.target.platform.version variables.
Please have a look here for an exact walkthrough for creating a project in dev studio.
SECOND APPROACH: Manually updating the dependencies
Your package needs the Vulcan API as dependency. And as the deployment in 7.4 works, you seem to compile it for the 7.4 version.
So I would do following approach:
1 Check which version of Vulcan API Liferay is running in your desired Liferay
Startup a Liferay server.
Goto its Gogo Shell and execute:
lb vulcan
You should get some entries back, the correct one is the "Liferay Portal Vulcan API", in my case (DXP 7.3 SP3) it has the version 7.19.2
So you should remember / note that version.
2 Replace all occurences of that dependency in your gradle files
Liferay has an article here which explains more in detail on how to resolve bundle dependencies
Search in Dev Studio via Search -> File for com.liferay.portal.vulcan.api
For example in your build.gradle you will have something like this
compileOnly group: "com.liferay", name: "com.liferay.portal.vulcan.api", version: "9.3.1"
Update the version to your target version and save the file, so in my case it would look like:
compileOnly group: "com.liferay", name: "com.liferay.portal.vulcan.api", version: "7.19.2"
One note of warning for this approach: There might be further issues with other dependencies as well. You will have to resolve all of them to successfully deploy to your desired Liferay version. Good thing though, you can do it the same way I described above.

Related

JBoss Forge new Gradle Project?

When starting a new project using JBoss Forge, the project is creating with a Maven build system by default. How do I take advantage of Forge 2.*'s Gradle AddOn to create the project using Gradle instead of Maven?
% forge
Using Forge at /usr/local/Cellar/jboss-forge/2.12.2.Final/libexec
…
[ForgePlaygroundGradle]$ new-project --name ForgePlaygroundGradle --topLevelPackage com.kedges.forgegradle --porjectFolder . **???**;
What you need here are two things:
1) After you start Forge, make sure you have installed the Gradle addon (it does not come with the core distribution):
addon-install --coordinate org.jboss.forge.addon:gradle,2.12.2.Final
2) Then you can use the --buildSystem option of the project-new command:
project-new --named ForgePlaygroundGradle --topLevelPackage com.kedges.forgegradle
Please note that the latter command may take some time to execute the first time. The reason for this is the downloading of the dependencies for a decent Java EE web project. Same happens with Maven projects when you create them with an empty local ~/.m2/repository folder.
If you don't need a web project, then consider the other project types provided by the --type option.

SonarQube fails to start due to findbugs and fbcontrib

I'm upgrading from Sonar 3.1.1 to SonarQube 4.0. I have the sonar-fb-contrib-plugin-1.2.jar file in my extensions/plugins directory. The startup fails with the following message:
2013.11.12 15:10:17 INFO org.sonar.INFO Install plugins done: 197 ms
2013.11.12 15:10:17 ERROR o.s.s.p.PlatformLifecycleListener Fail to start server
org.sonar.api.utils.SonarException: Fail to extend the plugin findbugs for fbcontrib
My understanding is that findbugs comes bundled with SonarQube (I can see the jar file under bundled-plugins). I'm not sure what the problem is here - it doesn't look like this works out of the box as it did for 3.1.1
I had a similar issue while upgrading from 3.6 to 3.7.3; the fbcontrib-plugin depends on the findbugs-plugin which is part of the sonar java-ecosystem.
In this case it is safe (and documented, point 6) to take a backup of the database and of the extensions directory before updating; then update and restart sonar having moved away any external contribution plugin, so that sonar can manage the update and come up back successfully. Another good tip is to not overwrite new configuration files with the old ones, instead manually editing them to bring over the old settings.
Then, add the plugins back and restart again; happy static analysis.

liferay build-service

I encountered problem in Liferay. I want to create new service exactly the same service like the one that presented in the Liferay's developer documentation. However, after copy-pasting the XML to the portlet folder I try to build t using the command on my command prompt:
ant build-service
I get nothing. It only say on the console like this:
Buildfile: D:\Program\liferay-plugins-sdk-6.1.1\portlets\NewPortlet-portlet\build.xml
build-service:
It stayed like that for so damn long, and still. I don't know what's the problem, is it because the Ant? I use the latest version of apache ant(currently: Apache Ant(TM) version 1.8.4 compiled on May 22 2012)
Is it because of configuration in the build.xml in the portlet folder?
Anybody encountered the same problem? or is it just me?
Ant hanging during a build task is typically because there is a cluster config enabled in a properties file.
Remove/comment out the cluster configurations and that should clear the problem.

In PlayN, how can I upgrade to PlayN version 1.3.1 without getting "no lwjgl in java.library.path" error?

Update
The reason I couldn't update properly was I didn't have game's jar file properly installed. That was fixed by first running this on the command line:
mvn install:install-file -DgroupId=com.mygame -DartifactId=mygame-core -Dversion=0.9-beta -Dpackaging=jar -Dfile=/home/klenwell/projects/mygame/playn/mygame/java/target/mygame-java-0.9-beta.jar
Then, in Eclipse, I right-clicked java folder > Maven > Test. This updated all my dependencies including lwjgl.
Otherwise, see thomasbroad's answer.
Original Question
I've consulted the following authorities on this topic and applied their various recommendations:
http://lwjgl.org/installation.php
http://www.lwjgl.org/wiki/index.php?title=Setting_Up_LWJGL_with_Maven
http://www.lwjgl.org/wiki/index.php?title=Setting_Up_LWJGL_with_Eclipse
https://stackoverflow.com/a/11065814/1093087
https://groups.google.com/forum/?fromgroups#!topic/playn/E2t7gNh4ab0
https://groups.google.com/d/msg/playn/3D4JZ1Dbm-E/HmPHofS2fqgJ
Part of the problem is I'm not sure whether I should be following the Maven instructions or the Eclipse instructions. I've tried both and everything in between.
I'm working in Ubuntu 12.04 64-bit on Eclipse using Maven. Everything was working fine until I changed the PlayN version in my POM file from 1.2 to 1.3.1 and introduced the lwjgl dependency.
What I would have expected to have worked:
1) Download lwjgl (latest version 2.8.4) and test per lwjgl.org instructions (this was successful)
2) Update the appropriate POM files
2A) Add lwjgl.version as a property to mygame/pom.xml
<properties>
<playn.version>1.3.1</playn.version>
<lwjgl.version>2.8.4</lwjgl.version>
</properties>
2B) Add lwjgl as a dependency to mygame/mygame-java/pom.xml
<dependency>
<groupId>org.lwjgl.lwjgl</groupId>
<artifactId>lwjgl</artifactId>
<version>${lwjgl.version}</version>
</dependency>
3) Right-click mygame-java project in Eclipse > Run As > Run Configurations > Arguments and add either -Djava.library.path=target/natives or -Djava.library.path=/absolute/path/to/my/lwjgl/lib to VM arguments. (I've tried both variations.)
I can see the dependencies listed under my java project folder in Eclipse. And when I follow the lwjgl.org guide for Eclipse, I can see the jar listed under the java project folder. But I still get the error.
After two hours of hair-wrenching frustration, I hope somebody can either point out my fatal oversight or provide explicit instructions that will help me get back to work. Thanks.
I upgraded my project from 1.2 to 1.3 a while ago. I only updated my pom.xml files to refer to the new version of PlayN . I did not manually install lwjgl and neither did I add the lwjgl dependency as that one is implicitly pulled in by PlayN
Manually apply the diffs found here to your project, to your poms.
The key part being the piece in the java pom that tells Maven to unpack native dependencies. This part was actually added in the previous diff, so you may want to look there as well.
Now your IDE will most likely tell you that your project is not up-to-date with your poms, update your project, this should pull in the lwjgl dependency and set it up correctly.
I believe you should add the -Djava.library.path arguments to the VM Arguments, not to the Program Arguments in your runtime configuration.
The other -using maven- option is described on the Getting Started page, it worth noting, that the default embedded Maven is buggy for development, you should download and use at least Maven 3.0.3 as it is mentioned on the page (but I guess you already do this).
I just started a new project fresh with PlayN 1.4 and encountered this issue again in Eclipse. Resolved it as follows:
Right click mygame-java > Run As > Run Configurations...
Then added the following to VM Arguments under Arguments tab:
-Djava.library.path=target/natives
Then successfully ran as application.
At one point, I also ran the mvn install:install-file... command mentioned in question but I'm not sure whether that was necessary or not.

gwt-maven-plugin with Eclipse Indigo

I would just like to setup a new GWT project in Eclipse and use Maven for dealing with all the jar jungle. I used gwt-maven-plugin with this instructions, but I can't get the project to work in Eclipse.
What I've actually done:
Created a maven project using the archetype gwt in command line.
Imported the projet in eclipse using import > existing maven project
While doing that I had errors saying:
gwt-maven-plugin:2.3.0-1:generateAsync - "No marketplace entries found to handle"
gwt-maven-plugin:2.3.0-1:i18n - "No marketplace entries found to handle"
gwt-maven-plugin:2.3.0-1:exploded - "No marketplace entries found to handle"
These errors don't go away even if I ignore them on the import.
How can I make these projects working? Is the problem that I skipped the "process-resources" setting? (There is no such setting in the latest version of m2e.)
Should I even use gwt-maven-plugin? Is there any other way of making a GWT project to use Maven? Or – is there any other way to fight with the jar jungle? What does GWT guys use?
I use Eclipse Indigo with m2e plugin 1.0.0 and Google suite plugin version 2.3.3.
Eventually I gave up Maven. As one other developer said "good ideas and bad code build communities faster" , I also remember my experience with Maven on all the projects: very promising on the beginning, but eventually you get to some problems and end up working more with configuring Maven than actually dealing with your own code.
I decided to manually copy needed .jar-s into /lib folder. I spent some time due to transitive dependencies, but LESS than dealing with Maven and now I have things under control. If sometime in the future working with libraries will become an overhead, I will consider using Ivy.
If someone wishes to stick with Maven, I lately found a very useful link by Google team:
http://code.google.com/p/google-web-toolkit/wiki/WorkingWithMaven
They recommend using their sample projects and not gwt-maven-plugin archetypes (due to issues). I agree. They also provide needed pom lifecycle changes for Eclipse Indigo.
According to a recent post on the gwt-maven-plugin mailing list the Maven integration is not complete for Eclipse Indigo, since the M2Eclipse 1.0 release has brought about a large number of changes. The suggested workarounds from David Chandler, Google engineer, are:
You can run "mvn package" on the command line or right-click on the project > Maven > Run as > Maven build.
The plugin execution failures you're seeing can be resolved by adding lifecycle mapping metadata as in the sample POMs. They are only needed for Indigo. You should not get these errors in Helios or when running mvn package from the command line.
Disclaimer: The following guidelines are for Windows users. These steps are on the basis that, they have worked when tried by the replier and doesn't guarantee fulfledge working unless experimented by self and tried with proper prerequisites.
::Creating a simple gwt project using archetype::
Following are few commands that can be used to create a simple gwt project "Web Starter Application":
mvn archetype:generate -DarchetypeGroupId=org.codehaus.mojo
-DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.3.0
mvn -DarchetypeGroupId=org.codehaus.mojo
-DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.3.0 -DgroupId={project packaging} -DartifactId={application name} -Dversion=1.0 org.apache.maven.plugins:maven-archetype-plugin:generate
mvn -DarchetypeGroupId=org.codehaus.mojo
-DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.3.0 -DgroupId={project packaging} -DartifactId={application name} -Dversion=1.0 -Dmodule={module name} org.apache.maven.plugins:maven-archetype-plugin:generate
(The value of archetypeVersion can be 2.3.0 or any higher stable version.)
Few coordinates are required by maven to create the gwt project. They are as follows:
groupId
artifactId
version
module
The first command doesn't take any of the above coordinates hence, we need to supply them at the time it executes. Notice that the archetype goal is mentioned right at the beginning of the command. It is mandatory to give the archetype goal.
The meanings of these coordinates can be found here.
One of the best ways to start with understanding maven is this.
The second command doesn't consider the module name hence, you will be prompted to give it at the time the command executes.
The third command is equivalent to running it in batch mode where you just have to confirm the inputs for groupId, artifactId, version, module as mentioned in command itself.
Once any of these commands gives a BUILD SUCCESS result, then navigate to the just-now-created project folder from command line and execute the following command:
mvn gwt:run
It should start the project in Development Mode so that you can Launch the Default Browser to run the project or Copy the URL to clipboard and navigate to it through any browser.
Good luck with the execution.