There was an error communicating with the database. Please contact the application administrator - mysql

i just running Bitnami Tomcat 8.5.24-2 in the google Cloud. and i need to connect to mysql and i do following as orbeon steps:
Create a new user orbeon with password orbeon and new schema orbeon.
Create the tables used for Orbeon Forms in the orbeon schema.
Download mysql-connector-java-5.1.33-bin.jar and copy it in xampp\tomcat\lib.
4 Edit Tomcat's server.xml, and within the for Orbeon Forms adding a <Resource>
auth="Container"
type="javax.sql.DataSource"
initialSize="3"
maxActive="10"
maxIdle="10"
maxWait="30000"
poolPreparedStatements="true"
testOnBorrow="true"
validationQuery="select 1"
username="orbeon"
password="orbeon"
url="jdbc:mysql://localhost:3306/orbeon?useUnicode=true&characterEncoding=UTF8"/>
and for Valve in same file
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="localhost_access_log"
suffix=".txt"
pattern="%h %l %u %t "%r" %s %b"/>
<property as="xs:string"
name="oxf.fr.persistence.provider.orbeon.library.*"
value="mysql"/>
and on Orbeon properties-local.xml
<properties xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:oxf="http://www.orbeon.com/oxf/processors">
<property as="xs:string"
me="oxf.fr.persistence.provider.*.*.*"
value="mysql"/>
</properties>

Related

Unable to access mysql from jpa after Catalina update

My jpa application was working fine (in fact, my 2 jpa applications) since I update my mac to Catalina (and restart it, of course).
Since then I got
org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator initiateService
WARN: HHH000342: Could not obtain connection to query metadata : null
Exception in thread "main" org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
...
Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
But from mySQL Workbench I can access my databases with no problem.
I've tried to reinstall mysql, even using brew to do it. Nothing works.
I changed nothing on my persistence.xml file nor my code.
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="MyProject" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/myschema"/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.password" value="MyPassword"/>
<property name="javax.persistence.schema-generation.database.action" value="update"/>
</properties>
</persistence-unit>
</persistence>
My mysql version is 8.0.19.
Thank you!
Next day update (28/4):
By now, I have:
1) Added this line to my persistence.xml:
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
As I got a new error...
Access denied for user 'root'#'localhost' (using password: YES)
2) Followed this instructions to set root password:
https://medium.com/#aungzanbaw/how-to-reset-root-user-password-in-mysql-8-0-a5c328d098a8
Now my new error is
Connection refused
Next next day update (29/4):
Today I stoped and started mysql from terminal:
sudo /usr/local/bin/mysql.server stop
sudo /usr/local/bin/mysql.server start
I then I got a new error
The server time zone value 'CEST' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the 'serverTimezone' configuration property) to use a more specifc time zone value if you want to utilize time zone support.
Let's continue my investigation!
Following this question: https://es.stackoverflow.com/questions/48935/configurar-zona-horaria-jdbc-driver-java/48946?newreg=494e1840d4404575a81dc4ec10200266
I modified persistence.xml:
So I got a
Table 'myschema.mytable' doesn't exist
error.
Finally I got it, not sure how... probably restarting from comand line.
Here my final persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="MyProject" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/myschema?serverTimezone=UTC"/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.password" value="MyPassword"/>
<property name="javax.persistence.schema-generation.database.action" value="update"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL8Dialect" />
</properties>
</persistence-unit>
</persistence>
Using MySQL8Dialect is necessary to be able to create the tables without that error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'type=MyISAM' at line 1

Netbeans/Glassfish - not connecting with jdbc using sun-resources.xml

I'm trying to get a Netbeans/Glassfish Enterprise application to run locally on my pc (it is currently working in production). I've gotten as far as the login display, but when I try to log in, the app throws the following exception:
SEVERE: "com.sun.enterprise.security.auth.login.common.LoginException: Login failed: javax.security.auth.login.LoginException: Failed file login for myloginname".
And the login servlet forwards to a login error page.
The web.xml in the "-web" project looks like this:
<resource-ref>
<res-ref-name>jdbc/my_name_MySQL</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
There's also a persistence.xml set up as follows:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="modCompJar-PU" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/my_name_MySQL</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
<property name="hibernate.cache.use_second_level_cache" value="true"/>
<property name="hibernate.cache.use_query_cache" value="true"/>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.EhCacheProvider"/>
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.SunONETransactionManagerLookup"/>
<property name="hibernate.query.factory_class" value="org.hibernate.hql.classic.ClassicQueryTranslatorFactory"/>
<property name="hibernate.search.default.indexBase" value="/opt/index/webInput"/>
</properties>
</persistence-unit>
</persistence>
Finally, there's a sun-resources.xml, which looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Resource Definitions //EN" "http://www.sun.com/software/appserver/dtds/sun-resources_1_3.dtd">
<resources>
<jdbc-resource enabled="true" jndi-name="jdbc/my_name_MySQL" object-type="user" pool-name="MyPool">
<description/>
</jdbc-resource>
<jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="com.mysql.jdbc.Driver" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="MyPool" non-transactional-connections="false" pool-resize-quantity="2" res-type="javax.sql.DataSource" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
<property name="URL" value="jdbc:mysql://localhost:33306/mydatabsename?relaxAutoCommit="true""/>
<property name="User" value="root"/>
</jdbc-connection-pool>
</resources>
Note I've set up a tunnel via Putty to use a remote database, thus the "33306" for the mysql port instead of 3306.
I also changed Netbeans to point to the remote server's database, using the tunneled port. That works because the clicking on the "Database" node under the "Services" shows the same databases as exist on the remote server.
I know the login is correct because when I log in to the application running on the server, I get in, and they're both accessing the same database.
I also noticed there are some jdbc connection pools set up in "domain.xml" which refer to non-existent databases and ip addresses. The only valid database is the one shown above, in "sun-resources.xml".
How can I get this app to connect to the right database?

cannot connect orbeon to my own mysql

I have tried all steps described in http://wiki.orbeon.com/forms/doc/developer-guide/form-runner/oracle-and-mysql-persistence-layers#TOC-MySQL2 . I am using Orbeon Forms 4.7 and XAMPP v3.2.1.
My steps are:
Create a new user orbeon with password orbeon and new schema orbeon.
Create the tables used for Orbeon Forms in the orbeon schema.
Download mysql-connector-java-5.1.33-bin.jar and copy it in xampp\tomcat\lib.
Edit Tomcat's server.xml, and within the for Orbeon Forms adding a
<Resource> element, i.e.:
<Resource name="jdbc/mysql" auth="Container" type="javax.sql.DataSource"
initialSize="3" maxActive="10" maxIdle="20" maxWait="30000"
driverClassName="com.mysql.jdbc.Driver"
poolPreparedStatements="true"
validationQuery="select 1 from dual"
testOnBorrow="true"
username="orbeon"
password="orbeon"
url="jdbc:mysql://localhost:3306/orbeon?useUnicode=true&characterEncoding=UTF8"/>
Now after I create the form,there is no data in mysql.
Is there any solutions or any steps I done wrong?
Based on your list of steps, it looks like you have missed the "Orbeon Forms setup" section of the docs. By default, all forms for all apps (except samples which are resource based) are configured to use the built-in eXist database.
You can use:
<property as="xs:string"
name="oxf.fr.persistence.provider.*.*.*"
value="mysql"/>
I noticed that with that configuration, the global library with the US Address section template disappears, so if you want that to show up, you need to also use:
<property as="xs:string"
name="oxf.fr.persistence.provider.orbeon.library.*"
value="exist"/>
Alternatively, you can just configure specific apps to use mysql:
<property as="xs:string"
name="oxf.fr.persistence.provider.hr.*.*"
value="mysql"/>
<property as="xs:string"
name="oxf.fr.persistence.provider.finance.*.*"
value="mysql"/>
Those aren't the only properties though. See the doc for the rest:
http://wiki.orbeon.com/forms/doc/developer-guide/form-runner/oracle-and-mysql-persistence-layers#TOC-Orbeon-Forms-setup

JBOSS 7 MYSQL missing dependencies error

There are many threads like this one already for similar errors but none which have solved my problem so after an hour of trying to debug it, I have decide to ask for help.
Background
I am setting up a Java EE project. I have create an enterprise application and have create an EJB project, JPA project and web Project and added EAR's to the enterprise project.
I have also added mysql-connector-java-5.1.0-bin to the JBOSS/standalone/deployments folder. And added to this jar file to the JPA project.
Any advice on how to solve the error would be greatly apprecited.
The main error is:
missing/unavailable dependencies" =>
["jboss.persistenceunit.\"SIMSProject.ear#primary\"jboss.naming.context.java.jboss.datasources.SIMSD
Here is my full error:
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from [Module "org.hibernate:main" from local module loader #32008dad (roots: C:\Users\Bawn92\Desktop\Programs\jboss-as-7.1.1.Final\modules)]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
at java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_07]
at java.lang.Class.forName(Class.java:186) [rt.jar:1.7.0_07]
at org.hibernate.internal.util.ReflectHelper.classForName(ReflectHelper.java:192)
at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:101)
... 23 more
01:50:40,265 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "SIMSProject.ear" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.persistenceunit.\"SIMSProject.ear#SIMSJPA\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"SIMSProject.ear#SIMSJPA\": Failed to start service"},"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"SIMSProject.ear#primary\"jboss.naming.context.java.jboss.datasources.SIMSDBMissing[jboss.persistenceunit.\"SIMSProject.ear#primary\"jboss.naming.context.java.jboss.datasources.SIMSDB]"]}
01:50:40,296 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015877: Stopped deployment SIMSWebProject.war in 31ms
01:50:40,296 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015877: Stopped deployment SIMSEJB.jar in 31ms
01:50:40,309 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015877: Stopped deployment SIMSProject.ear in 44ms
01:50:40,312 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014777: Services which failed to start: service jboss.persistenceunit."SIMSProject.ear#SIMSJPA": org.jboss.msc.service.StartException in service jboss.persistenceunit."SIMSProject.ear#SIMSJPA": Failed to start service
01:50:40,316 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.persistenceunit.\"SIMSProject.ear#SIMSJPA\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"SIMSProject.ear#SIMSJPA\": Failed to start service"},"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"SIMSProject.ear#primary\"jboss.naming.context.java.jboss.datasources.SIMSDBMissing[jboss.persistenceunit.\"SIMSProject.ear#primary\"jboss.naming.context.java.jboss.datasources.SIMSDB]"]}}}
MY -ds.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<datasources xmlns="http://www.jboss.org/ironjacamar/schema">
<datasource jndi-name="java:jboss/datasources/SIMSDB" enabled="true"
use-java-context="true" pool-name="SIMSDB">
<connection-url>jdbc:mysql://localhost:3306/mydb</connection-url>
<driver>mysql-connector-java-5.1.0-bin.jar</driver>
<pool></pool>
<security>
<user-name>root</user-name>
<password>nbuser</password>
</security>
</datasource>
</datasources>
My persistence.xml file is:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="primary">
<jta-data-source>java:jboss/datasources/SIMSDB</jta-data-source>
<properties>
<property name="hibernate.show_sql" value="false" />
</properties>
</persistence-unit>
<persistence-unit name="SIMSJPA">
<class>model.Class</class>
<class>model.Subject</class>
<class>model.Teacher</class>
<properties>
<!-- //i put in dialect line -->
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.connection.username" value="root"/>
<property name="hibernate.connection.password" value="nbuser"/>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/mydb"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
</properties>
</persistence-unit>
</persistence>
The datasourse section of my Standalone file is:
<datasource jndi-name="java:jboss/datasources/SIMSDB" pool-name="SIMSDB">
<connection-url>jdbc:mysql://localhost:3306/mydb</connection-url>
<driver>mysql-connector-java-5.1.0-bin.jar</driver>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>100</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>test</user-name>
<password>test</password>
</security>
<statement>
<prepared-statement-cache-size>32</prepared-statement-cache-size>
<share-prepared-statements/>
</statement>
</datasource>
<drivers>
<driver name="com.mysql" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>
You need to create MySQL driver module.
JBoss 7 will be able to use if you create it like this:
download the driver (jar file)
create directory in you server path: {$jboss-home}/modules/com/mysql/main
and paste the driver jar file here
in same folder create and new file module.xml
Insert following code in that module.xml (if your jar file is named mysql.jdbc.jar):
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
<resources>
<resource-root path="mysql.jdbc.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
Make sure the dependencies for your mysql.jdbc.jar are OK.
JBoss 7 is not using -ds.xml any more.
You allready doing setup for your databse in standalon.xml, this the right way.
Just make sure your migration is correct. I see you have diffent user name and password...
EDIT1:
I don't know how hibernate works with JBoss 7.
But I see you should try to change in your persistence.xml
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
to
<property name="hibernate.connection.driver_class" value="com.mysql"/>
because you are using com.mysql as module name. Otherwise you can change module name to com.mysql.jdbc.Driver.
In your standalone.xml
change
<driver>mysql-connector-java-5.1.0-bin.jar</driver>
to
<driver>com.mysql</driver>
because you gave com.mysql as name for your driver:
<driver name="com.mysql" module="com.mysql">

Connecting JSF Web Application deployed on Glassfish to a local MySQL database

I have glassfish running on the same server that the MySQL database is running on. When I attempt to deploy the web application via the admin console, I get the following error:
Error occurred during deployment: Exception while preparing the app : Invalid resource : solardbdatasource__pm. Please see server.log for more details.
I am however able to run the web application from another computer and connect remotely to the database, only when I attempt to deploy the application on the same server as the database do I get the error. My glassfish-resources.xml for my working remote connection:
<resources>
<jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false"
connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10"
connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit"
datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"
fail-all-connections="false" idle-timeout-in-seconds="300"
is-connection-validation-required="false" is-isolation-level-guaranteed="true"
lazy-connection-association="false" lazy-connection-enlistment="false"
match-connections="false" max-connection-usage-count="0" max-pool-size="32"
max-wait-time-in-millis="60000" name="mysql_solardb_rootPool"
non-transactional-connections="false" pool-resize-quantity="2"
res-type="javax.sql.DataSource" statement-timeout-in-seconds="-1"
steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
<property name="serverName" value="192.168.1.113"/>
<property name="portNumber" value="3306"/>
<property name="databaseName" value="solardb"/>
<property name="User" value="root"/>
<property name="Password" value="password"/>
<property name="URL" value="jdbc:mysql://192.168.1.113:3306/solardb?zeroDateTimeBehavior=convertToNull"/>
<property name="driverClass" value="com.mysql.jdbc.Driver"/>
</jdbc-connection-pool>
<jdbc-resource enabled="true" jndi-name="solardbdatasource" object-type="user" pool-name="mysql_solardb_rootPool"/>
When I attempt to deploy it on the server I change '192.168.1.113' to '127.0.0.1'(localhost) to no avail. My persistance.xml:
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="solar-decathlonPU" transaction-type="JTA">
<jta-data-source>solardbdatasource</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties/>
</persistence-unit>
</persistence>
My problem seemed to be that the stand alone download of glassfish does not come with the mysql connector. In addition, i needed to manually configure the jdbc connection pool via the administrator console. One final issue I ran into was the 'URL' property, there are actually two when setting up a connection pool by default: 'Url' and 'URL', with the latter being the one I wanted.