0

I have a very strange situation. I have a set of eclipse plugin projects which I am using tycho and maven for building them. I used JDBC driver in one of the projects and I have a test plugin to test this project. Since the com.mysql.jdbc plugin was not available in the eclipse p2 repository ( and we don't have our own p2), I imported the jdbc plugin and created an OSGi plugin and add the dependency to my local plugin.

I have multiple eclipse workspaces sat up. Only in the very first workspace that created the test and jdbc plugin, junit tests are working when I run them using eclipse run as -> Junit test command. When others or even me checkout the source codes and try to run the test in different workspaces, this exception is thrown:

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

I also tried using tycho integration test (runing mvn integration-test) but that doesn't work neither and I still get the same exception. I tried searching for this a lot but I couldn't find the answer.

UPDATE:I think it is not a tycho problem. I just tried to create the eclipse plug in based on com.jdbc.mysql jar. The workspace I created this on is working fine. But as soon as I commit the code and import the project in another workspace the tests stop working. All of the settings are same among two workspaces, one is working the other gets the ClassNotFound exception!

rozagh
  • 73
  • 1
  • 12
  • I have a very similar problem and I had thought I am missing something about using Junit in Tycho/EclipseRCP environment. So last week, I had asked the question : http://stackoverflow.com/questions/16166866/how-to-follow-test-first-approach-with-equinox-osgi-tycho-eclipse-rcp-enviro Now I have more hint about the problem and I explained briefly as a comment under oberlies' answer. I assume there is something wrong in system/configuration level. Also I think all the answers below regarding configuration would be helpful only if you could not run your tests at all. – Ozgun Alan Apr 29 '13 at 10:12

2 Answers2

0

Tycho computes the OSGi runtime based on the transitive dependencies of your test bundle. You probably have no design-time dependency on the mysql driver bundle (but rather only on the JDBC interfaces it implements)

Try adding a test runtime dependency on the mysql jdbc driver bundle. See http://wiki.eclipse.org/Tycho/FAQ#How_to_add_a_undeclared_dependency.3F__.28e.g..2C_OSGi_declarative_service.29 on how to do this.

jsievers
  • 1,853
  • 10
  • 13
0

ClassNotFoundExceptions in an OSGi runtime indicate that there is something wrong in the imports and/or export declarations in the OSGi manifests. The most frequent case is that a bundle claims to export a certain package, but doesn't actually have the binaries/class files of that package.

In a Tycho build, this can easily happen if you don't have the entry . in the bin.includes property in the build.properties.

oberlies
  • 11,503
  • 4
  • 63
  • 110
  • Thanks @oberlies, but I checked those before. The package is exported and the build properties is correct. But I still get teh classNotFoundException! – rozagh Apr 25 '13 at 18:11