cannot connect orbeon to my own mysql - 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

Related

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

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>

Wildfly 10 persistence MySQL table not found

I have a REST service which access a MySQL database. I'm using Wildfly 10 and MySQL 5.7.12. I am trying to get the EntityManager as an injection and I get the following error when executing the find method for my Entity mapping the table content.
org.h2.jdbc.JdbcSQLException: Table "MYTABLE" not found; SQL statement:
In the RESTService class I have
#PersistenceContext(unitName="myUnit")
protected EntityManager entityManager;
and my persistence.xml file is:
<?xml version="1.0" encoding="UTF-8"?>
<persistence 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"
version="2.1">
<persistence-unit name="myUnit">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/mytable" />
<property name="javax.persistence.jdbc.user" value="user" />
<property name="javax.persistence.jdbc.password" value="pass" />
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.archive.autodetection" value="class, hbm"/>
</properties>
</persistence-unit>
</persistence>
The issue is that if instead of using injection I retrieve the entity manager using the manual way everything works smothly.
EntityManagerFactory emFactory;
emFactory = Persistence.createEntityManagerFactory("myUnit");
EntityManager em = emFactory.createEntityManager();
Could you give me some hints on how to use the PersistenceContext? the code is somehow cleaner and I prefer to use it.
It looks like you 're getting the default datasource injected in your persistence Unit so I guess this depends on how the EntityManager is 'built'. One way to fix this is to create a datasource in WidFly and use it (through) its JNDI name in your persistence unit.
Feel free to report a bug http://issues.jboss.org/
You are setting up a RESOURCE_LOCAL persistence unit. You should configure it as such:
<persistence-unit transaction-type="RESOURCE_LOCAL">
In order to use a resource local persistence unit you cannot inject EntityManager, only EntityManagerFactory. You'll end up with a lot less plumbing if you switch to JTA datasource and let the server manage it.
If you absolutely don't want to edit standalone.xml, in WF8 anyway, you can drop yourdatasource-ds.xml file into your WEB-INF folder, or into the deployments directory alongside your .war file. There was talk of removing this from WF though so I don't know if it works in 10.x.

How to prevent database renewing its data in camunda

I am using
- camunda-bpm-wildfly-7.4.0
- mysql-5.6.24-winx64
- wildfly-8.2.1.Final
I have integerated mysql with camunda wildfly.
My datasource code in the standalone.xml is as follows,
<datasource jta="true" jndi-name="java:jboss/datasources/ProcessEngine" pool-name="ProcessEngine" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:mysql://localhost:8888/camundabpm?DB_CLOSE_DELAY=-1;MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE</connection-url>
<driver>mysql</driver>
How do I prevent the database resetting on server restart? It removes all data and replaces it with new data on every server start. So I am unable to persist my data between server on and off.
Update:
I found out that hibernate was deleting the tables from the db So I changed the property from this
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
to
<property name="hibernate.hbm2ddl.auto" value="update" />
after having a look at How to make Hibernate not drop tables. But now the tasklist process instances are removed and only the tables created by my project remain and all other tables are refreshed with new data.
Can you check the value of the databaseSchemaUpdate poroperty? It should be contained in the standalone.xml of our WildFly (very down). Make sure it os not set to create-drop.
See https://docs.camunda.org/manual/7.4/reference/deployment-descriptors/tags/process-engine/#configuration-properties

Keep JDBC references outside web.xml to deploy in Jetty, like in tomcat

I try to move some services from my Tomcat Server to Jetty, just to make some comparisons. Obviously I don't want to change my services, but I experiment some issues to deploy them with JDBC.
My services all use the same database to access datas, so I wrote my own library to make my requests. The services don't have any informations about the database, they just know they have to use the library. In this library I make connections with the database using this kind of code:
InitialContext ictx = new InitialContext();
Context envCtx = (Context) ictx.lookup("java:comp/env");
DataSource ds = (DataSource) envCtx.lookup("jdbc/mysql");
In Tomcat my services work well just adding a line in context.xml:
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" maxActive="100" maxIdle="30" maxWait="10000" name="jdbc/mysql" username="login" password="password" type="javax.sql.DataSource" url="jdbc:mysql://localhost:3306/mysql" />
So I just want to do the same in Jetty. I added the following block in my jetty.xml:
<New id="mysql" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg></Arg>
<Arg>jdbc/mysql</Arg>
<Arg>
<New class="org.apache.commons.dbcp.BasicDataSource">
<Set name="driverClassName">com.mysql.jdbc.Driver</Set>
<Set name="url">jdbc:mysql://localhost:3306/mysql</Set>
<Set name="username">login</Set>
<Set name="password">password</Set>
</New>
</Arg>
</New>
The server starts well and seem to work, but I get an error when I try to access to my services. In jetty's manual I found it's explictly written that I have to add some informations in web.xml like:
<resource-ref>
<description>My DataSource Reference</description>
<res-ref-name>jdbc/DSTest</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
So I wonder if there is any other solution, than write the same lines in all my web.xml services' files? Like adding a common xml file for all my server with the same informations ?
You can add it to the webdefault.xml that is used as the foundation for processing web.xml.
This file is typically located in etc/webdefault.xml of the distribution.
cheers

Do I need DataSource in JPA Hibernate project?

I am preparing some application with usage of JPA 2.0, Hibernate as provider, MySQL 5 as database, which will be deployed on JBoss AS 7.0.2.I have already configured some basics in persistence.xml and I came into some kind of trouble. I have noticed that some people also defines some specific DataSource on JBoss Management Console level.
My question is. Do I really need to worry about some DataSource or anything like that in Hibernate application?I thought it is important in old JDBC approach.In some books, where examples are shown, there is no such configuration in persistence.xml or hibernate.cfg.xml
Do I have to place mysql connector into JBOSS_HOME/standalone/deployments directory to use MySQL in my application?Here is content of my persistence.xml file:
<?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="SomeApp">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/somedb" />
<property name="hibernate.connection.username" value="" />
<property name="hibernate.connection.password" value="" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
</properties>
</persistence-unit>
</persistence>
Well, you can either access the database by:
providing the url/driver/password/etc. information in the persistence.xml using your jpa-provider properties (in your case hibernate.connection.*) or the JPA 2.0 standardised javax.persistence.jdbc.* ones - this basically looks like the example you've posted,
creating a Data Source in the ApplicationServer and just referring to it in the persistence.xml (through it's JNDI name you provide during creation) which might look similar to this (without the XML schema definition for the sake of brevity) :
<persistence>
<persistence-unit name="SomeApp">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/myDB</jta-data-source>
</persistence-unit>
</persistence>
What you're actually doing right now (with these properties) is using the JDBC.
I would definitely go with the creation of the Data Source in the ApplicationServer rather than providing it in the properties in persistence.xml. It allows you to dynamically change the end-database, it's type, credentials, manage connection pools, etc. without even touching your descriptor.
It's also safer, as the credentials are not written in the plain file left on your server.
As a side note, please remember that the javax.persistence.jdbc.* properties are a JPA provider must requirement for the Java SE environment, but it's optional for Java EE.
Hope that helps!
Do I have to place mysql connector into
JBOSS_HOME/standalone/deployments directory to use MySQL in my
application?
Yes you need to put Mysql J/connector for use it as JDBC Driver. Your application server (JBOss, Weblogic, Glassfish, etc) doesn't provide it because depend of the RDBMS that you are using (in this case Mysql) and the version of it.
In the case of JBoss 7 the JDBC driver can be installed into the container in one of two ways: either as a deployment or as a core module. For the pros/cons of both modes an detailed explanatio you can check the following documentation: http://community.jboss.org/wiki/DataSourceConfigurationInAS7