GlassFish Server Open Source Edition 3.1.2.2(ビルド5)をMySqlで実行しています
NetBeansを使用してJDBC接続プールを作成しました。
この問題をグーグルで検索すると、クラスパスの追加がクラスパスの問題であることがわかりました。 GlassfishクラスパスへのMySQLデータベースの接続が設定されていないか、クラス名が間違っています および http://bhapca.blogspot.in/2009/06/class-name-is-wrong-or- classpath-is-not.html ディレクトリにjarを追加しました。
C:\Program Files\glassfish-3.1.2.2\glassfish\domains\domain1\lib
また、試してみました
C:\Program Files\glassfish-3.1.2.2\glassfish\domains\domain1\lib\ext
サーバーを何度も再起動しました。接続プールを再作成しました。まだ成功していません。
Admin Consoleからpingを実行すると、これが表示されます
Error An error has occurred
Ping Connection Pool failed for AffableBeanPool. Class name is wrong or classpath is not set for : com.mysql.jdbc.jdbc2.optional.MysqlDataSource Please check the server.log for more details.
関連サーバーログエントリ:
Log Entry Detail
Timestamp
Jul 15, 2013 15:45:49.340
Log Level
WARNING
Logger
javax.enterprise.resource.resourceadapter.com.Sun.enterprise.connectors.service
Name-Value Pairs
_ThreadID=22;_ThreadName=Thread-2;
Record Number
3172
Message ID
RAR8054
Complete Message
Exception while creating an unpooled [test] connection for pool [ AffableBeanPool ], Class name is wrong or classpath is not set for : com.mysql.jdbc.jdbc2.optional.MysqlDataSource
そして
Log Entry Detail
Timestamp
Jul 15, 2013 15:39:33.777
Log Level
SEVERE
Logger
javax.enterprise.resource.resourceadapter.com.Sun.gjc.util
Name-Value Pairs
_ThreadID=27;_ThreadName=Thread-2;
Record Number
3153
Message ID
Complete Message
RAR5099 : Wrong class name or classpath for Datasource Object Java.lang.ClassNotFoundException: com.mysql.jdbc.jdbc2.optional.MysqlDataSource at Java.net.URLClassLoader$1.run(URLClassLoader.Java:202) at Java.security.AccessController.doPrivileged(Native Method) at Java.net.URLClassLoader.findClass(URLClassLoader.Java:190) at Java.lang.ClassLoader.loadClass(ClassLoader.Java:307) at Java.lang.ClassLoader.loadClass(ClassLoader.Java:248) at Java.lang.Class.forName0(Native Method) at Java.lang.Class.forName(Class.Java:247) at com.Sun.gjc.common.DataSourceObjectBuilder.getDataSourceObject(DataSourceObjectBuilder.Java:285) at com.Sun.gjc.common.DataSourceObjectBuilder.constructDataSourceObject(DataSourceObjectBuilder.Java:114) at com.Sun.gjc.spi.ManagedConnectionFactory.getDataSource(ManagedConnectionFactory.Java:1307) at com.Sun.gjc.spi.DSManagedConnectionFactory.getDataSource(DSManagedConnectionFactory.Java:163) at com.Sun.gjc.spi.DSManagedConnectionFactory.createManagedConnection(DSManagedConnectionFactory.Java:102) at com.Sun.enterprise.connectors.service.ConnectorConnectionPoolAdminServiceImpl.getUnpooledConnection(ConnectorConnectionPoolAdminServiceImpl.Java:697) at com.Sun.enterprise.connectors.service.ConnectorConnectionPoolAdminServiceImpl.testConnectionPool(ConnectorConnectionPoolAdminServiceImpl.Java:426) at com.Sun.enterprise.connectors.ConnectorRuntime.pingConnectionPool(ConnectorRuntime.Java:1086) at org.glassfish.connectors.admin.cli.PingConnectionPool.execute(PingConnectionPool.Java:130) at com.Sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.Java:348) at com.Sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.Java:363) at com.Sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.Java:1085) at com.Sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.Java:95) at com.Sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.Java:1291) at com.Sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.Java:1259) at org.glassfish.admin.rest.ResourceUtil.runCommand(ResourceUtil.Java:214) at org.glassfish.admin.rest.resources.TemplateExecCommand.executeCommand(TemplateExecCommand.Java:127) at org.glassfish.admin.rest.resources.TemplateCommandGetResource.processGet(TemplateCommandGetResource.Java:78) at Sun.reflect.GeneratedMethodAccessor188.invoke(Unknown Source) at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:25) at Java.lang.reflect.Method.invoke(Method.Java:597) at com.Sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.Java:60) at com.Sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.Java:205) at com.Sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.Java:75) at com.Sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.Java:288) at com.Sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.Java:134) at com.Sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.Java:147) at com.Sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.Java:134) at com.Sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.Java:147) at com.Sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.Java:108) at com.Sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.Java:147) at com.Sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.Java:84) at com.Sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.Java:1469) at com.Sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.Java:1400) at com.Sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.Java:1349) at com.Sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.Java:1339) at com.Sun.jersey.server.impl.container.grizzly.GrizzlyContainer._service(GrizzlyContainer.Java:182) at com.Sun.jersey.server.impl.container.grizzly.GrizzlyContainer.service(GrizzlyContainer.Java:147) at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.Java:148) at com.Sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.Java:179) at com.Sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.Java:117) at com.Sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.Java:354) at com.Sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.Java:195) at com.Sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.Java:860) at com.Sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.Java:757) at com.Sun.grizzly.http.ProcessorTask.process(ProcessorTask.Java:1056) at com.Sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.Java:229) at com.Sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.Java:137) at com.Sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.Java:104) at com.Sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.Java:90) at com.Sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.Java:79) at com.Sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.Java:54) at com.Sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.Java:59) at com.Sun.grizzly.ContextTask.run(ContextTask.Java:71) at com.Sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.Java:532) at com.Sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.Java:513) at Java.lang.Thread.run(Thread.Java:662)
Jdbc jarをドメインフォルダーに配置しました。Glassfishサーバーフォルダーに配置してみてください。C:\Program Files\glassfish-3.1.2.2\glassfish\lib
右、mysql libが見つかりません。mysql-connector-Java-5.x.x-bin.jarのコピーをE:\Projects\glassfish3.1.1\glassfish\lib
その後、サーバーを再起動してお楽しみください!!!
この場所にmysqlコネクタjarを配置できます。 E:\ servers\glassfish4\glassfish\domains\domain1\libで動作します