- This topic has 28 replies, 3 voices, and was last updated 19 years ago by
stainbk2.
-
AuthorPosts
-
Kalle-lumiMemberHello!!
I get an “java.lang.ClassNotFoundException: com.mysql.jdbc.Driver” ONLY when I try to make a jsp call to a java bean that should manage all connections to the database.
It works fine to connect directly from a jsp page to the datatbase (but this is a terrible architectural solution):
try {
Class.forName(“com.mysql.jdbc.Driver”);
// blah… blah…
} catch (SQLException e){
System.out.println(e.toString());
}The problem appears when Class.forName(“com.mysql.jdbc.Driver”);
is executed from the DbConnector.javaTo save you time and questions I want you to know that I have already:
————————————————————————————
– put the driver in tomcat/common/lib
– added it to the classpath in BOTH Eclipse settings and MyEclipse/Tomcat settingsConfiguration Summary:
——————————–
*** Date: Mon Mar 27 12:01:09 CEST 2006*** System properties:
OS=WindowsXP
OS version=5.1
Java version=1.5.0_06*** MyEclipse details:
MyEclipse Enterprise WorkbenchVersion: 4.1.0 GA
Build id: 20060122-4.1-GA*** Eclipse details:
Eclipse SDKVersion: 3.1.2
Build id: M20060118-1600Eclipse Platform
Version: 3.1.2
Build id: M20060118-1600Eclipse RCP
Version: 3.1.2
Build id: M20060118-1600Eclipse Java Development Tools
Version: 3.1.2
Build id: M20060118-1600Eclipse Plug-in Development Environment
Version: 3.1.2
Build id: M20060118-1600Eclipse Project SDK
Version: 3.1.2
Build id: M20060118-1600Eclipse startup command=-os
win32
-ws
win32
-arch
x86
-launcher
C:\Program\eclipse\eclipse.exe
-name
Eclipse
-showsplash
600
-exitdata
e28_2c
-vm
C:\WINDOWS\system32\javaw.exe!SESSION 2006-03-01 18:39:03.984 ———————————————–
eclipse.buildId=M20060118-1600
java.version=1.5.0_06
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=sv_SE
Command-line arguments: -os win32 -ws win32 -arch x86 -clean!ENTRY org.eclipse.ui 4 4 2006-03-01 18:53:11.953
!MESSAGE Unable to find Action Set: org.objectweb.lomboz.ws.axis.AxisActionSet
!SESSION 2006-03-06 14:19:18.359 ———————————————–
eclipse.buildId=M20060118-1600
java.version=1.5.0_06
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=sv_SE
Command-line arguments: -os win32 -ws win32 -arch x86!ENTRY org.eclipse.ui 4 0 2006-03-27 11:10:52.734
!MESSAGE Warning: Detected recursive attempt by part com.genuitec.eclipse.webdesigner.jsp to create itself (this is probably, but not necessarily, a bug)
!STACK 1
org.eclipse.ui.PartInitException: Warning: Detected recursive attempt by part com.genuitec.eclipse.webdesigner.jsp to create itself (this is probably, but not necessarily, a bug)
at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:543)
at org.eclipse.ui.internal.EditorReference.getEditor(EditorReference.java:223)
at org.eclipse.ui.internal.EditorManager.findEditor(EditorManager.java:477)
at org.eclipse.ui.internal.EditorManager.findEditor(EditorManager.java:402)
at org.eclipse.ui.internal.EditorManager.findEditor(EditorManager.java:372)
at org.eclipse.ui.internal.WorkbenchPage.findEditor(WorkbenchPage.java:1780)
at com.genuitec.eclipse.core.util.EditorUtil.getEditorForInput(EditorUtil.java:156)
at com.genuitec.eclipse.core.util.EditorUtil.checkConflictingEditor(EditorUtil.java:217)
at com.genuitec.eclipse.webdesigner2.HTMLMultiPageEditorPart.init(HTMLMultiPageEditorPart.java:873)
at org.eclipse.ui.internal.EditorManager.createSite(EditorManager.java:778)
at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:596)
at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:384)
at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:552)
at org.eclipse.ui.internal.EditorReference.getEditor(EditorReference.java:223)
at org.eclipse.ui.internal.EditorManager.findEditor(EditorManager.java:477)
at org.eclipse.ui.internal.EditorManager.findEditor(EditorManager.java:402)
at org.eclipse.ui.internal.EditorManager.findEditor(EditorManager.java:372)
at org.eclipse.ui.internal.WorkbenchPage.findEditor(WorkbenchPage.java:1780)
at org.eclipse.search.internal.ui.text.EditorOpener.showInEditor(EditorOpener.java:74)
at org.eclipse.search.internal.ui.text.EditorOpener.showWithReuse(EditorOpener.java:46)
at org.eclipse.search.internal.ui.text.EditorOpener.open(EditorOpener.java:35)
at org.eclipse.search.internal.ui.text.FileSearchPage.showMatch(FileSearchPage.java:168)
at org.eclipse.search.ui.text.AbstractTextSearchViewPage$8.run(AbstractTextSearchViewPage.java:764)
at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1044)
at org.eclipse.core.runtime.Platform.run(Platform.java:783)
at org.eclipse.search.ui.text.AbstractTextSearchViewPage.showMatch(AbstractTextSearchViewPage.java:768)
at org.eclipse.search.ui.text.AbstractTextSearchViewPage.showCurrentMatch(AbstractTextSearchViewPage.java:832)
at org.eclipse.search.ui.text.AbstractTextSearchViewPage.gotoNextMatch(AbstractTextSearchViewPage.java:798)
at org.eclipse.search.ui.text.AbstractTextSearchViewPage.handleOpen(AbstractTextSearchViewPage.java:1197)
at org.eclipse.search.ui.text.AbstractTextSearchViewPage$6.open(AbstractTextSearchViewPage.java:644)
at org.eclipse.jface.viewers.StructuredViewer$2.run(StructuredViewer.java:741)
at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1044)
at org.eclipse.core.runtime.Platform.run(Platform.java:783)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:44)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:148)
at org.eclipse.jface.viewers.StructuredViewer.fireOpen(StructuredViewer.java:739)
at org.eclipse.jface.viewers.StructuredViewer.handleOpen(StructuredViewer.java:968)
at org.eclipse.jface.viewers.StructuredViewer$6.handleOpen(StructuredViewer.java:1067)
at org.eclipse.jface.util.OpenStrategy.fireOpenEvent(OpenStrategy.java:243)
at org.eclipse.jface.util.OpenStrategy.access$2(OpenStrategy.java:238)
at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:277)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3125)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2758)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1699)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:367)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:103)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334)
at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
at org.eclipse.core.launcher.Main.run(Main.java:973)
at org.eclipse.core.launcher.Main.main(Main.java:948)
!SUBENTRY 1 org.eclipse.ui 4 0 2006-03-27 11:10:52.734
!MESSAGE Warning: Detected recursive attempt by part com.genuitec.eclipse.webdesigner.jsp to create itself (this is probably, but not necessarily, a bug)
Riyad KallaMemberHmm, your setup looks fine and where you put the JAR looks fine. Just to clarify, if you put that exact same snippet of code in your JSP, it works fine, but as soon as you put it in DBCOnnector and call out to it from a JSP, it blows up? What is the exact exception? (copy paste it)
Kalle-lumiMemberThe exact exception is the same as the subject of this forum topic:
“java.lang.ClassNotFoundException: com.mysql.jdbc.Driver”.
Riyad KallaMemberSomething you can do to forcefully make sure Tomcat can find the class is to navigate to your Tomcat connector settings and go to Paths, then click Add and append the MySQL Connector JAR to your class path.
The one thing I would point out is that what you are doing here is run-of-the-mill. It’s a setup that most of our users including all of the dev team use and it works fine so there is likely some really minor setup issue going on here, not some daunting big task.
Kalle-lumiMemberThanks. I have already added the jar to the classpath.
…as I wrote in my starting message of this forum thread above:
“To save you time and questions I want you to know that I have already:
————————————————————————————
– put the driver in tomcat/common/lib
– added it to the classpath in BOTH Eclipse settings and MyEclipse/Tomcat settings”Thanks for your effort. Do you have any other ideas or settings would be very useful? 🙂
Kalle-lumiMemberFollow up question:
Does it matter what name I enter in Eclipse > Window > Preferences > Java > Build Path > Classpath Variables > New… > Name
I have named it: com.mysql.jdbc.Driver
The value of the same in my case is: C:/Program/Tomcat-5.5.15/common/lib/mysql-connector-java-3.1.12-bin.jarCan you please post all the information we request in the [URL=http://www.myeclipseide.com/PNphpBB2+file-viewtopic-t-393.html]Posting Guidelines[/URL] thread at the top of this forum? That will give us some context so that we can determine if this is an installation issue, a configuration problem, or a bug. Thanks.
Riyad KallaMemberOh no, get rid of it from your Classpath Variables. YOu shouldn’t need to every add anything in there. Any particular reason you are doing that?
Do me a favor, launch Tomcat outside of MyEclipse and run your app. If it’s STILL giving the exception then you just have a bad setup with or without MyEclipse. Check to make sure that your JDBC driver is not in your project and getting deployed with it (check your deployed WEB-INF/lib dir to verify) and make sure you only have one copy under common/lib. Check under shared and /lib to see if ther eare other versions of it.
Kalle-lumiMemberNow I have
– shut down eclipse
– started tomcat from command shell
Tomcat now connects to database 🙂so after that I have
– removed the mysql.driver from the eclipse classpath
– tomcat still has it as before
but it doesnt work 🙁
Kalle-lumiMemberoh.. where did you go? This case is not closed, please…
I have the mysql driver in the myeclipse/tomcat/classpath
…but it still gives me the same exception when I try to connect
from jsp to DbConnetor.java: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Riyad KallaMemberSorry about the delay, I’ve been trying to reproduce this problem on two machines I had laying around here and both worked fine. Let’s try this, actually REMOVE the JDBC reference from your Paths settings for the Tomcat connector. So now the only place you have it is in your Tomcat/common/lib folder, right? Ok now startup Tomcat.
I’m wondering if this is causing a conflict.
Kalle-lumiMemberThanks for your patience =)
First a question:
– If a topic of mine has been “forgotten”, after how much time is it legitime for me to send you a private reminder message?And some answers:
After deleting the driver reference from myeclipse/tomcat/classpath as you told me and I start tomcat from within eclipse: I get the same problem
When I after that stop tomcat I get:
INFO: Stopping Coyote HTTP/1.1 on http-80
2006-mar-29 21:59:52 org.apache.coyote.http11.Http11BaseProtocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-8443
2006-mar-29 21:59:52 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: Failed shutdown of Apache Portable Runtimehm??
Riyad KallaMemberFirst a question:
– If a topic of mine has been “forgotten”, after how much time is it legitime for me to send you a private reminder message?Any time you want.
Can you try and upgrade to MyEclipse 4.1.1 just to make sure this isn’t some completely obscure bug that was fixed. I also want to get you on the same version I’m using for troubleshooting reasons.
I swear this problem is something rediculously simple, it’s just eluding us.
Kalle-lumiMemberOk I will backup my workspace first. How many hours will you be here now?
(You are 7 hours after me and here the time is 22:30)
Riyad KallaMemberWe don’t sleep, I’m always here.
Kalle-lumiMemberOk. I am back.
Now I have upgraded to MyEclipse 4.1.1 and we are having the same problem.
Starting tomcat from within eclipse makes mysql.driver not loading.
Starting tomcat from command shell makes mysql.driver loading correctly.Note: Now I have no eclipse/tomcat/classpath set to the mysql.driver since your last directive.
Do you need to read any other of my log files or preferences?This is my new MyEclipse Coniguration Summary:
*** Date: Wed Mar 29 23:24:57 CEST 2006
*** System properties:
OS=WindowsXP
OS version=5.1
Java version=1.5.0_06*** MyEclipse details:
MyEclipse Enterprise WorkbenchVersion: 4.1.1 GA
Build id: 20060309-4.1.1-GA*** Eclipse details:
Eclipse SDKVersion: 3.1.2
Build id: M20060118-1600Eclipse Platform
Version: 3.1.2
Build id: M20060118-1600Eclipse RCP
Version: 3.1.2
Build id: M20060118-1600Eclipse Java Development Tools
Version: 3.1.2
Build id: M20060118-1600Eclipse Plug-in Development Environment
Version: 3.1.2
Build id: M20060118-1600Eclipse Project SDK
Version: 3.1.2
Build id: M20060118-1600Eclipse startup command=-os
win32
-ws
win32
-arch
x86
-launcher
C:\Program\eclipse\eclipse.exe
-name
Eclipse
-showsplash
600
-exitdata
7ec_3c
-vm
C:\WINDOWS\system32\javaw.exe -
AuthorPosts