I am using liferay 6.2 & built a maven portlet and working fine, I want to use its tables to store data for another portlet so that I need its services in this portlet.
But we can't access it externally so i find a way something like: required-deployment-contexts=Portlet-Project1 inside liferay-plugin-package.properties, then found its works for Ant only.
I was also finding the xxx-portlet-service.jar but didn't able to, so that i could manually put it in other portlet's lib folder i.e inside tomcat-webapps-xxxportlet-WEB-INF.
Just want to find how to use xxxLocalService.util in other in maven portlet
The best approach you can implement is a plugin to manage all the interaction with the DB.
First of all you must create a Service with a maven project and include it into your pom.xml in each portlet that you need. Then you can invoke its methods whenever you want because each portlet will store the dependencies.
Create Service Plugin into jar file
Rebuild with mvn clean liferay:build-service
Custom your own methods to manage the iteraction with the DB (LocalServiceUtilImpl and rebuild).
Include this plugin into pom.xml portlets
Rebuild your portlet.
The JAR will be placed in your .m2 folder, then each time that you rebuild your Service Plugin will be updated.
If i understood your question correctly, You need to create service builder project using maven and then you can add as dependency in other project wherever you need access to use xxxLocalServicutil class.
You can follow below link to create maven service builder project.
http://www.liferay-guru.com/how-to-use-liferay-servicebuilder-archetype/
As you mentioned in your question.
was also finding the xxx-portlet-service.jar but didn't able to, so
that i could manually put it in other portlet's lib folder
To answer this, manually putting .jar file in lib directory will not help when you are working with maven project
Related
I have the following issue.
On one hand I have a multi module maven project, which I use maven install to write the .jar files in my local .m2 repository. This is working fine. Lets call it MultiA.
Now on the other hand, I have a spring boot project (lets call it SpringB) in which I bind the .jar files from my multi module maven project. This is working fine as well. When I execute my buisness logic from IntelliJ, I receive no issue, but when I build the project as a .jar, I receive an issue because the settings.properties file from MultiA are not found. I do not try to access settings.properties from SpringB, but I call a method from MultiA, which in return trys to access the settings properties.
I hope, this description helps and someone knows the answer to this problem.
This is where I am at:
I am using Drools 6.2 and calling drools engine remotely via KIE Execution Server running on jboss.
I used workbench to create my initial drl file and fact objects and then used Build & Deploy option of workbench to create and deploy the jar file. I then created the container using the jar file and got the end point that I am using to access the rule engine from my client application. At this point every thing is working fine and I am able to fire the rules remotely.
My requirement is to modify the rules file (.drl) outside the workbench, let's say in notepad and update the container with this new drl file. Is there an easy way to create the jar file programmatically that i can deploy to the central maven repository? I can then run the KIE scanner to look for the latest version of my jar file and automatically update my container. Or is there another recommended way to update the running container with an updated .drl file?
My client application is not in Java so I am not looking for an integrated solution where I can write java code to create the knowledge base and use kie builder to build the drl file.
Is there an easy way to create the jar file programmatically that i can deploy to the central maven repository?
2 options that I can think of, one "easy" and one not so much:
Option 1
Use Maven and the maven drools plugin (you don't have to write Java code, just create your maven project and run mvn package to get a jar. See here: https://docs.jboss.org/drools/release/6.0.1.Final/drools-docs/html/KIEChapter.html#KIEModuleIntroductionBuildingIntroductionSection
Option 2
A JAR file is simply a zip file with a specified structure. That means that you should be able to update your whatever.drl file, put it in the directory structure that the KIE server expects and deploy it.
For instance, create a directory structure like:
META-INF/kmodule.xml
com/site/project/drools/rules/myrule/SomeRule.drl
Zip those files into somefile.jar and deploy it.
I have service based environment in which I have to create a jar and upload it dynamically to maven repository and return the dependency tree for it. Is there any library which will create a jar file and upload that jar file to maven repository and will return me dependecny of uploaded jar. Right now Im creating it with maven goals in eclipse but I don't want that.
Thanks,
If you don't want to use the command line or IDE, have you looked at the Maven API? There's also an 'undocumented' Maven embedder project.
Below are some links that may help you get started, pick the approach that is easier for you, while meeting your requirements:
https://github.com/jenkinsci/lib-jenkins-maven-embedder/blob/master/src/main/java/hudson/maven/MavenEmbedder.java
http://maven.apache.org/ref/3.0.2/maven-embedder/apidocs/org/apache/maven/cli/MavenCli.html
http://q4e.googlecode.com/svn-history/r819/trunk/plugins/maven/core/src/org/devzuz/q/maven/embedder/internal/EclipseMaven.java
http://developers-blog.org/blog/def../2009/09/18/How-to-resolve-an-artifact-with-maven-embedder
I want to develop a RESTful API within my multi-module Spring-based project using Spring Rest. For that purpose, I have a webapp module and some other business/data layer modules. For example, this would be my simplified project structure:
myProject
-- webapp (war-packaged)
-- business (jar-packaged)
-- data (jar-packaged)
Business module depends on data module and so does webapp on business module. Webapp imports successfully every module's application context. Now I want to be able to use some business module classes that do some kind of calculation according to some data retrieved from a DB in order to provide a certain resource. All examples I had a look at were quite simple and this multi-module approach was not covered at all.
What is the problem? As far as I am concerned, Tomcat loads classes in a certain order. Concretely, it first loads WEB-INF/classes and only then WEB-INF/lib (where all webapp dependencies are placed, business module in this case). So, there goes my question. Where should I place my Controller classes? If I place them within the webapp module I won't be able to autowire any business-module bean since Tomcat will throw a ClassNotFoundException when I deploy the webapp war (at least this is the behaviour I have experienced).
The answer is probably easy but I'm quite new to Spring and its world!
Thank you all in advance.
Your business and data jars would go into the WEB-INF/lib directory. Then those jars will automatically be added to the CLASSPATH for your app when you deploy it. You will need to deploy your application as a WAR file.
Ideally, you would build the business and data jars, add them to some repository, and then the build system would pull the proper version of each jar into the WEB-INF/lib directory for you.
And as to the original question, the controller classes go into the webapp/src directory.
Assuming you are using Maven 2. Make sure your assembly creator (e.g. maven war module) is including your dependent .jar files within the final .war file's WEB-INF/lib directory. This should be the default procedure (per: http://maven.apache.org/plugins/maven-war-plugin/war-mojo.html#dependentWarIncludes ). The other concern, then is whether your sub-projects (business and data) are even creating jars so that they could be included in the WAR output.
If you have doubts as to the contents of that war file, browse the listing of it by executing
'jar tvf $WAR_FILENAME' from the command line and by observing the WEB-INF/lib directory contents. You should see your business and data jars in there. Go further by exploding your war file, then browsing the contents of business and data jar (using 'jar xvf $FILENAME' to explode in a new directory).
Hope this helps!
As the topic says I cannot import this package in my web dynamic project using SpringSource Tool Suite.The command Spring Tools --> Add Spring Project Nature has been already executed.
Thank you.
What kind of project did you create? Is it a Maven project? If so, you need to make sure that you are importing 'at least' the spring-context dependency like so
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.1.0.RELEASE</version>
<scope>runtime</scope>
</dependency>
(or whatever version you want to use)
[EDIT]
Since as you say, you are using a Dynamic Web Project through this example -> http://www.vaannila.com/spring/spring-mvc-tutorial-1.html, you need to physically add the following jar files to your WEB-INF/lib folder
antlr-runtime-3.0
commons-logging-1.0.4
org.springframework.asm-3.0.0.M3
org.springframework.beans-3.0.0.M3
org.springframework.context-3.0.0.M3
org.springframework.context.support-3.0.0.M3
org.springframework.core-3.0.0.M3
org.springframework.expression-3.0.0.M3
org.springframework.web-3.0.0.M3
org.springframework.web.servlet-3.0.0.M3
You should have the following:
Adding the 'Spring Project Nature' does not add the dependencies for you, but only instructs the IDE that this project is using Spring.
Use maven.it automatically adds the necessary jar files.otherwise u need to manually do it.you can have a look at this http://www.mkyong.com/maven/how-to-convert-java-web-project-to-maven-project/
to migrate an existing project into maven
OR
You can manually add the necessary jar files.
Right click on the spring project>>
properties>>
java build path>>
libraries>>Add jars
:)