maven module, Connect persistance.xml with Spring - java

I realize an App which I have a project father and 4 project module:
-persistance
--META-INF/persistence
--pom.xml
-business
--pom.xml
-controller
--pom.xml
-web
-- pom.xml
SOLVED: src/resources/META-INF/persistance.xml
Thank you.

Add your persistence.xml
project/src/main/resources/META-INF/persistence.xml

Related

Dependency error in eclipse project making use of Maven

I am using Eclipse Mars to run my Java project. I am making use of Maven in it. But while trying to compile my package I am getting the following error.
Failed to execute goal on project apex-check: Could not resolve dependencies for project org.fundacionjala.enforce.sonarqube:apex-check:jar:1.0: Failed to collect dependencies at org.fundacionjala.enforce.sonarqube:apex-squid:jar:1.0: Failed to read artifact descriptor for org.fundacionjala.enforce.sonarqube:apex-squid:jar:1.0: Could not transfer artifact org.fundacionjala.enforce.sonarqube:apex-squid:pom:1.0 from/to central (https://repo.maven.apache.org/maven2): Failed to authenticate with proxy -> [Help 1].
I am able to find that my pom.xml has a bug in its dependency. But don't know how to resolve it. I have given below my pom.xml file
<?xml version="1.0" encoding="UTF-8"?>
<!-- ~ Copyright (c) Fundacion Jala. All rights reserved. ~ Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.fundacionjala.enforce.sonarqube</groupId>
<artifactId>apex</artifactId>
<version>1.0b${build.number}</version>
</parent>
<artifactId>apex-check</artifactId>
<name>Apex :: Checks</name>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>apex-squid</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
I have written 'apex-check' and 'apex-squid' as two separate projects.
Can anyone explain how to correct my pom.xml?
You need to have:
org.fundacionjala.enforce.sonarqube:apex-check:jar:1.0
org.fundacionjala.enforce.sonarqube:apex-squid:jar:1.0
jar files available in your local .m2/repository folder. If they are not present maven will try to download from central repository and as an expected result it will fail on firewall or it will not find the artifact. i.e. if:
apex-check requires apex-squid project as dependency first you need to install squid project files by using mvn install on squid project folder.
But it seems more like you want to create a multi module maven project, take a look at this question. Create a parent project similar to this project, add check and squid as module and run mvn clean install on parent.
**edit: I just see you already have parent, so make sure parent has your projects as modules, which helps reactive build order and eclipse imports

java.lang.NoSuchMethodError: in weblogic

when making a deployment in weblogic I get the following error.
java.lang.NoSuchMethodError: javax/validation/spi/ConfigurationState.getParameterNameProvider()Ljavax/validation/ParameterNameProvider;
Do I exclude any dependencies?
I think the problem is bean-validator
pom.xml
jersey-guava-2.6.jar
jersey-client-2.6.jar
jersey-common-2.6.jar
jersey-server-2.6.jar
jersey-spring3-2.6.jar
jersey-media-json-jackson-2.6.jar
jersey-container-servlet-core-2.6.jar
bean-validator-2.2.0.jar
novedades-validation-api-1.0.0.GA.jar
hibernate-validator-4.2.0.Final.jar
validation_1.0_spec-1.1.jar
hibernate-core-3.6.7.Final.jar
transactions-hibernate3-3.7.0.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar
hibernate-entitymanager-3.6.7.Final.jar
hibernate-commons-annotations-3.2.0.Final.jar
weblogic.xml
<container-descriptor>
<prefer-application-packages>
<package-name>org.hibernate.*</package-name>
<package-name>javax.validation.*</package-name>
</prefer-application-packages>
<prefer-application-resources>
<resource-name>javax.validation.*</resource-name>
<resource-name>org.hibernate.*</resource-name>
</prefer-application-resources>
</container-descriptor>
Thank you
This issue can occur due to incompatible version of validation api being used.
Also check if there are 2 versions of validation api in the class path.
Run a mvn dependency:tree command to check for inter dependencies.

How to publish artifacts to Artifactory with different names? [duplicate]

I published few atifacts of a component to a maven repository using different configurations of ivy. As an example, I took the following way (Ivy Documentation) to do the same..
<ivy-module version="1.0">
<info organisation="org.apache" module="filter"/>
<configurations>
<conf name="api" description="only provide filter framework API"/>
<conf name="homemade-impl" extends="api" description="provide a home made implementation of our api"/>
</configurations>
<publications>
<artifact name="filter-api" type="jar" conf="api" ext="jar"/>
<artifact name="filter-hmimpl" type="jar" conf="homemade-impl" ext="jar"/>
</publications>
</ivy-module>
According to the above configuration, the artifacts that are produced are filter-api.jar and filter-hmimpl.jar, and I generated a pom file filter.pom and published this into a maven repository.
Now, when I am trying to resolve the artifact filter-api in another component using the following..
<dependency org="org.apache" name="filter" rev="3.1" conf="default->api"/>
But it is not working, I believe my filter.pom should contain some modules like this, to make it work..
<modules>
<module>api</module>
<module>homemade-impl</module>
</modules>
Am I correct, and if yes how can I map different conf's of ivy to modules in maven.
Publishing mutliple files to a Maven repository is tricky because Maven modules normally contain a single artifact. Maven modules do support additional module artifacts, which are referenced in a Maven dependency using the "classifier" attribute.
The following answers provide examples of publishing multiple files to a Maven module:
how to publish 3rdparty artifacts with ivy and nexus
Convert ivy.xml to pom.xml
Observe that the ANT scripts are using the makepom to generate POM files and that these files are considered artifacts published (part of the ivy publications section).
For more background you might be interested in the following answer that deals with the differences between Maven "scopes" and ivy "confgurations".
How are maven scopes mapped to ivy configurations by ivy
Finally, if your ivy build uses configurations, it's possible to configure the makepom task to map between configurations and scopes:
<ivy:makepom ivyfile="${build.dir}/ivy.xml" pomfile="${build.dir}/${ivy.module}.pom"/>
<mapping conf="api" scope="compile"/>
</ivy:makepom>
Most likely, the problem is with the dependency declaration. You pull the dependency into your 'default' configuration with conf="default->api". But you really want them in the "compile" conf, to include them in your compile classpath.

Ivy can't resolve log4j from Maven Central

New to Apache Ivy, and can't get it to resolve the latest log4j jar from Maven Central. I'm using IvyDE to manage all of my dependencies and using all of its defaults, which I believe configure it to use either the Maven repo or Ibiblio.
This link takes you to Maven's log4j page. From here I am just using the Apache Ivy <dependency> tag provided on that page:
<dependency org="log4j" name="log4j" rev="1.2.16" >
<artifact name="log4j" type="bundle" />
</dependency>
When I add this to my ivy.xml file and save it inside Eclipse, IvyDE automatically runs an Ivy resolve...and I am getting an error:
Ivy resolve job of ivy.xml in 'myProject' has encountered a problem.
Impossible to resolve dependencies of myOrg#myProject;working#myMachine
download failed: log4j#log4j;1.2.16!log4j.bundle
download failed: log4j#log4j;1.2.16!log4j.bundle
download failed: log4j#log4j;1.2.16!log4j.bundle
download failed: log4j#log4j;1.2.16!log4j.bundle
(Those last 4 lines, although identical, are in fact repeated 4 times!)
Is something wrong with log4j on Maven Central? All of my other jars resolve without a hitch, and I am using the same technique for getting all of my jars. This is the only one (out of 30 or so) that is failing. Thanks in advance!
Leave out the
<artifact name="log4j" type="bundle" />
part and it will download the normal jar file.
I don't think you need the bundle-specification part and it seems (to me) like some kind of anomaly.
bundle is not even a core packaging value for maven:
The current core packaging values are: pom, jar, maven-plugin, ejb,
war, ear, rar, par. These define the default list of goals which
execute to each corresponding build lifecycle stage for a particular
package structure.
I used following :
<dependency org="log4j" name="log4j" rev="1.2.17">
<artifact name="log4j" type="jar" />
</dependency>
and it worked.

Hudson plug-in not publishing all artifacts to Artifactory

I've got a small Java project setup to build continuously through a Hudson server. I'd like to publish the build artifacts to an Artifactory server as a post-build step so, naturally, I'm using the Hudson-Artifactory plug-in to facilitate this. The local publish appears to work just fine - it publishes the two artifacts (both .jar files) and the resolved ivy.xml file as expected. When I request a build on the Hudson server, however, only one of my two artifacts gets published.
The build creates the following artifacts:
ftpSvc.jar
ftpSvc-lib.jar
My ivy.xml file looks like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
<info organisation="esf"
status="integration"
module="ftpSvc"
revision="SNAPSHOT" />
<publications>
<artifact name="ftpSvc" ext="jar"/>
<artifact name="ftpSvc-lib" ext="jar" type="lib" />
</publications>
<!--list the dependencies of this project-->
<dependencies>
<dependency org="commons-net" name="commons-net" rev="1.3.0" />
</dependencies>
</ivy-module>
The two artifacts are clearly called out in the <publications> section. The build target in my build.xml file looks like this:
<target name="publish_local" description="publish artifacts locally">
<echo>organisation: ${ivy.organisation}</echo>
<echo>module: ${ivy.module}</echo>
<echo>status: ${ivy.status}</echo>
<echo>revision: ${ivy.revision}</echo>
<echo>local dir: ${ivy.default.ivy.user.dir}</echo>
<ivy:publish
resolver="local"
update="true"
verwrite="true"
srcivypattern="${bundle.jar.dir}/ivy.xml"
artifactspattern="${bundle.jar.dir}/[artifact].[ext]" />
</target>
The artifactspattern grabs all defined artifacts from the build directory - nothing fancy going on here. Lastly, the resolver chain in my ivysettings.xml file looks like this (server names changed to protect the innocent):
<resolvers>
<chain name="main">
<ibiblio name="main" m2compatible="true" root="http://my.server.employer.com:8080/artifactory/repo" />
<filesystem name="local">
<ivy pattern="${ivy.default.ivy.user.dir}/local/[organisation]/[module]/[revision]/ivy-[revision].xml" />
<artifact pattern="${ivy.default.ivy.user.dir}/local/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
</filesystem>
</chain>
</resolvers>
It's all rather routine stuff and, as mentioned above, the local publish works fine. Here's a peek at the console output when I build through Eclipse:
publish_local:
[echo] organisation: esf
[echo] module: ftpSvc
[echo] status: integration
[echo] revision: SNAPSHOT
[echo] local dir: C:\Users\myusername\.ivy2
[ivy:publish] :: publishing :: esf#ftpSvc
[ivy:publish] published ftpSvc to C:\Users\myusername\.ivy2/local/esf/ftpSvc/SNAPSHOT/ftpSvc-SNAPSHOT.jar
[ivy:publish] published ftpSvc-lib to C:\Users\myusername\.ivy2/local/esf/ftpSvc/SNAPSHOT/ftpSvc-lib-SNAPSHOT.jar
[ivy:publish] published ivy to C:\Users\myusername\.ivy2/local/esf/ftpSvc/SNAPSHOT/ivy-SNAPSHOT.xml
Both .jar files and the resolved ivy.xml file get published as expected. On my Hudson server, I've got the Artifactory Configuration settings configured thusly (again, some details have been changed to obscure my true superhero identity):
Artifactory server: http://my.server.employer.com:8080/artifactory
Target repository: target-repository
Ivy pattern: [organisation]/[module]/[revision]ivy-[revision].xml
Artifact pattern: "[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"
As you can see, the Ivy and Artifact patterns are exactly the same as the patterns in my local resolver from my ivysettings.xml file. Thus, when the build is run on the Hudson server, I'd expect the exact same artifacts to be published to my Artifactory server.
Let's take a look at the console output from the latest build on my Hudson server:
publish_local:
[echo] organisation: esf
[echo] module: ftpSvc
[echo] status: integration
[echo] revision: SNAPSHOT
[echo] local dir: /usr/share/tomcat6/.ivy2
[ivy:publish] :: publishing :: esf#ftpSvc
Collecting Module information for module: ftpSvc
Module location: /usr/share/tomcat6/.hudson/jobs/ftpSvc-ivy/workspace/trunk/out/jars/ftpSvc.jar
[ivy:publish] published ftpSvc to /usr/share/tomcat6/.ivy2/local/esf/ftpSvc/SNAPSHOT/ftpSvc-SNAPSHOT.jar
Collecting Module information for module: ftpSvc
Module location: /usr/share/tomcat6/.hudson/jobs/ftpSvc-ivy/workspace/trunk/out/jars/ftpSvc-lib.jar
[ivy:publish] published ftpSvc-lib to /usr/share/tomcat6/.ivy2/local/esf/ftpSvc/SNAPSHOT/ftpSvc-lib-SNAPSHOT.jar
Collecting Module information for module: ftpSvc
Module location: /tmp/ivy2450884590736960955.xml
[ivy:publish] published ivy to /usr/share/tomcat6/.ivy2/local/esf/ftpSvc/SNAPSHOT/ivy-SNAPSHOT.xml
Build finished triggered
Deploying artifact: http://my.server.employer.com:8080/artifactory/target-repository/esf/ftpSvc/SNAPSHOT/ftpSvc-SNAPSHOT.jar
Deploying artifact: http://my.server.employer.com:8080/artifactory/target-repository/esf/ftpSvc/SNAPSHOT/ftpSvc-SNAPSHOT.xml
Deploying build info to: http://my.server.employer.com.com:8080/artifactory/api/build
Dubya' Tee Eff!? Once again, the local publish appears to work just fine, publishing both jars and the ivy.xml file to the local/esf/ftpSvc/SNAPSHOT/ directory on the Hudson server. The Artifactory plug-in, on the other hand, gets everything totally wrong. Not only does it fail to publish one of the two jars, it renames the ivy.xml file incorrectly.
Are there any Hudson/Ivy/Artifactory experts out there that can shed some light on what's going on here? I've got multiple projects that are exhibiting the exact same behavior. Any and all assistance in resolving this problem would be greatly appreciated.
Hey, I haven't used that plugin, but I would try removing the dash from the name ftpSvc-lib and/or removing type="lib" from its artifact element, just to see what happens.
I got the same problem, filled a bug on the JFrog Jira, the bug has been marked resolved today, but as you can see in my comments on the Jira, I'm still confused about this resolution.
https://issues.jfrog.org/jira/browse/IAP-26?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
If anyone has an idea, any input would be great...

Categories