Archiva

database not being updated with project model information

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.0
  • Fix Version/s: 1.0.2
  • Component/s: None
  • Labels:
    None
  • Environment:
    OS: Windows XP
    Software: Java 5 Update 12 and Maven 2.0.4
  • Number of attachments :
    3

Description

I noticed Archiva database was not being updated with project model information in the following scenario:

1) Project B (1.0-SNAPSHOT) depends on Project A (1.0)
2) Project B is deployed to Archiva repository
3) Project B changes Project A dependency version from 1.0 to 1.1-SNAPSHOT
4) Project B is deployed to Archiva repository again.
5) The user executes 'Scan Repository Now' and 'Update Database Now' using Archiva.

At this point, if you browse project B, you'll notice it still keeps the reference to the former version of Project A, 1.0, and not 1.1-SNAPSHOT. However, if you download the POM file, you will see it has the lastet dependency version as expected.

NOTE: In project B POM file the snapshotRepository is configured with uniqueVersion equals to false.

  1. archiva-database.patch
    13/Dec/07 6:22 AM
    0.6 kB
    Dário Oliveros
  2. archiva-database-consumers.patch
    13/Dec/07 6:22 AM
    8 kB
    Dário Oliveros
  3. archiva-scheduled.patch
    13/Dec/07 6:22 AM
    2 kB
    Dário Oliveros

Issue Links

Activity

Hide
Dário Oliveros added a comment -

I just found out the project model information was not updated since it was not considered an unprocessed artifact. Therefore there was no consumer for updating database as it is for unprocessed artifacts, only for clean up. This problem happens only when you update a dependency version of a SNAPSHOT project that is already in the Archiva database.
I will see if I come up with a solution for this issue.

Show
Dário Oliveros added a comment - I just found out the project model information was not updated since it was not considered an unprocessed artifact. Therefore there was no consumer for updating database as it is for unprocessed artifacts, only for clean up. This problem happens only when you update a dependency version of a SNAPSHOT project that is already in the Archiva database. I will see if I come up with a solution for this issue.
Hide
Dário Oliveros added a comment -

Attached are the patch files of all components that have been modified.

Please let me know if they are OK.

Show
Dário Oliveros added a comment - Attached are the patch files of all components that have been modified. Please let me know if they are OK.
Hide
Maria Odea Ching added a comment -

I applied the patches locally and it doesn't seem to work for me I tested it with the scenario specified above using maven-antrun-plugin as the test artifact. i've just edited the pom file itself (changed the dependency junit version from 3.8.1 to 3.8.2 ) instead of re-deploying after making the changes. I got this error during the database update:

jvm 1 | 2007-12-18 14:56:21,093 [pool-1-thread-1] ERROR org.apache.maven.archiva.consumers.DatabaseUnprocessedArtifactConsumer:update-db-project - Unable to process model /home/deng/TestFiles/sample-local-repo/org/apache/maven/plugins/maven-ant-plugin/2.0-beta-1/maven-ant-plugin-2.0-beta-1.pom due to : javax.jdo.JDOUserException : Field org.apache.maven.archiva.model.ArchivaProjectModel.origin is null, but is mandatory as its described in the jdo metadata
jvm 1 | javax.jdo.JDOUserException: Field org.apache.maven.archiva.model.ArchivaProjectModel.origin is null, but is mandatory as its described in the jdo metadata
jvm 1 | at org.jpox.store.rdbms.fieldmanager.ParameterSetter.storeStringField(ParameterSetter.java:120)
jvm 1 | at org.jpox.state.StateManagerImpl.providedStringField(StateManagerImpl.java:2757)
jvm 1 | at org.apache.maven.archiva.model.ArchivaProjectModel.jdoProvideField(ArchivaProjectModel.java)
jvm 1 | at org.apache.maven.archiva.model.ArchivaProjectModel.jdoProvideFields(ArchivaProjectModel.java)
jvm 1 | at org.jpox.state.StateManagerImpl.provideFields(StateManagerImpl.java:3115)
jvm 1 | at org.jpox.store.rdbms.request.InsertRequest.execute(InsertRequest.java:252)
jvm 1 | at org.jpox.store.rdbms.table.ClassTable.insert(ClassTable.java:2519)
jvm 1 | at org.jpox.store.StoreManager.insert(StoreManager.java:920)
jvm 1 | at org.jpox.state.StateManagerImpl.internalMakePersistent(StateManagerImpl.java:3667)
jvm 1 | at org.jpox.state.StateManagerImpl.makePersistent(StateManagerImpl.java:3646)
jvm 1 | at org.jpox.AbstractPersistenceManager.internalMakePersistent(AbstractPersistenceManager.java:1198)
jvm 1 | at org.jpox.AbstractPersistenceManager.makePersistent(AbstractPersistenceManager.java:1261)
jvm 1 | at org.apache.maven.archiva.database.jdo.JdoAccess.saveObject(JdoAccess.java:192)
jvm 1 | at org.apache.maven.archiva.database.jdo.JdoAccess.saveObject(JdoAccess.java:165)
jvm 1 | at org.apache.maven.archiva.database.jdo.JdoProjectModelDAO.saveProjectModel(JdoProjectModelDAO.java:86)
jvm 1 | at org.apache.maven.archiva.consumers.database.ProjectModelToDatabaseConsumer.processArchivaArtifact(ProjectModelToDatabaseConsumer.java:170)
jvm 1 | at org.apache.maven.archiva.database.updater.ProcessArchivaArtifactClosure.execute(ProcessArchivaArtifactClosure.java:52)
jvm 1 | at org.apache.commons.collections.CollectionUtils.forAllDo(CollectionUtils.java:388)
jvm 1 | at org.apache.maven.archiva.database.updater.JdoDatabaseUpdater.updateUnprocessed(JdoDatabaseUpdater.java:152)
jvm 1 | at org.apache.maven.archiva.database.updater.JdoDatabaseUpdater.updateAllUnprocessed(JdoDatabaseUpdater.java:86)
jvm 1 | at org.apache.maven.archiva.scheduled.executors.ArchivaDatabaseUpdateTaskExecutor.executeTask(ArchivaDatabaseUpdateTaskExecutor.java:78)
jvm 1 | at org.codehaus.plexus.taskqueue.execution.ThreadedTaskQueueExecutor$ExecutorRunnable$1.run(ThreadedTaskQueueExecutor.java:116)
jvm 1 | at edu.emory.mathcs.backport.java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
jvm 1 | at edu.emory.mathcs.backport.java.util.concurrent.FutureTask.run(FutureTask.java:176)
jvm 1 | at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665)
jvm 1 | at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690)
jvm 1 | at java.lang.Thread.run(Thread.java:595)

Was this the error you've mentioned regarding the effective cache in your email in the dev list?
It would really be better if you could also provide tests for these changes Thanks Darios!

Show
Maria Odea Ching added a comment - I applied the patches locally and it doesn't seem to work for me I tested it with the scenario specified above using maven-antrun-plugin as the test artifact. i've just edited the pom file itself (changed the dependency junit version from 3.8.1 to 3.8.2 ) instead of re-deploying after making the changes. I got this error during the database update: jvm 1 | 2007-12-18 14:56:21,093 [pool-1-thread-1] ERROR org.apache.maven.archiva.consumers.DatabaseUnprocessedArtifactConsumer:update-db-project - Unable to process model /home/deng/TestFiles/sample-local-repo/org/apache/maven/plugins/maven-ant-plugin/2.0-beta-1/maven-ant-plugin-2.0-beta-1.pom due to : javax.jdo.JDOUserException : Field org.apache.maven.archiva.model.ArchivaProjectModel.origin is null, but is mandatory as its described in the jdo metadata jvm 1 | javax.jdo.JDOUserException: Field org.apache.maven.archiva.model.ArchivaProjectModel.origin is null, but is mandatory as its described in the jdo metadata jvm 1 | at org.jpox.store.rdbms.fieldmanager.ParameterSetter.storeStringField(ParameterSetter.java:120) jvm 1 | at org.jpox.state.StateManagerImpl.providedStringField(StateManagerImpl.java:2757) jvm 1 | at org.apache.maven.archiva.model.ArchivaProjectModel.jdoProvideField(ArchivaProjectModel.java) jvm 1 | at org.apache.maven.archiva.model.ArchivaProjectModel.jdoProvideFields(ArchivaProjectModel.java) jvm 1 | at org.jpox.state.StateManagerImpl.provideFields(StateManagerImpl.java:3115) jvm 1 | at org.jpox.store.rdbms.request.InsertRequest.execute(InsertRequest.java:252) jvm 1 | at org.jpox.store.rdbms.table.ClassTable.insert(ClassTable.java:2519) jvm 1 | at org.jpox.store.StoreManager.insert(StoreManager.java:920) jvm 1 | at org.jpox.state.StateManagerImpl.internalMakePersistent(StateManagerImpl.java:3667) jvm 1 | at org.jpox.state.StateManagerImpl.makePersistent(StateManagerImpl.java:3646) jvm 1 | at org.jpox.AbstractPersistenceManager.internalMakePersistent(AbstractPersistenceManager.java:1198) jvm 1 | at org.jpox.AbstractPersistenceManager.makePersistent(AbstractPersistenceManager.java:1261) jvm 1 | at org.apache.maven.archiva.database.jdo.JdoAccess.saveObject(JdoAccess.java:192) jvm 1 | at org.apache.maven.archiva.database.jdo.JdoAccess.saveObject(JdoAccess.java:165) jvm 1 | at org.apache.maven.archiva.database.jdo.JdoProjectModelDAO.saveProjectModel(JdoProjectModelDAO.java:86) jvm 1 | at org.apache.maven.archiva.consumers.database.ProjectModelToDatabaseConsumer.processArchivaArtifact(ProjectModelToDatabaseConsumer.java:170) jvm 1 | at org.apache.maven.archiva.database.updater.ProcessArchivaArtifactClosure.execute(ProcessArchivaArtifactClosure.java:52) jvm 1 | at org.apache.commons.collections.CollectionUtils.forAllDo(CollectionUtils.java:388) jvm 1 | at org.apache.maven.archiva.database.updater.JdoDatabaseUpdater.updateUnprocessed(JdoDatabaseUpdater.java:152) jvm 1 | at org.apache.maven.archiva.database.updater.JdoDatabaseUpdater.updateAllUnprocessed(JdoDatabaseUpdater.java:86) jvm 1 | at org.apache.maven.archiva.scheduled.executors.ArchivaDatabaseUpdateTaskExecutor.executeTask(ArchivaDatabaseUpdateTaskExecutor.java:78) jvm 1 | at org.codehaus.plexus.taskqueue.execution.ThreadedTaskQueueExecutor$ExecutorRunnable$1.run(ThreadedTaskQueueExecutor.java:116) jvm 1 | at edu.emory.mathcs.backport.java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442) jvm 1 | at edu.emory.mathcs.backport.java.util.concurrent.FutureTask.run(FutureTask.java:176) jvm 1 | at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665) jvm 1 | at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690) jvm 1 | at java.lang.Thread.run(Thread.java:595) Was this the error you've mentioned regarding the effective cache in your email in the dev list? It would really be better if you could also provide tests for these changes Thanks Darios!
Hide
Dário Oliveros added a comment -

Yes, that is correct. I would get this error if effective cache was not updated properly upon project removal.

Anyway, to make sure I was not missing anything, I've updated my working copy (trunk), applied the patches locally and forced a modification to a POM file by replacing one of its dependency version (tested against new deployment and manual change to a POM sitting in the repository). Everything worked as expected.

I would suggest you to do it from scratch once again:

1) Update working copy to latest revision and apply the patches.
2) Install and run local Archiva.
3) Create an empty repository.
4) Add two projects (A and B) to it where B depends on A
5) Follow the steps from test scenario.

BTW do you have any recommendation about creating test cases for Archiva ?
Any tip would be appreciated.

Thank you.

Show
Dário Oliveros added a comment - Yes, that is correct. I would get this error if effective cache was not updated properly upon project removal. Anyway, to make sure I was not missing anything, I've updated my working copy (trunk), applied the patches locally and forced a modification to a POM file by replacing one of its dependency version (tested against new deployment and manual change to a POM sitting in the repository). Everything worked as expected. I would suggest you to do it from scratch once again: 1) Update working copy to latest revision and apply the patches. 2) Install and run local Archiva. 3) Create an empty repository. 4) Add two projects (A and B) to it where B depends on A 5) Follow the steps from test scenario. BTW do you have any recommendation about creating test cases for Archiva ? Any tip would be appreciated. Thank you.
Hide
Dário Oliveros added a comment -

Yes, that is correct. I would get this error if effective cache was not updated properly upon project removal.

Anyway, to make sure I was not missing anything, I've updated my working copy (trunk), applied the patches locally and forced a modification to a POM file by replacing one of its dependency version (tested against new deployment and manual change to a POM sitting in the repository). Everything worked as expected.

I would suggest you to do it from scratch once again:

1) Update working copy to latest revision and apply the patches.
2) Install and run local Archiva.
3) Create an empty repository.
4) Add two projects (A and B) to it where B depends on A
5) Follow the steps from test scenario.

BTW do you have any recommendation about creating test cases for Archiva ?
Any tip would be appreciated.

Thank you.

Show
Dário Oliveros added a comment - Yes, that is correct. I would get this error if effective cache was not updated properly upon project removal. Anyway, to make sure I was not missing anything, I've updated my working copy (trunk), applied the patches locally and forced a modification to a POM file by replacing one of its dependency version (tested against new deployment and manual change to a POM sitting in the repository). Everything worked as expected. I would suggest you to do it from scratch once again: 1) Update working copy to latest revision and apply the patches. 2) Install and run local Archiva. 3) Create an empty repository. 4) Add two projects (A and B) to it where B depends on A 5) Follow the steps from test scenario. BTW do you have any recommendation about creating test cases for Archiva ? Any tip would be appreciated. Thank you.
Hide
Maria Odea Ching added a comment -

Hi Dario, I re-applied the patch again and did as was specified in the test scenario. The result was still the same for me though I still got the same error. Maybe there were some other changes in your local copy that didn't get included in the patches you've submitted? Anyway, I'll also look into why I'm getting the error.

For the tests, you could take a look at some of the test cases in Archiva as reference. As much as possible, it is recommended to use mock objects for the tests and cover as many different scenarios as you can. Another tip too (though not related to the tests), is you can also submit just one patch for all your changes. Instead of doing a diff per module, you can just diff on the top level directory

Thanks again!

Show
Maria Odea Ching added a comment - Hi Dario, I re-applied the patch again and did as was specified in the test scenario. The result was still the same for me though I still got the same error. Maybe there were some other changes in your local copy that didn't get included in the patches you've submitted? Anyway, I'll also look into why I'm getting the error. For the tests, you could take a look at some of the test cases in Archiva as reference. As much as possible, it is recommended to use mock objects for the tests and cover as many different scenarios as you can. Another tip too (though not related to the tests), is you can also submit just one patch for all your changes. Instead of doing a diff per module, you can just diff on the top level directory Thanks again!
Hide
Maria Odea Ching added a comment -

Applied the following sections from the archiva-database-consumers.patch in ProjectModelToDatabaseConsumer and DatabaseCleanupRemoveProjectConsumer:

// Force removal of project model from effective cache
String projectKey = toProjectKey( projectModel );
synchronized ( effectiveProjectCache )
{
if ( effectiveProjectCache.hasKey( projectKey ) )

{ effectiveProjectCache.remove( projectKey ); }

}
...
private String toProjectKey( ArchivaProjectModel project )

{ StringBuilder key = new StringBuilder(); key.append( project.getGroupId() ).append( ":" ); key.append( project.getArtifactId() ).append( ":" ); key.append( project.getVersion() ); return key.toString(); }

Other changes made:

  • delete the project model if it already exists in the database (ProjectModelToDatabaseConsumer)
  • added the effective-project-cache component in the DatabaseCleanupRemoveProjectModelTest

The above fixes are in -r637928. Thanks!

Show
Maria Odea Ching added a comment - Applied the following sections from the archiva-database-consumers.patch in ProjectModelToDatabaseConsumer and DatabaseCleanupRemoveProjectConsumer: // Force removal of project model from effective cache String projectKey = toProjectKey( projectModel ); synchronized ( effectiveProjectCache ) { if ( effectiveProjectCache.hasKey( projectKey ) ) { effectiveProjectCache.remove( projectKey ); } } ... private String toProjectKey( ArchivaProjectModel project ) { StringBuilder key = new StringBuilder(); key.append( project.getGroupId() ).append( ":" ); key.append( project.getArtifactId() ).append( ":" ); key.append( project.getVersion() ); return key.toString(); } Other changes made:
  • delete the project model if it already exists in the database (ProjectModelToDatabaseConsumer)
  • added the effective-project-cache component in the DatabaseCleanupRemoveProjectModelTest
The above fixes are in -r637928. Thanks!

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: