I am trying to run the jbpm6 sample web application "rewards-basic" in my local. But it seems two datasources files are missing.
<persistence-unit name="org.jbpm.examples.rewards-basic" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
<mapping-file>META-INF/**JBPMorm.xml**</mapping-file>
<mapping-file>META-INF/**Taskorm.xml**</mapping-file>
What for JBPMorm.xml and Taskorm.xml files ? How to recreate these files here ?
Thanks,
those files are in jbpm-human-task-jpa -> https://github.com/droolsjbpm/jbpm/blob/master/jbpm-human-task/jbpm-human-task-jpa/src/main/resources/META-INF/Taskorm.xml
and
in jbpm-persistence-jpa:
https://github.com/droolsjbpm/jbpm/blob/master/jbpm-persistence-jpa/src/main/resources/META-INF/JBPMorm.xml
Notice that both files are in the main/src/resources directory so they should be included if you have jbpm-persistence-jpa.jar and jbpm-human-task-jpa in your class path.
HTH
Related
I recently completed this tutorial: "http://static.springsource.org/docs/Spring-MVC-step-by-step/", but now I want it to work with Hibernate and annotations. I know I'm close but I've hit a roadblock and I can't figure it out. I've posted my code on the Spring forums here. I would greatly appreciate ANY help. Thanks
I'm trying to incorporate annotations and hibernate into it, but I've run into a problem and I can't figure it out. I keep getting errors of "No persistence unit with name 'product' found". ANY help would be greatly appreciated.
You need a META-INF/persistence.xml, with <persistence-unit name="product">. See here
(I usually put it in WEB-INF/classes/META-INF. As noted in the comments, with maven you can place it in src/main/resources/META-INF)
this is a example of file persistence.xml
<persistence 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"
version="2.0">
<persistence-unit name="poduct" transaction-type="RESOURCE_LOCAL">
</persistence-unit>
</persistence>
create this file inside "src/main/resources/META-INF" if you use Maven project.
I run onto the same problem and had to manually edit the Web Deployment Assembly Configuration so as to instruct /META-INF/persistence.xml to be deployed under WEB-INF/classes/ (the red box in the attached img was manually edited)
i have the same problem. But when you use the ide(for example eclipse) and configure your server in the ide. When you asosiate the piece and restart the server always have the same error because detected the persistence unit is used, you need delete that part of the server and deploy to the oldway. Enter to the console and install the peace of you project and works!!
And the other is when you check the diagnostic in wls you need said who user is the owner of the jdbc, only select and check (for example, AdminServer) and save and check again!!
:D
I have a Netbeans project, from which I build a .war file. I now deploy two instances of that war file on my glassfish server, each with a different context root, e.g. mydomain.com/abc and mydomain.com/def
This works fine but they are still operating on the same database, since I declare the persistence unit in the persistence.xml and the glassfish-resources.xml.
My glassfish-resources.xml file:
...
<jdbc-resource enabled="true"
jndi-name="jdbc/abc"
object-type="user"
pool-name="abcPool">
<description/>
</jdbc-resource>
<jdbc-connection-pool
...
name="abcPool"
...
<property name="URL" value="jdbc:mysql://localhost:3306/abc"/>
...
</jdbc-connection-pool>
My persistence.xml file:
...
<persistence-unit name="abcPU" transaction-type="JTA">
<jta-data-source>jdbc/abc</jta-data-source>
...
</persistence-unit>
...
Does anybody have a solution on how to have two instances of one war file, operating on two different databases?
Is there maybe a way to upload a different glassfish-resources.xml and persistence.xml to each application, overwriting the packaged one?
It would be acceptable to change the module descriptors in the glassfish domain admin console once the application is deployed, if that is possible.
If screenshots from the glassfish domain admin console are needed, please write in the comments, I will add them.
Thank you in advance!
Easiest approach in my opinion would be to have two different builds.
Basically you may create two different .war files. Each one with a different persistence.xml file in it. One pointing to the JDBC resource ABC and the other one pointing to the JDBS resource DEF.
Build tools like gradle+Jenkins may support you with this.
You will find lots of information about similar tasks, if you search for how to create builds with a different configuration for testing vs. productive system. This is a very common task.
Here might be a starting point for what you are looking for:
Create multiple .WAR files with different dependencies in Gradle
At server level setup two Data sources pointing to different databases and go to the application instance and modify Resource reference pointing specific data source.
This used to work fine:
<?xml version="1.0" encoding="UTF-8"?>
<web-bnd xmlns="http://websphere.ibm.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-bnd_1_0.xsd" version="1.0">
<virtual-host name="default_host" />
</web-bnd>
And at deploy-time it still does but Eclipse's validator keeps show annoying "errors" because http://websphere.ibm.com/xml/ns/javaee does not point to a valid site anymore (redirects to some search site),when trying to download the schemas.
I know that probably I'll just have to turn off validation for these files, but let me try asking first:
Is there a new home for those schemas?
Or somewhere to alert IBM that they are failing miserably on that regard...?
Install WebSphere Developer Tools via Eclipse Marketplace. It will add required schema to the XML Catalog in the Eclipse. You can check if you have them via Preferences > XML > XML catalog. These schemas are in one of the jars from plugin (the exact filename can be different depending on tools version)
Location: schemas\ibm-web-bnd_1_0.xsd in jar file C:\eclipse\plugins\com.ibm.jee.was.descriptors.schemas_1.1.100.v20141119_2034.jar.
For Websphere Application Server:
You can find all the schemas here...
WAS_INSTALL_ROOT/properties/schemas
I'm struggling with NetBeans and failing to make a project (Vaadin -> Maven-based) that connects to an SQLite database. For some reason every time I run my project:
NetBeans starts an Apache Derby database
JPA doesn't generate tables in my SQLite table (probably since I never manage to connect to it)
I have done the following:
"Install" the SQLite JDBC driver - downloaded the jar, went to Services -> Database and created a new connection pointing at the jar. I've named it SQLite 3.8.11.2. It has been successfully added and listed under Databases -> Drivers.
Adding a connection to the database - the database is created using the command line tool and is located inside the root directory of the NetBeans Maven project. Currently it is empty since I want to use JPA to generate my tables from the respective entity classes. I added the connection and it points to the cookbook.sqlite file. In order to check if things are working at this stage I created a small table using NetBeans' user interface, added a bunch of stuff and then using the terminal checked if the database file has changed and what it contains. No problems here.
Resolve Maven dependecies - to the <dependencies/> inside the pom.xml of my project I added:
<dependencies>
<!-- various other dependencies mostly related to Vaadin -->
...
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.5.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
<version>2.5.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
Created a persistence unit - I have 3 entity classes - User, Ingredient and Recipe. The generated persistence.xml contains:
<?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="CookbookPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<non-jta-data-source>cookbook_db</non-jta-data-source>
<class>com.ava.cookbook.models.User</class>
<class>com.ava.cookbook.models.Ingredient</class>
<class>com.ava.cookbook.models.Recipe</class>
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
<properties>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
<property name="javax.persistence.jdbc.driver" value="org.sqlite.JDBC"/>
<property name="javax.persistence.jdbc.url" value="jdbc:sqlite:/PATH_TO_PROJECT_ROOT/cookbook_db.sqlite"/>
<property name="javax.persistence.jdbc.user" value="cookbook"/>
<property name="javax.persistence.jdbc.password" value="cookbook"/>
<property name="eclipselink.logging.level" value="FINEST"/>
</properties>
</persistence-unit>
</persistence>
Note that the schema generation is set to drop-and-create.
Basically these are my settings. When I try to run the project in the output window four new tabs appear:
Run (Cookbook) - this one tells me information about the state of the running project (since I haven't started actually accessing the database (which I cannot connect to :3) it runs perfectly fine)
GlassFish Server 4.1 - information about the GlassFish server that the project is running on
Browser Log - I'm using the NetBeans connector and while running the Vaadin project inside Google Chrome this tab displays a bunch of Vaadin-related events
Java DB Database Process - this one is the bummer in all this. In detail the messages here are:
Fri Oct 09 15:02:47 CEST 2015 : Security manager installed using the Basic server security policy.
Fri Oct 09 15:02:48 CEST 2015 : Apache Derby Network Server - 10.11.1.2 - (1629631) started and ready to accept connections on port 1527
Before I saw that I was thinking that I've screwed things up with the whole JPA-Entity-thing but after I noticed the second message in particular it became obvious that the project not connecting to the SQLite database but running it's own Derby DB.
I have barely any experience with Maven, EclipseLink, JPA and NetBeans so it is quite possible I'm overlooking something. Some advice or even a solution would be much appreciated.
If the connection is already setup incorrectly.
Use the Netbeans Menu : Windows -> Services to show the services tab.
Expand Servers
Expand GlassFish Server
Expand Resources
Expand JDBC
Expand JDBC Resources
Select your resource name.
Right-click for properties. Note the Pool Name
Expand Connection Pools
Select the Pool you just noted.
Right-click for properties.
Edit properties to use sqlite instead of derby. URL should be jdbc:sqlite:<path to cookbook.sqlite>
If you haven't setup the resource.
Select your project.
Right-click for New -> Other
In the Dialog select Category = Glassfish, File Type = JDBC Resource
Select Create New JDBC Connection Pool.
Change the name to your resources name
Click Next Twice
Set the Connection Pool name to something that you can remember.
Set the Data Source CLass Name to anything you want.
Set the Resource Type javax.sql.ConnectiPoolDataSource
Click Next
Check the settings on the last screen of the dialog and then click Finish.
To create classes mapped to tables:
Select your project.
Right-click for New -> Other
In the Dialog select Category = Persistance, File Type = Entity Class
Change Class name and Package Name
There are some tutorials that would probably be worth while to quickly work through even though they also cover some irrelevant material they are not that long.
Getting Started with Java EE Applications
Creating a Simple Web Application Using a MySQL Database
and/or
Take a look at the sample, at File > New Project > Samples > Java EE > Web JPA
During EJB project creation in eclipse, it created following projects
MyEjbProj
MyEjbProjClient
MyEjbProjEAR
The interfaces and implementations are created in 'MyEjbProj'. The MyEjbProjClient suppose to have interfaces which can be shared to the clients. How to generate/retrieve the jar which can be given to the Clients to use the interfaces.
It should be creating interface in client project only. I have same setup and Eclipse does create interfaces in client project for me. Problem should be either with your facets settings or with module settings. Check following things:
Are you selecting EAR and Client project option while creating EJB project.
If answer of above question is yes, then check if client and EJB project are shown in deployment assembly settings of EAR.
Check if client project have correct facets settings. It must have Java and Utility 2.0 facets.
Check if ejb-jar.xml file contains an entry specific to client project. See in following example I have tag with name of client project:
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd" version="3.1">
<display-name>TestEJB </display-name>
<ejb-client-jar>TestEJBClient.jar</ejb-client-jar>