Eclipse - JBoss (Hibernate) tools not showing any tables - eclipse

I want to use JBoss tools in Eclipse to generate java code from DDL.
I am using the following:
Oracle XE
Eclipse Helios (SpringSource version)
JBoss Tools
I've configured the hibernate.cfg.xml (as below) and created a sample application to insert and update records in XE and it works fine.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:#localhost:1521:xe</property>
<property name="hibernate.connection.username">admin</property>
<property name="hibernate.connection.password">admin</property>
<property name="hibernate.default_schema">users</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<mapping resource="users.hbm.xml"/>
</session-factory>
</hibernate-configuration>
But when I select (in hibernate perspective) File->New->Hibernate console configuration, I get the following in the "Hibernate Configurations" window:
-Console
+Configuration
+Session Factory
+Database
Expanding the "Database" above shows "pending" for few seconds and then shows nothing. I expecting it to show the table names. I am struggling to find out the reason. There are no exceptions\errors in any of the log files, nothing on console, all XE services are running, hibernate configuration is correct because my sample app works.
While creating the "console configuration" I created a new database connection and have done the "Test connection" and it shows "Ping successfully" message. I've used the following in the configuration:
hibernate.connection.url jdbc:oracle:thin:#localhost:1521:xe
hibernate.dialect org.hibernate.dialect.Oracle10gDialect
hibernate.connection.driver_class oracle.jdbc.OracleDriver
Any help is appreciated. Thanks.

Fixed it..
had to change the following
<property name="hibernate.default_schema">users</property>
to
<property name="hibernate.default_schema">USERS</property>

I had this same problem, then found out my database had no tables in it and felt embarrassed. After creating a quick table, it worked. Will never get that time back..

Related

How to embed database in javadb with my javafx standalone database application

I am creating a desktop application using JavaFx with database integration. When I run the Java DB server from programfiles/sun/javadb it shows me ClassNotFound Exception but the same thing when i run from NetBeans IDE it works.. So please tell me how to make my application run without NetBeans IDE. I also want to create its exe. How can we embed database with JAR. while creating exe.
You will need to include the Derby jar files (at least derby.jar, maybe some others) in your application CLASSPATH.
I'm an Eclipse user so I can't help you with Netbeans but here how it's done in Eclipse: in this explanation I used JPA in Java SE (this is from a real project so I hope I could help)
First export the the project as a jar:
Click File -> export -> and choose Java/Runnable JAR file -> Click
Next
-> Eclipse automatically will find and select your Main class + select the location where you want eclise to save the JAR file
-> select package required libraries into generated JAR -> click finish.
Next, I assume you create your database manually, let's assume the the db folder is called finance. now put the db folder in the same folder as the JAR, I used JPA in this project of mine so here is the persistence.xml
<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="FinanPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>lite.money.entities.Category</class>
<!-- <shared-cache-mode>NONE</shared-cache-mode> -->
<properties>
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
<property name="javax.persistence.jdbc.url" value="jdbc:derby:finance;" /> <!-- Derby -->
<property name="eclipselink.ddl-generation.output-mode" value="database" />
</properties>
</persistence-unit>
this line:
<property name="javax.persistence.jdbc.url" value="jdbc:derby:finance;" />
as you can see finance is the path to your DATABASE FOLDER, and since it's a relative path; the db driver will search for the folder in the same folder that the JAR exist.
and this how I embed JavaDB with JavaFX applications (using JPA of course).

Arquillian: Do I need domain.xml and arquillian.xml for minimal Glassfish Embedded tests with Derby DB?

in the internet I often find recent but contrary information on this topic..., thus I would like to ask a question on minimum requirements.
My goal is to do a very simple integration test of simple EJB 3.1 application:
Simple JPA 2.0 functionality with EclipseLink
Arquillian with JUnit for testing
Maven
Derby DB (in memory or file in ./target), JTA persistence context.
Embedded Glassfish in Arquillian
So I just want to do a simple JPA test. I get my Glassfish running in Arquillian, but when doing my JPA stuff, my app always fails to handle the Derby DB (tells me there are no tables etc.), but DDL files look sane.
I played around with providing schema name, user etc. in my persistence.xml, but nothing helps. Sometimes a come accross posts telling me about making changes in a minimal domain.xml for the embedded Glassfish to match my persistence.xml or to adapt the arquillian.xml.
My question is: for this minimal approach - do I really require that src/test/glassfish/domains/domain1/domain.xml or arquillian.xml?
I am quite sure that some time ago I managed to do so with Embedded Glassfish but using Hibernate 4 as JPA provider. I have no access to the project anylonger and thus cannot tell the difference except that I definetely did not add a domain.xml etc.
Posts like (other question here) really do confuse me.
Important is that I am not using a managed server, but an embedded one.
Thanks and cheers,
Timo
Here is one of my versions, please see my following comment.
<persistence-unit name="localiser-core" transaction-type="JTA">
<jta-data-source>jdbc/__default</jta-data-source>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
<property name="javax.persistence.jdbc.url"
value="jdbc:derby:memory:test;create=true" />
<property name="javax.persistence.jdbc.user" value="" />
<property name="javax.persistence.jdbc.password" value="" />
<property name="eclipselink.target-database" value="Derby"/>
<property name="eclipselink.ddl-generation.output-mode"
value="database" />
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.application-location" value="target" />
<property name="eclipselink.create-ddl-jdbc-file-name" value="create.sql"/>
<property name="eclipselink.drop-ddl-jdbc-file-name" value="drop.sql"/>
<property name="eclipselink.debug" value="ALL"/>
<property name="eclipselink.weaving" value="static"/>
<property name="eclipselink.logging.level" value="FINEST"/>
<property name="eclipselink.logging.level.sql" value="FINEST"/>
<property name="eclipselink.logging.level.cache" value="FINEST"/>
</properties>
</persistence-unit>
Since your connection URL is: jdbc:derby:memory:test;create=true, what you have told Derby is: connect to a database in the folder 'test', relative to the current working directory of wherever Derby is started, and if that database 'test' is not present in the current working directory, create it from scratch.
So one possibility is that your application has a different current working directory each time, or perhaps that something else in your application is clearing out your current working directory each time you run the application.
Thus Derby doesn't find the previous database in that location, and so it creates a fresh new one.
One way around this is to specify a more explicit location for your database, by using a connection URL such as: jdbc:derby:memory:/users/timo/testdb
Then create the database once, up front, and subsequent to that your application will find the database in the specified location and use it.

Add new workflow into Alfresco share

I'm new to Alfresco/Activiti.
Our company is using Skelta BPM.NET (in integration with our self developed RMS) and now we would like to take a look into other BPM software.
I last days I found our how to create new workflow using Eclipse and Import them into standalone installation of Activiti.
Now I would like to publish this workflow into Alfresco share. Is there any easy way to do that? I was searching whole day on Google but didn't find anything useful.
And another question about installation:
Is it possible to install Activiti with all it's webapps on the same tomcat, that alfresco is running on? That Apache Ant can build only standalone installation. So can this two application be merged?
Thanks for your info, Anze
If you place your BPMN 2.0 process definition XML somewhere in the Alfresco classpath, you can use Alfresco's workflow console to deploy the definition.
For example, I always place my workflows under WEB-INF/classes/alfresco/extension/workflows/someFolder where someFolder is a unique folder for each process definition I am using.
The workflow console is in http://localhost:8080/alfresco/faces/jsp/admin/workflow-console.jsp. Assuming you are using 3.4.e, which is a preview release showing Activiti integration, you can deploy a process through the workflow console with this command:
deploy activiti /alfresco/extension/workflows/activiti/activitiHelloWorld.activiti
You can see other helpful workflow console commands by typing help.
Alternatively, as Gagravarr suggests, you can use Spring to deploy your workflow when Alfresco starts up. The Spring config file must have a name ending with "-context.xml". I usually place mine in WEB-INF/classes/alfresco/extension.
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<bean id="someco.workflowBootstrap" parent="workflowDeployer">
<property name="workflowDefinitions">
<list>
<props>
<prop key="engineId">activiti</prop>
<prop key="location">alfresco/extension/workflows/activiti/activitiHelloWorld.bpmn20.xml</prop>
<prop key="mimetype">text/xml</prop>
<prop key="redeploy">false</prop>
</props>
</list>
</property>
<property name="models">
<list>
<value>alfresco/extension/model/scWorkflowModel.xml</value>
</list>
</property>
<property name="labels">
<list>
<value>alfresco.extension.messages.scWorkflow</value>
</list>
</property>
</bean>
</beans>
If you'd like working examples of some simple workflows, with the same workflows implemented for both jBPM and Activiti for easy comparison, take a look at this blog post: http://ecmarchitect.com/archives/2011/04/27/1357
Jeff
For the second part of your question:
If you want to use Alfresco with Activiti, then you should try the 3.4.e release (or a recently nightly build). 3.4.e has Activiti build in, so you don't need to do any merging of webapps. It's all already there for you.
For the first part, as long as you're using 3.4.e (or a later nightly build), then you ought to be able to deploy to Activiti in much the same way that you would previously deploy to JBMP. The Workflow With Activiti wiki page ought to help you with this too, as might this wiki too.

JPA Entity (in multiple persistence-unit) in OSGi (Spring DM) Environnement is confusing me

I'm a bit confused about a strange behavior of my JPA's related objects.
I have three bundle :
The User bundle does contain some user-related objects, but mainly the User object.
The Energy bundle does contain some energy-related objects, and particularly a ConsumptionTerminal which contains a List of User.
The Index bundle does contain an Index object that has no dependency at all.
My OSGi environment is the following :
A DataSource bundle that provide 2 services : dataSource and jpaVendorAdapter.
The three bundles. They consume dataSource and jpaVendorAdapter.
Their module-context.xml file look like :
And they all have a persistence.xml file :
User
<?xml version="1.0" encoding="UTF-8"?>
<persistence>
<persistence-unit name="securityPU" transaction-type="JTA">
<jta-data-source>java:/securityDataSourceService</jta-data-source>
<class>net.nextep.amundsen.security.domain.User</class>
<!-- [...] -->
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="eclipselink.logging.level" value="INFO" />
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
<property name="eclipselink.orm.throw.exceptions" value="true" />
</properties>
</persistence-unit>
</persistence>
Energy
<?xml version="1.0" encoding="UTF-8"?>
<persistence>
<persistence-unit name="energyPU" transaction-type="JTA">
<jta-data-source>java:/securityDataSourceService</jta-data-source>
<class>net.nextep.amundsen.security.domain.User</class>
<class>net.nextep.amundsen.energy.domain.User</class>
<!-- [...] -->
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="eclipselink.logging.level" value="INFO" />
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
<property name="eclipselink.orm.throw.exceptions" value="true" />
</properties>
</persistence-unit>
</persistence>
Index : This one has the most simple persistence.xml with just the Index class (no shared Class).
I'm using named #PersistenceUnit annotation like #PersitenceUnit(name = 'securityPU') (for the User bundle).
And finally, I'm using EclipseLink as Jpa provider and Spring DM (+ Spring DM Server in the development process)
The problem is the following :
When the User bundle is deployed, I'm able to persist User objects.
When the User bundle and Energy bundles are both deployed, I'm not able to persist User objects (neither the Energy object). But I don't have any exception at all !
There is no problem at all with the Index bundle.
The bug is dataSource independent (I tried with PostgreSQL and MySQL so far).
My first conclusion was that the <class>net.nextep.amundsen.security.domain.User</class> in both persistence unit was causing the trouble. I tried without it (and hiding the User dependent object in the Energy bundle) but it failed too.
I'm a bit confused about that bug. I'm also not quite sure about the transaction management in this context.
I wasn't the one who designed this architecture (but I tell my intern OK without testing it.. shame on me) but if I could understand this bug and maybe fix it without rewrite the bundle (and break my intern work), I would appreciate. Am I doing something wrong ? (it's obvious, but what..) Did I miss something while reading documentation ?
By the way, I'm also looking for some best practices or advices when it comes to JPA, EclipseLink (or whatever JPA Provider) and Spring DM (and OSGi in general). I found interesting slides from Mike Keith about this topic (by browsing Stackoverflow).
Ok, it seems stupid to answer my own question (because it's actually not an answer but a step to the understanding of the bug).
emphasized text
It might be related to load-time weaving. I'm not quite alright with this concept yet, so I'm going to learn about it..

Using hibernate tools to reverse engineer pojos from Postgres

I am trying to reverse engineer pojos (using hibernate tools plugin v3.2.4x in eclipse 3.4.2) from a database that I have created in Postgres but my tables are being ignored. It works if I specify 'public' as the value for the 'hibernate.default_schema' property in my hibernate.cfg.xml file but if I try to specify a different schema then nothing is generated.
I've tried modifying the case (i.e. lower, upper, camel) but I still get the same result. Here is my hibernate.cfg.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="MyFactory">
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.password">[mypassword]</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/testgis</property>
<property name="hibernate.connection.username">postgres</property>
<property name="hibernate.default_schema">locatimus</property>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
</session-factory>
</hibernate-configuration>
Here is a picture of my setup in pgAdmin III - http://twitpic.com/snj8i
I'm pretty sure that I'm doing (or missing) something easy. As I say, if I change the schema to public then pojos from all tables in that schema are generated!
Can anyone help?
Many thanks,
Damian
OK, I found the problem. It seems that the table names must be in lowercase or hibernate tools does not see them. I don't know if this is a bug with the PostgresSQL dialect or Hibernate itself.
Does the postgres user have permission to the tables in the locatimus schema ?