I am trying to make a maven project using Datanucleus as a database abstraction. However, when i try to mvn datanucleus:schema-create, i get the following error:
[ERROR] --------------------
[ERROR] Standard error from the DataNucleus tool + org.datanucleus.store.schema.SchemaTool :
[ERROR] --------------------
[ERROR] Error: Could not find or load main class org.datanucleus.store.schema.SchemaTool
The relevant parts from the pom.xml file are:
<dependencies>
<dependency>
<groupId>javax.jdo</groupId>
<artifactId>jdo-api</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>4.0.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-api-jdo</artifactId>
<version>4.0.4</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-rdbms</artifactId>
<version>4.0.4</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.34</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<!-- <version>3.2</version> -->
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-maven-plugin</artifactId>
<version>4.0.0-release</version>
<configuration>
<api>JDO</api>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
And the persistence.xml file is in /src/main/resources/META-INF/persistence.xml, containing the following:
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<!-- JDO tutorial "unit" -->
<persistence-unit name="Tutorial">
<class>a.b.c.MyClass</class>
<exclude-unlisted-classes />
<properties>
<property name="javax.jdo.option.PersistenceUnitName" value="Tutorial" />
<property name="javax.jdo.option.ConnectionURL" value="jdbc:mysql://localhost/mydb" />
<property name="javax.jdo.option.ConnectionDriverName"
value="com.mysql.jdbc.Driver" />
<property name="javax.jdo.option.ConnectionUserName" value="myuser" />
<property name="javax.jdo.option.ConnectionPassword" value="mypass" />
<property name="datanucleus.schema.autoCreateAll" value="true" />
<property name="datanucleus.schema.validateTables" value="true" />
<property name="datanucleus.schema.validateConstraints"
value="true" />
<property name="javax.jdo.PersistenceManagerFactoryClass"
value="org.datanucleus.api.jdo.JDOPersistenceManagerFactory" />
</properties>
</persistence-unit>
To my untrained eye it looks like everything is in place, yet it doesn't work.
Perhaps your <scope>runtime</scope> is causing the problem, because that jar contains this class. Whether it is or not you can easily enable Maven debug --debug on the command line and look at what is in the CLASSPATH for that operation.
Related
I want to create a pom.xml that will fetch some .dmp files from a remote FTP server ,
to access this server I have it's URL username and password (who ofcourse only have READ permissions).
What is the best way to get those files from the server?
with maven-ant plugin/maven executer/ or any other plugin that I don't know of?
try this
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<configuration>
<target>
<ftp action="get"
server="192.168.1.1"
remotedir="remoteDir"
userid="anonymous"
password="anonymous">
<fileset dir="${project.build.directory}">
<include name="**/*.*"/>
</fileset>
</ftp>
</target>
</configuration>
<dependencies>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-commons-net</artifactId>
<version>1.8.1</version>
</dependency>
</dependencies>
</plugin>
Also you can have a look here
I’m trying to use aspect seaving in my Maven/Spring (3.2.11.RELEASE) project. I have this configured for my plugin …
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<configuration>
<complianceLevel>1.6</complianceLevel>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
and here’s my aspects dependencies …
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.2</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.8.2</version>
</dependency>
but when I run “mvn clean install” I get these warnings …
[INFO] --- aspectj-maven-plugin:1.7:compile (default) # pd ---
[INFO] Showing AJC message detail for messages of types: [error, warning, fail]
[WARNING] advice defined in org.springframework.scheduling.aspectj.AbstractAsyncExecutionAspect has not been applied [Xlint:adviceDidNotMatch]
/Users/davea/.m2/repository/org/springframework/spring-aspects/3.2.11.RELEASE/spring-aspects-3.2.11.RELEASE.jar!org/springframework/scheduling/aspectj/AbstractAsyncExecutionAspect.class:58
[WARNING] advice defined in org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl has not been applied [Xlint:adviceDidNotMatch]
/Users/davea/Dropbox/workspace/pd/org/springframework/mock/staticmock/AnnotationDrivenStaticEntityMockingControl.aj:83
[WARNING] advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch]
/Users/davea/.m2/repository/org/springframework/spring-aspects/3.2.11.RELEASE/spring-aspects-3.2.11.RELEASE.jar!org/springframework/mock/staticmock/AbstractMethodMockingControl.class:190
[WARNING] advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch]
/Users/davea/.m2/repository/org/springframework/spring-aspects/3.2.11.RELEASE/spring-aspects-3.2.11.RELEASE.jar!org/springframework/mock/staticmock/AbstractMethodMockingControl.class:199
How do I resolve dependencies properly so that these warnings go away?
Edit: This is the configuration I have set up in my spring WEB-INF/dispatcher-servlet.xml file. I'm trying to make a private method #Transactional ...
<bean class="org.springframework.transaction.aspectj.AnnotationTransactionAspect" factory-method="aspectOf">
<property name="transactionManager" ref="transactionManager"/>
</bean>
<tx:annotation-driven mode="aspectj" transaction-manager="transactionManager" />
<tx:advice id="txAdvice" >
<tx:attributes>
<tx:method name="generateAccess" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="orderServicePC" expression="execution(* org.mainco.subco.myproject.service.OrderService.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="orderServicePC" />
</aop:config>
im trying to build an example code with maven liferay:build-service from an service.xml
There is simple entity company.
After code generating i have uncompilable code. I have tried another versions of maven plugins, but it didnt help.
Thanx
My pom.xml
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.plugins</groupId>
<artifactId>intlib-env</artifactId>
<packaging>war</packaging>
<name>intlib-env Portlet</name>
<version>1.0.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>com.liferay.maven.plugins</groupId>
<artifactId>liferay-maven-plugin</artifactId>
<version>6.1.2</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>build-css</goal>
</goals>
</execution>
</executions>
<configuration>
<autoDeployDir>D:\portal\liferay\deploy</autoDeployDir>
<appServerDeployDir>D:\portal\liferay\tomcat7\webapps</appServerDeployDir>
<appServerLibGlobalDir>D:\portal\liferay\tomcat7\lib\ext</appServerLibGlobalDir>
<appServerPortalDir>D:\portal\liferay\tomcat7\webapps\ROOT</appServerPortalDir>
<liferayVersion>6.1.2</liferayVersion>
<pluginType>portlet</pluginType>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId>
<version>6.1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-bridges</artifactId>
<version>6.1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-taglib</artifactId>
<version>6.1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-java</artifactId>
<version>6.1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>Liferay-v6.x-Runtime-Stub</id>
<properties>
<liferay.version>6.1.2</liferay.version>
<liferay.maven.plugin.version>6.1.30.1</liferay.maven.plugin.version>
<liferay.auto.deploy.dir>D:\portal\liferay\deploy</liferay.auto.deploy.dir>
<liferay.app.server.deploy.dir>D:\portal\liferay\tomcat7\webapps</liferay.app.server.deploy.dir>
<liferay.app.server.lib.global.dir>D:\portal\liferay\tomcat7\lib\ext</liferay.app.server.lib.global.dir>
<liferay.app.server.portal.dir>D:\portal\liferay\tomcat7\webapps\ROOT</liferay.app.server.portal.dir>
</properties>
</profile>
</profiles>
</project>
and here the service.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_0_0.dtd">
<service-builder package-path="cz.sysnet.intlib.eia">
<author>EB</author>
<namespace>EIA</namespace>
<entity name="Company" local-service="true" remote-service="false">
<column name="Id" type="long" primary="true" />
<column name="ICO" type="String" />
<column name="name" type="String" />
<column name="companyId" type="long" />
<column name="groupId" type="long" />
<order by="asc">
<order-column name="name" />
</order>
<finder name="G_N" return-type="Collection">
<finder-column name="groupId" />
<finder-column name="name" />
</finder>
<finder name="GroupId" return-type="Collection">
<finder-column name="groupId" />
</finder>
<finder name="CompanyId" return-type="Collection">
<finder-column name="companyId" />
</finder>
</entity>
</service-builder>
Here are few of the errors after successfully generation of the code.
Description Resource Path Location Type
The method update(Company, boolean) in the type BasePersistence<Company> is not applicable for the arguments (Company) CompanyLocalServiceBaseImpl.java /intlib-env2/src/main/java/cz/sysnet/intlib/eia/service/base line 80 Java Problem
The method update(Company, boolean) in the type BasePersistence<Company> is not applicable for the arguments (Company) CompanyLocalServiceBaseImpl.java /intlib-env2/src/main/java/cz/sysnet/intlib/eia/service/base line 276 Java Problem
The method update(Company, boolean) in the type BasePersistence<Company> is not applicable for the arguments (Company) CompanyUtil.java /intlib-env2/src/main/java/cz/sysnet/intlib/eia/service/persistence line 89 Java Problem
The method update(Company, boolean) in the type BasePersistence<Company> is not applicable for the arguments (Company, ServiceContext) CompanyUtil.java /intlib-env2/src/main/java/cz/sysnet/intlib/eia/service/persistence line 97 Java Problem
The method setModelClass(Class<Company>) is undefined for the type CompanyPersistenceImpl CompanyPersistenceImpl.java /intlib-env2/src/main/java/cz/sysnet/intlib/eia/service/persistence line 169 Java Problem
The method setExpandoBridgeAttributes(ExpandoBridge) of type CompanyModel must override or implement a supertype method CompanyModel.java /intlib-env2/src/main/java/cz/sysnet/intlib/eia/model line 146 Java Problem
The method setExpandoBridgeAttributes(BaseModel<?>) of type CompanyModel must override or implement a supertype method CompanyModel.java /intlib-env2/src/main/java/cz/sysnet/intlib/eia/model line 143 Java Problem
The method countWithDynamicQuery(DynamicQuery) in the type BasePersistence<Company> is not applicable for the arguments (DynamicQuery, Projection) CompanyLocalServiceBaseImpl.java /intlib-env2/src/main/java/cz/sysnet/intlib/eia/service/base line 210 Java Problem
Thanx.
Company is a type that Liferay also has. Most likely ServiceBuilder generates import for Liferay's Company class, clashing with your own. Unless you want to start over, you'd have some tasks to do to get rid of all of your company declarations from the generated content of service builder - hibernate files, spring configuration and others. Search for cz.sysnet.intlib.eia.Company in your project and remove those declarations (and the Company* classes in your project), rename your entity (e.g. to Kompany, choose any other value that you like) and rebuild the services.
ServiceBuilder has a few limitations like these, after all, it's a code generator and rarely used to introduce another entity with an already existing name. You might want to add this limitation to LPS-27710 and watch that issue. It probably doesn't have the highest priority unless there's a lot of activity on there
Thanx for the response,
i had to move from the newest version apache maven 3.2.2 to the 3.1.1 and cleaned the maven files in the project.
Now its working again.
I am trying to pass maven properties (defined through profiles) to a antrun execution:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<dependencies>
<!-- ... these are ok -->
</dependencies>
<executions>
<execution>
<configuration>
<target>
<property name="ant_destDir" value="${destDir}" />
<property name="ant_serverDeploy" value="${serverDeploy}" />
<property name="ant_deployDir" value="${deployDir}" />
<property name="ant_userDeploy" value="${userDeploy}" />
<property name="ant_passwordDeploy" value="${passwordDeploy}" />
<!-- correct task definitions for sshexec and scp -->
<sshexec host="${serverDeploy}" username="${userDeploy}"
password="${passwordDeploy}" trust="yes"
command="some command" />
<scp remoteTodir="${userDeploy}#${serverDeploy}:${destDir}"
password="${passwordDeploy}" trust="yes" sftp="true">
<fileset dir="${deployDir}" includes="*.jar" />
</scp>
<sshexec host="${serverDeploy}" username="${userDeploy}"
password="${passwordDeploy}" trust="yes"
command="some command" />
</target>
</configuration>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
The properties are defined in profiles to allow for deployment in different servers (I know it's not the best possible approach, but this is the way things are done here), like this:
<profile>
<id>aprofile</id>
<properties>
<property name="serverDeploy" value="somevalue" />
<property name="userDeploy" value="someuser" />
<property name="passwordDeploy" value="somepassword" />
<!-- and so on -->
</properties>
</profile>
My problem is that I can't get maven properties to work in ant plugin; I tried to add a <echoproperties> task in ant to see which properties I have and there is no trace of maven properties.
Is it possible to use maven defined properties or should I use another approach? Any suggestion is welcome.
Edit: I modified the script as per first answer, it still doesn't work
You can pass the properties by defining new Ant properties (using the property tag in your target within the configuration). So for example:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>test-module</artifactId>
<name>test-module</name>
<version>SNAPSHOT</version>
<properties>
<my.custom.property>false</my.custom.property>
</properties>
<profiles>
<profile>
<id>customProfile</id>
<properties>
<my.custom.property>true</my.custom.property>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<configuration>
<target>
<property name="antProperty" value="${my.custom.property}"/>
<echo message="Custom Ant Property is: ${antProperty}"/>
<echoproperties />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
When I execute mvn compile on this pom the output is:
main:
[echo] Custom Ant Property is: false
[echoproperties] #Ant properties
[echoproperties] #Thu Aug 08 17:17:30 CEST 2013
[echoproperties] ant.project.name=maven-antrun-
[echoproperties] ant.version=Apache Ant(TM) version 1.8.2 compiled on December 20 2010
[echoproperties] antProperty=false
and when the command is mvn -PcustomProfile compile then the output is:
main:
[echo] Custom Ant Property is: true
[echoproperties] #Ant properties
[echoproperties] #Thu Aug 08 17:18:30 CEST 2013
[echoproperties] ant.project.name=maven-antrun-
[echoproperties] ant.version=Apache Ant(TM) version 1.8.2 compiled on December 20 2010
[echoproperties] antProperty=true
This works using maven 3.0.5.
Most properties are automatically passed along to ant, at least if you're running an inlined ant script. Some of the properties get renamed. I suggest running "mvn -X" and the antrun plugin prints a list of all the variable mappings into ant (things like basedir becomes project.basedir, etc.)
On the newer versions of maven you can just use:
<taskdef resource="net/sf/antcontrib/antcontrib.properties"
classpathref="maven.plugin.classpath" />
example:
<build>
....
<plugins>
....
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<taskdef resource="net/sf/antcontrib/antcontrib.properties"
classpathref="maven.plugin.classpath" />
<echo message="Project name from Maven: ${project.name}" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
....
</plugins>
....
</build>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
<exclusions>
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.6.5</version>
</dependency>
</dependencies>
I'm working on a plugin for Talend Open Studio; the component architecture of that platform needs that all external JARs are declared in a component-descriptor XML file in a form like:
<IMPORT MODULE="commons-collections-3.2.1.jar" NAME="commons-collections-3.2.1"
REQUIRED="true"/>
I use the Maven dependency plugins to manage all these external JARs
Is there a way to get all the dependency names in a list or something? This way can I be able to build the required strings (using an antcontrib task, perhaps), fill a ${parameter} and finally add it to XML file using maven-replacer-plugin?
The simplest solution is to use the maven-dependency-plugin via the buld-classpath goal. This goal can be given supplemental parameters to put the result into a file like:
mvn dependency:build-classpath -Dmdep.outputFile=classpath.out
Ok, I partly resolved this way that should works with some limitations:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
<exclusions>
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.6.5</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>package</phase>
<id>copy-resources</id>
<configuration>
<exportAntProperties>true</exportAntProperties>
<tasks>
<!-- add the ant tasks from ant-contrib -->
<taskdef resource="net/sf/antcontrib/antlib.xml" classpathref="maven.plugin.classpath"/>
<var name="import.set" value=""/>
<for param="file">
<path>
<fileset dir="${project.build.directory}" includes="*.jar"/>
</path>
<sequential>
<var name="basename" unset="true"/>
<basename file="#{file}" property="basename"/>
<var name="filenames" value="${basename}"/>
<var name="import.clause" value='<IMPORT MODULE="${filenames}" NAME="${filenames}" REQUIRED="true"/>'/>
<var name="import.set" value="${import.clause}${line.separator}${import.set}" />
</sequential>
</for>
<property name="import.jar" value="${import.set}"/>
<echo>${import.jar}</echo>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Still some problems: even if exportAntProperties is set to true, the property ${import.jar} is still not available outside ant taska in other maven goals, while if i switch to maven-antrun-plugin 1.7 version, a "Error executing ant tasks: org.apache.tools.ant.launch.Locator.fromJarURI(Ljava/lang/String;)Ljava/lang/String;" exception is thrown. Still no clues...