**I wanted to configure Tomcat6.0 authentication via JDBC realm Configuration.****
I checked following:
-All my "users" and "roles" are stored in MySQL database.
-MySQL JDBC drives are in tomcat\lib directory
-Tomcat-user-xml is modified for such realm as below
<-Realm
className="org.apache.catalina.realm.JDBCRealm" driverName="org.gjt.mm.mysql.Driver"
connectionName="XXX" connectionPassword="YYY"
connectionURL="jdbc:mysql://localhost/mydb"
digest="MD5"
userTable="users" userNameCol="username"
userCredCol="password"
userRoleTable="user_roles" roleNameCol="rolename"/>
After doing this whenever I try to run Tomcat and try to run 'Manager' then it throws Authentication error on browser
and Catalina.log contain following error log everytime.
SCHWERWIEGEND: Exception opening
database connection
java.sql.SQLException: Access denied
for user
'XXX';password=XXXX'#'localhost'
(using password: NO) at
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3558)
at
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3490)
at
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:919)
at
com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3996)
at
com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1284)
at
com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2142)
at
com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:781)
at
com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:46)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method) at
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown
Source) at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source) at
java.lang.reflect.Constructor.newInstance(Unknown
Source) at
com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at
com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:352)
at
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:284)
at
org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:703)
at
org.apache.catalina.realm.JDBCRealm.start(JDBCRealm.java:775)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1037)
at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at
org.apache.catalina.core.StandardService.start(StandardService.java:516)
at
org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at
org.apache.catalina.startup.Catalina.start(Catalina.java:583)
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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Please anybody have idea what is going wrong and at which point.
Thanks
use it as:
<Realm className="org.apache.catalina.realm.JDBCRealm"
connectionURL="jdbc:mysql://localhost/mydb?user=XXX&password=YYY"
driverName="com.mysql.jdbc.Driver"
...
rest same as before/>
From the exception it seems that the username and/or password of the database user are incorrect. Make sure that they are spelled right and that a database user with the proper access rights is actually created.
I had the same problem when my server.xml was the following:
<Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
driverName="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/authorization"
connectionName="root"
connectionPassword="xxxxx"
userTable="user_table"
userNameCol="user"
userCredCol="password"
userRoleTable="role_table"
roleNameCol="role" />
but finally I found it was wrong in tomcat7, it should be:
<Realm className="org.apache.catalina.realm.JDBCRealm"
driverName="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/authorization?user=root&password=xxxxxx"
userTable="user_table"
userNameCol="user"
userCredCol="password"
userRoleTable="role_table"
roleNameCol="role" />
Related
I have installed a spark 2.4.7 using "spark-2.4.7-bin-hadoop2.6.tgz"
I could see the metastore_db got created automatically under the usr home directory and it contains derby database. Also when I developer runs a query it throws error like below
Caused by: javax.jdo.JDOFatalDataStoreException: Unable to open a test connection to the given database. JDBC url = jdbc:derby:;databaseName=metastore_db;create=true, username = APP. Terminating connection pool (set lazyInit to true if you expect to start your database after your app). Original Exception: ------
java.sql.SQLException: Failed to start database 'metastore_db' with class loader org.apache.spark.sql.hive.client.IsolatedClientLoader$$anon$1#6cde460, see the next exception for details.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.seeNextException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.bootDatabase(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
at org.apache.derby.jdbc.InternalDriver$1.run(Unknown Source)
at org.apache.derby.jdbc.InternalDriver$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.derby.jdbc.InternalDriver.getNewEmbedConnection(Unknown Source)
at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:208)
at com.jolbox.bonecp.BoneCP.obtainRawInternalConnection(BoneCP.java:361)
at com.jolbox.bonecp.BoneCP.<init>(BoneCP.java:416)
we are not planning to use derby database, I have MySQL database ready on a different host, can some one please help me understand how can I change the config to point my spark to MySQL instead of the derby??
Thanks in advance
Suresh
I can't connect to our database using Squirrel. I am certain my URL is correct as I'm using it via my java code to access the database.
I got the drivers from here: http://dev.mysql.com/downloads/file.php?id=454395
What is interesting is when I add the driver to MySQL in squirrel it shows it as:
com.mysql.fabric.jdbc.FabricMySQLDriver
In the past when I've used squirrel it would just show com.mysql.jdbc.Driver and no "fabric" stuff.
Stack trace:
java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.sql.SQLException: Unable to create connection. Check your URL.
at java.util.concurrent.FutureTask.report(Unknown Source)
at java.util.concurrent.FutureTask.get(Unknown Source)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.awaitConnection(OpenConnectionCommand.java:132)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.access$100(OpenConnectionCommand.java:45)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand$2.run(OpenConnectionCommand.java:115)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: java.sql.SQLException: Unable to create connection. Check your URL.
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.executeConnect(OpenConnectionCommand.java:171)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.access$000(OpenConnectionCommand.java:45)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand$1.run(OpenConnectionCommand.java:104)
... 5 more
Caused by: java.sql.SQLException: Unable to create connection. Check your URL.
at net.sourceforge.squirrel_sql.fw.sql.SQLDriverManager.getConnection(SQLDriverManager.java:136)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.executeConnect(OpenConnectionCommand.java:167)
... 7 more
Double-click on the MySQL driver in the Drivers window. Take a look at the class name dropdown at the bottom of the newly opened window. Click on the dropdown arrow and see if you can select the original com.mysql.jdbc.Driver class name.
I got a WAR-file for a working webservice, which accesses MySQL through JDBC hosted in TomCat 7.
Code:
private static final String db_jdbc_connection = "jdbc:mysql://localhost:3306/jsea";
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(db_jdbc_connection, "root, "secret");
However, this causes the following error:
No suitable driver found for jdbc:mysql://localhost:3306/jsea
[ERROR] Exception occurred while trying to invoke service method clientSignUp
java.lang.reflect.InvocationTargetException
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.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:212)
at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:117)
at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)
at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:172)
at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:146)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
In the web-inf/LIB folder of the webservice the following JAR-file is present:
mysql-connector-java-5.1.23-bin.jar
Also tried copying this file to tomcat/lib folder.
MySQL is configured with database jsea and the users provided in the connection have permissions.
In MySQL log I see no entries at all.
I have Googled for hours now and I have really no clue. What am I doing wrong ?
No suitable driver" usually means that the JDBC URL you've supplied to connect has incorrect syntax or when the driver isn't loaded at all.
When the method getConnection is called, the DriverManager will attempt to locate a suitable driver from amongst those loaded at initialization and those loaded explicitly using the same classloader as the current applet or application.(using Class.forName())
I would suggest to place mysql-connector-java-5.1.23-bin.jar at /WEB-INF/lib directory of your project and restart Tomcat. Also, Check Tomcat logs, you should find something unusual.
I really have no idea what has caused the problem. I have received the source code of the webservice, cleaned the project, rebuilt, and it suddenly works....
When attempting to connect to a MySQL 5.x database in a JSP webapplication running on Tomcat 6, I am getting the following exception:
org.apache.jasper.JasperException: javax.servlet.ServletException: com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
java.net.SocketException
MESSAGE: java.security.AccessControlException: access denied (java.net.SocketPermission [0:0:0:0:0:0:0:1]:3307 connect,resolve)
STACKTRACE:
java.net.SocketException: java.security.AccessControlException: access denied (java.net.SocketPermission [0:0:0:0:0:0:0:1]:3307 connect,resolve)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:151)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:280)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:1699)
at com.mysql.jdbc.Connection.<init>(Connection.java:405)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:268)
at java.sql.DriverManager.getConnection(DriverManager.java:620)
at java.sql.DriverManager.getConnection(DriverManager.java:200)
at org.apache.jsp.doLogin_jsp._jspService(doLogin_jsp.java:70)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:244)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAsPrivileged(Subject.java:537)
at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:276)
at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:162)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:283)
at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:56)
at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:189)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:185)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:636)
What could be the cause and how can I fix it?
Here is the relevant bit of the trace:
java.net.SocketException MESSAGE: java.security.AccessControlException: access denied (java.net.SocketPermission [0:0:0:0:0:0:0:1]:3307 connect,resolve)
The webapp doesn't have the permission to connect/resolve the mentioned socket. You need to configure it at Tomcat level. Open /conf/catalina.policy and add the following block of code:
grant {
permission java.net.SocketPermission "localhost:3307", "connect,resolve";
};
If you want to be a bit more restrictive, e.g. granting access to a specific JDBC driver only which is present in /lib/filename.jar, then add this instead:
grant codeBase "jar:file:${catalina.home}/lib/filename.jar!/-" {
permission java.net.SocketPermission "localhost:3307", "connect,resolve";
};
Unrelated to the concrete problem, the following lines
at java.sql.DriverManager.getConnection(DriverManager.java:200)
at org.apache.jsp.doLogin_jsp._jspService(doLogin_jsp.java:70)
indicate that you're connecting the DB inside a JSP file. Maybe you're just starting and learning, but I would only mention that this is not the best practice. DB connectivity should be done in its own classes which you in turn use in a servlet class which in turn forwards to the JSP which in turn displays the results. Calling the servlet by URL should then yield the same results, but you end up with better reuseable and maintainable code.
We run a corporate proxy with authentication and we're running Hudson as our CI platform. Hudson can get to the outside world to tell which plugins need updating, but when we tell Hudson to download the updates to the plugins, we get the following error.
java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy service is denied. )"
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$6.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
at hudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:603)
at hudson.model.UpdateCenter$DownloadJob.run(UpdateCenter.java:812)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy service is denied. )"
at sun.net.www.protocol.http.HttpURLConnection.doTunneling(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(Unknown Source)
at java.net.URLConnection.getHeaderFieldInt(Unknown Source)
at java.net.URLConnection.getContentLength(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getContentLength(Unknown Source)
at hudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:602)
... 7 more
Does anyone know how I can configure Hudson or our JRE or whatever needs configuring, to allow Hudson to update via the GUI? Sure we can download updates manually but that gets annoying after a while.
Currently we have Hudson installed as a service on windows server 2008 and its using the built in server that came with Hudson to host it. Also, I've set the proxy configuration via the "Advanced" tab
Two things to do
1. Pop over into the plugin manager and select advanced, enter the settings in there
2. Set the properties of the JRE http://java.sun.com/javase/6/docs/technotes/guides/net/properties.html
You can set properties using the -Dproperty.name=some.value syntax when starting up hudson.