Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Class Not Found Exception for com.mysql.jdbc.Driver Wildfly 10  RSS feed

 
Sean Jensen
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using Wildfly 10 and my datasource in the standalone.xml is:



I'm running this code in my Java bean:


and I get this error message:



I read documentation that said I needed to have the driver in my lib folder for Tomcat so I tried it but that didn't work. I'm sure the solution is simple but I don't see it. Can someone point me in the right direction. Some documentation that I can use as a resource would be great.
 
Dave Tolls
Rancher
Posts: 2914
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For starters you don't need that Class.forName() call in your code.
The Data Source deals with all that and, in any case, a class 4 driver (which is what you;re using) self-registers, so it's not necessary anyway.

Is that exception thrown from that line?
 
Sean Jensen
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes that exception is thrown from that line. I thought the line seemed odd myself but I found multiple examples of people using it. The original problem was that I was getting an error on the Connection definition:

which gave me this error:



The thing is I've tested that connection because it is used in my code already. My data adapters work just fine. I know the code works because I've used it locally. I need to run this process to generate reports on the fly. I've looked around and tried a number of things but I just can't seem to find the instructions for making this connection work on the server.
 
Dave Tolls
Rancher
Posts: 2914
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've got a data source, so you should be getting your connection from there, not via the DriverManager.
 
Sean Jensen
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I totally agree. I posted on two other forums and one of them suggested an possible solution which I will try in a few minutes but if you can point me towards that code I will have another source. If not I'll post the solution if that turns out to be it.
 
Sean Jensen
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what worked for me:


Thank you for replying.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!