0

I'm trying to use an Updatesite.nsf to deploy jar to a test server. I can see it in this case the jdbc driver plugin at the server console using the http osgi ss command. But when I use it I get a java.lang.ClassNotFoundException com.mysql.jdbc.driver. What I'm missing or doing wrong. Thank you

Jesse Gallagher
  • 4,461
  • 13
  • 11
Bob Yesenskiy
  • 414
  • 2
  • 15

1 Answers1

1

The immediate answer is that the code that's calling Class.forName will need to have the MySQL driver in its classloader one way or another, which an XPage or in-NSF Java won't have by default.

To expand on it a bit:

If you're trying to call it from an XPage or Java code in an NSF, it would have to be part of an XPages Library from another plugin, which in turn depends on and re-exports the driver plugin.

If you're trying to call it from another plugin, that other plugin should have a Require-Bundle or Import-Package entry to bring it in.

The class will be available to NSFs by default if you plunk it in jvm/lib/ext, though that admittedly gives up the niceties of OSGi-based deployment.

The reason it works for the XPages JDBC support is that the wrapped plugins created by the wizard in Designer include a special extension point to provide the driver class to the ExtLib code that wants it, but they don't make it automatically available to XPages apps themselves.

Jesse Gallagher
  • 4,461
  • 13
  • 11
  • If I understand you correctly if I wanted to use the OSGi deployment I need to build Import package for the jar and re-import in the update site ? – Bob Yesenskiy Mar 25 '19 at 21:18
  • It depends on what you want to do with it. If your intent is to have the driver available for the XPages JDBC components, you don't need to be able to load it from inside the XPages code itself. If you want to load it and manually do your JDBC work, then you'd need to deploy it to the filesystem or make it part of an XPages Library plugin. – Jesse Gallagher Mar 25 '19 at 21:50