15

I am getting really frustrated about this one:

I am using an maven project, using jdbc with eclipselink. mvn install works as intended. Until I have to change the PW in the persistence.xml. When I do an mvn clean and afterwards mvn install the project is broken and the wrong (old) persistence.xml is still in use. In eclipse I have to do maven -> update project (using m2e addon) and mvn install works suddenly again.

Now my problem: On the deployment server I am using command line scripting and I found no mvn XYZ equivalent for the m2e functionality...

Is there some equivalent?

Explicit scenario:

I am developing on my local machine (osx/win7) in an maven project imported in eclipse. I have a JPA Persistence interface which encapsulate the database connection which is realized via eclipselink. I can deploy locally (mvn install) but after I run mvn clean and change the password in persistence.xml mvn install isn't possible anymore. I just get classDefNotFound Persistor in the tests because it static initialize the EntityManager which can't connect cause of the new persistence.xml -- or at least it's my opinion, because the stacktrace is not really helpful. But, after maven -> update project... in eclipse on the project, mvn install works again and the new password is taken (tests run!).

When I want to deploy the project on a remote machine (debian, commandline) I can't ´mvn install` the pulled project, cause after I changed the password in persistence.xml for deployment, it's again the wrong persistence.xml or at least some cached used. I hope that make it a bit more clear.

SOLUTION: Make sure persistence.xml is placed in src/main/resources/META-INF and not elsewhere. m2e catches persistence.xml from wrong places (in my case, src/main/java/META-INF). So it was basically just a wrong project structure.

bad_coder
  • 11,289
  • 20
  • 44
  • 72
ThommyH
  • 310
  • 2
  • 6
  • 15
  • This should be helpful: http://stackoverflow.com/questions/10564684/how-to-fix-error-updating-maven-project-unsupported-iclasspathentry-kind-4?answertab=oldest#tab-top – PCM Feb 20 '13 at 23:51

2 Answers2

4

Looks like you can use mvn eclipse:clean eclipse:eclipse to regenerate the eclipse project files -- hope that sorts you.

hd1
  • 33,938
  • 5
  • 80
  • 91
  • unfortunately it did not work out. after a mvn clean or fresh git pull i cant install. – ThommyH Feb 20 '13 at 23:57
  • What do you mean? you "cant install", edit your question with whatever errors you get and I'll be happy to take a look. – hd1 Feb 20 '13 at 23:59
  • 1
    He is obviously using the [m2e](http://eclipse.org/m2e/) Maven integration for eclipse. That does not harmonize with to the [Maven eclipse plugin](http://maven.apache.org/plugins/maven-eclipse-plugin/eclipse-mojo.html) that you mention. I would not use both in parallel. – FrVaBe Feb 21 '13 at 08:59
1

maven update project from eclipse is different because it will generate a Maven Dependencies class path container

mvn eclipse:eclipse generates a Referenced Library Container.

BuZZ-dEE
  • 6,075
  • 12
  • 66
  • 96
Scott Izu
  • 2,229
  • 25
  • 12