WebLogic 10.3 JPA 1.0 Missing descriptor for class - stored-procedures

I'm using WebLogic 10.3 with JPA 1.0.
The entity class is:
#Entity
public class ZoneAgency implements Serializable {
public ZoneAgency() {
super();
}
#Id
#Column(name = "zoneid", nullable = false)
private Integer zoneId;
#Id
#Column(name = "agencyid", nullable = false)
private Integer agencyId;
}
It is also added in persistence.xml:
<?xml version="1.0" encoding="windows-1252" ?>
<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_1_0.xsd"
version="1.0">
<persistence-unit name="smthModel">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/smthDS</jta-data-source>
<class>smth.model.entities.ZoneAgency</class>
<properties>
<property name="eclipselink.target-server" value="WebLogic_10"/>
<property name="javax.persistence.jtaDataSource" value="jdbc/smthDS"/>
<property name="eclipselink.cache.shared.default" value="false"/>
</properties>
</persistence-unit>
</persistence>
I use this class in the following invocation:
Query query = entityManager.createNativeQuery("call get_zone_agency_by_channel_type_rr(?,?)", ZoneAgency.class);
where get_zone_agency_by_channel_type_rr is a stored procedure that returns the result of this select:
select t_zone_id as zoneid, t_agency_id as agencyid;
This entity class is wrapped inside a jar file that is used as a dependency in a web application (war file). This war is wrapped inside an ear file and deployed on WebLogic.
The problem is that
when I install/update the deployment, the entityManager.createNativeQuery invocation works fine;
when I stop the Web application and then restart it, I get the following error:
Exception Description: Missing descriptor for [class smth.model.entities.ZoneAgency].
Query: ReadAllQuery(referenceClass=ZoneAgency sql="call get_zone_agency_by_channel_type_rr(?,?)")
What could the problem be?

It seems to be a class loader issue. My guess is that the old persistence unit with the old classes are still deployed in the server.
When you use a container managed (injected/jta) persistence unit the server take care of undeploying it.
When you use an application managed persistence unit (Persistence.createEntityManagerFactory()), then you must ensure you close it before redeploying a live server. Otherwise it will remain deployed.

Related

Custom configuration not getting reflected in applicationcontext.xml

I am using custom configuration for my RabbitMQ connectivity. I'm connecting to multiple hosts.
<context:property-placeholder location="classpath:/test_setting.properties" ignore-unresolvable="true"/>
...
<rabbit:connection-factory id="testConnectionFactory"
addresses="${test.addresses}"
username="${test.username}"
password="${test.password}"
virtual-host="${test.virtualhost}"
connection-factory="rhb" />
<bean id="rhb" class="com.rabbitmq.client.ConnectionFactory">
<property name="requestedHeartbeat" value="${test.connection.heartbeat}" />
</bean>
My property file looks like: test_setting.properties
test.queue=testQueue
test.virtualhost=/global_api
test.addresses=host1:5672,
host2:5672
test.username=guest
test.password=guest
test.connection.heartbeat=60
test.consumer.concurrency=1
When i trigger my main class properties not getting replaced inside applicationcontext.xml in Spring. Thereby I am getting connection refused exception.
Please note if I hard code the connection details everything works fine.
ignore-unresolvable="true"
It looks like the file is not being found - change that to false to see the error.
Also, turning on DEBUG logging for org.springframework will provide a great deal of information about property resolution.
test.addresses=host1:5672,
host2:5672
Properties have to be on one line (you can terminate a line with \) for continuation.
test.addresses=host1:5672, \
host2:5672

Embedded Neo4j 2.1.6 fails to start in OSGi environment

We're running a modular application plattform using Apache ServiceMix 5.3.0. I need to extend our system with a persistence service - so I want to build an OSGi bundle containing Neo4J 2.1.6.
In my pom.xml (Maven) I'm using maven-bundle-plugin (org.apache.felix) to build the bundle. I've added nearly every package from neo4j-kernel and neo4j-lucene-index libs to the <Export-Package> section.
When deployed my bundle shows up in "resolved" state. But when beeing started it throws this:
org.osgi.framework.BundleException: Activator start error ...
...
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at org.neo4j.graphdb.factory.GraphDatabaseSettings.<clinit (GraphDatabaseSettings.java:69)
My activator code looks like this (the exception occurs at the last command):
GraphDatabaseFactory factory = new GraphDatabaseFactory();
/*
ArrayList<CacheProvider> caches = new ArrayList();
caches.add(new SoftCacheProvider());
factory.setCacheProviders(caches);
*/
GraphDatabaseBuilder builder = factory.newEmbeddedDatabaseBuilder("neo4j-db");
graphDb = builder.newGraphDatabase();
(It doesn't make a difference if the commented part is active or not.)
The error pattern looks similar like the one in this question.
I suspect the devil sitting in the following method from org.neo4j.graphdb.factory.GraphDatabaseSettings (line 259f) unable to find any CacheProvider instances, although they are packed and referenced in my bundle (org.neo4j.kernel.impl.cache...):
private static String[] availableCaches()
{
List<String> available = new ArrayList<>();
for ( CacheProvider cacheProvider : Service.load( CacheProvider.class ) )
{
available.add( cacheProvider.getName() );
}
...
return available.toArray( new String[available.size()] );
}
I believe this is very much an OSGi classloader issue rather than a Neo4J issue. Any ideas how to proceed here?
I managed to solve my problem meanwhile. As Neil already supposed, it was neither an OSGi-issue nor a Neo4J-bug. Instead I had to learn some more lessons about how Neo4J binds its extensions and how to shape OSGi dependencies accordingly in order to get ahead.
These are the results of my yesterday's research:
(1) Collect all packages
My mistake was to rely on maven-bundle-plugin's capability to parse the project and automatically break down all internal dependencies to package level (which is neccessary for OSGi). This works perfectly for class relations that are declared by import statements, but, of course, will fail where reflection methods are used to bind external stuff.
As the application worked perfectly in my JUnit environment the reasons for my problem had to include missing resources in the OSGi envirmonment.
The solution was to religiously list each single package of every library in the plugins Export-Package, Private-Package and Import-Package section accordingly (the list got quite lengthly) instead of trusting to wildcards.
(2) Neo4J kernel extensions
Heeding the above topics I got rid of the mentioned ArrayIndexOutOfBoundsException but I right ran into other (similar) exceptions. I got ahead after I learned about Neo4J's "kernel extension" concept.
Neo4J (I have version 2.1.6) has introduced "kernel extensions" to couple exchangeable modules for caching and indexing purpose at runtime. In order to apply a certain extension one just needs to add the according jar to the classpath. Each library carries one or more descriptor files under META-INF/services telling about the available implementations. These files are looked up and processed by the kernel in order to find and bind its extensions (extension for indexing and caching are mandatory).
After I securely had all neccessary java packages included in my bundly only the descriptor files in META-INF/services were missing. This code showed me a way how to add those resources to the bundle (search for the <Embed-Dependency> section in the maven-bundle-plugin.
Neo4J libs also contain a blueprint descriptor to automatically publish major classes as service (e.g. GraphDatabaseFactory). These resources are placed under OSGI-INF/blueprint/, which should also be included in the bundle.
The final pom.xml for my Neo4J OSGi bundle looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>my.group</groupId>
<artifactId>neo4jBundle</artifactId>
<version>0.1.0</version>
<packaging>bundle</packaging>
<properties>
<neo4j-version>2.1.6</neo4j-version>
<lucene-version>3.6.2</lucene-version>
</properties>
<dependencies>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-kernel</artifactId>
<version>${neo4j-version}</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-lucene-index</artifactId>
<version>${neo4j-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Name>org.neo4j.kernel</Bundle-Name>
<Export-Package>org.neo4j.graphdb.*;version=${neo4j-version},
... {all neo4j packages} ...
org.apache.lucene;version=${lucene-version},
... {all lucene packages} ...
org.slf4j.impl
</Export-Package>
<Private-Package>
javax.transaction,
javax.transaction.xa,
ch.qos.logback.classic,
... {all logback.classic packages} ...
ch.qos.logback.core,
... {all logback.core packages} ...
org.slf4j.*
</Private-Package>
<Import-Package>
javax.lang.model,
... {some javax packages to be imported from the runtime} ...
!sun.misc,
... {exclude uneccessary packages to limit dependency} ...
*
</Import-Package>
<Embed-Dependency>
*;groupId=org.neo4j;artifactId=neo4j-kernel;inline=META-INF/services/*,
*;groupId=org.neo4j;artifactId=neo4j-kernel;inline=OSGI-INF/blueprint/*,
*;groupId=org.neo4j;artifactId=neo4j-lucene-index;inline=META-INF/services/*,
*;groupId=org.neo4j;artifactId=neo4j-lucene-index;inline=OSGI-INF/blueprint/*
</Embed-Dependency>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
Remarks: This is a pure library bundle without any additional code. My application with the Activator resides in a seperate bundle.
This example only shows my aproach in solving my problems. My example doesn't claim to produce a general-purpose Neo4J bundle. Depending on the features you want and the society of already deployed stuff in the runtime you might need to add or leave out certain packages to get everything to work.

Simple Dropwizard 0.7.1 App Failing over Optional QueryParam w/ Java 8

I decided to return to Dropwizard after a very long affair with Spring. I quickly got the absolute barebones REST service built, and it runs without any problems.
Using Dropwizard 0.7.1 and Java 1.8, only POM entries are the dropwizard-core dependency and the maven compiler plugin to enforce Java 1.8, as recommended by the Dropwizard user manual
However, as soon as I try to add an Optional QueryParam to the basic controller, the application fails to start with the following error (cut for brevity):
INFO [2015-01-03 17:44:58,059] io.dropwizard.jersey.DropwizardResourceConfig: The following paths were found for the configured resources:
GET / (edge.dw.sample.controllers.IndexController)
ERROR [2015-01-03 17:44:58,158] com.sun.jersey.spi.inject.Errors: The following errors and warnings have been detected with resource and/or provider classes:
SEVERE: Missing dependency for method public java.lang.String edge.dw.sample.controllers.IndexController.index(java.util.Optional) at parameter at index 0
Exception in thread "main" javax.servlet.ServletException: com.sun.jersey.spi.container.servlet.ServletContainer-6c2ed0cd#330103b7==com.sun.jersey.spi.container.servlet.ServletContainer,1,false
The code for the controller is as follows:
#Path("/")
public class IndexController {
#GET
#Timed
public String index(#QueryParam("name") Optional<String> name) {
String saying = "Hi";
if(name != null && name.isPresent()) {
saying += " " + name.get();
}
return saying;
}
}
If I remove Optional from the mix, the application runs just fine. I replace the Optional-specific code with null checks and it works perfectly.
Am I missing something fundamental here? Both Google Guava Optional and java.util.Optional fail with the same error. (And yes, I did narrow it down to the Optional object)
A quick Google/SO search yielded nothing useful, but feel free to point me to a resource I may have missed
Thanks in advance!
Moments after posting this, I found that the issue was my use of Java 1.8. If using Java 1.8, I have to add the Java8Bundle to my app:
POM Entry:
<dependency>
<groupId>io.dropwizard.modules</groupId>
<artifactId>dropwizard-java8</artifactId>
<version>0.7.0-1</version>
</dependency>
And code in the Application class:
#Override
public void initialize(Bootstrap<SampleConfiguration> bootstrap) {
bootstrap.addBundle(new Java8Bundle());
}
See: https://github.com/dropwizard/dropwizard-java8
This enables both Google Guava Optional and java.util.Optional to work just fine.
If I revert to Java 1.7 and use the Google Guava Optional, it works just fine as well and I don't have to include the Java8Bundle. I'll opt for the Java8Bundle for now, though, as using Java8 features is lucrative for me :)
Cheers!

How to use Entity Framework + PostgreSQL from connection?

I have already seen threads discussing the use of Entity Framework and PostgreSQL with official instructions. Those instructions need to run gacutil for every install which is not so handy for deployment purposes.
What I want to do here is passing PostgreSQL connection directly to the DbContext constructor. This is enough for me because I am going to use CodeFirst without designer. This is what I do:
public class Context : DbContext
{
Context(System.Data.Common.DbConnection connection)
: base(connection, true)
{
}
public static Context CreateContext()
{
NpgsqlConnection conn = new NpgsqlConnection("Server=127.0.0.1;Port=5432;User Id=postgres;Password=********;Database=xxx;");
conn.Open();
return new Context(conn);
}
}
But using this method I get a NotSupportedException with message:
Unable to determine the provider name for connection of type
'Npgsql.NpgsqlConnection'.
What should I do?
You'll need to register the Npgsql provider in the app/web.config. See section 3.4 Using Npgsql with ProviderFactory of the Npgsql manual.
When you install an ADO.NET provider for databases (MySQL, PostgreSQL, etc.) the installers will usually register the provider assembly in the GAC and add an entry to the machine.config. If you want to deploy without having to install the provider you'll need to include a copy of the provider assembly (set Npgsql assembly reference as Copy Local for your project) and add an entry to your application's app/web.config as follows:
<configuration>
...
<system.data>
<DbProviderFactories>
<clear />
<add name="Npgsql Data Provider" invariant="Npgsql" support="FF" description=".Net Framework Data Provider for Postgresql Server" type="Npgsql.NpgsqlFactory, Npgsql, Version=2.0.1.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" />
</DbProviderFactories>
</system.data>
...
</configuraiton>
Make sure the version matches exactly the version of the Npgsql assembly you deploy with (or just omit the Version/Culture/PublicKeyToken). The <Clear /> is there to avoid conflicts if running on a machine that already has entry for Npgsql in its machine.config. Without the clear you would get an exception. However, that's also assuming you're not relying on any other providers specified in the machine.config for your application.

Using Grails 1.3.7 with EclipseLink 2.2.0 JPA Provider

I try to use Grails 1.3.7 with plugin gorm-jpa 0.7.1 to enable JPA persistence using EclipseLink 2.2.0 as a persistence provider.
When running the app and clicking on the controller of a JPA annotated entity I get an "UnwantedTokenException" from JPQLParser of EclipseLink:
Executing action [list] of controller [model.PersonController] caused exception:
An exception occurred while creating a query in EntityManager:
Exception Description: Syntax error parsing the query [select person from model.Person as person ], line 1, column 24: syntax error at [.].
Internal Exception: UnwantedTokenException(found=., expected 80);
at org.eclipse.persistence.internal.libraries.antlr.runtime.BaseRecognizer.recoverFromMismatchedToken(BaseRecognizer.java:587)
[...]
at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.parse(JPQLParser.java:134)
It seems that EclipseLink has a problem with the dot in "model.Person".
How to solve this issue?
To reproduce the issue setup a grails project as follows:
grails create-app GrailsJPA
cd GrailsJPA
grails uninstall-plugin hibernate
grails install-plugin gorm-jpa
grails create-domain-class model.Person
Edit "grails-app\domain\model\Person.groovy" as follows:
package model
import javax.persistence.*;
#Entity
class Person {
#Id
#GeneratedValue
long id;
#Basic
long version;
#Basic
String firstName
#Basic
String lastName
static constraints = {
firstName(nullable:true)
lastName(nullable:true)
}
}
Generate controller and view for the defined entity:
grails generate-controller model.Person
grails generate-view model.Person
Edit "grails-app\conf\spring\resources.groovy" as follows:
beans = {
entityManagerFactory(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean) {
beanClassLoader = ref("classLoader")
dataSource = ref("dataSource")
loadTimeWeaver = new org.springframework.instrument.classloading.SimpleLoadTimeWeaver()
}
transactionManager(org.springframework.orm.jpa.JpaTransactionManager) {
entityManagerFactory = entityManagerFactory
}
}
Create a file "web-app\WEB-INF\classes\META-INF\persistence.xml" as follows:
<?xml version="1.0" encoding="UTF-8"?>
<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_1_0.xsd" version="1.0">
<persistence-unit name="manager" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>model.Person</class>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>
Download EclipseLink 2.2.0 installer ZIP from http://www.eclipse.org/eclipselink/downloads/2.2.0 and extract "eclipselink.jar" from "eclipselink\jlib\" in ZIP to grails project dir:
lib\eclipselink.jar
Now run the grails application:
grails run-app
Browse to
http://localhost:8080/GrailsJPA
Now click on controller "model.PersonController" to reproduce the above exception.
Any ideas on how to resolve this issue?
I managed to get EclipseLink 2.3.0 JPA provider to work with domain classes that are not inside a package in the following way.
In the following I will show how to setup a grails application that is using EclipseLink as a JPA provider to persist domain classes and run the application in a Tomcat 6 web container.
Start by
creating a new grails project
uninstall the default hibernate plugin
install the gorm-jpa plugin which enables gorm-like behaviour on top of JPA
create a new domain class "Person" for testing
grails create-app GrailsJPA
cd GrailsJPA
grails uninstall-plugin hibernate
grails install-plugin gorm-jpa
grails create-domain-class Person
Hint: Do not put domain classes in packages. EclipseLink will fail when processing e.g. "model.Person" because of the dot in the name, but will do fine with e.g. "Person" (compare to above post).
Edit "grails-app\domain\Person.groovy" as follows:
import javax.persistence.*;
#Entity
class Person {
#Id
#GeneratedValue
long id;
#Basic
long version;
#Basic
String firstName
#Basic
String lastName
static constraints = {
firstName(nullable:true)
lastName(nullable:true)
}
}
Generate a controller and a view for the defined entity:
grails generate-controller Person
grails generate-view Person
Now we need to modify the generated controller slightly, so that all actions modifying the entity (save, edit, update, delete) are encapsulated in a transaction (compare to bug GPGORMJPA-6). This is done by encapsulating the whole action into a "Person.withTransaction" block.
Edit "grails-app\controllers\PersonController.groovy" as follows:
[...]
def save = {
Person.withTransaction {
[...original code stays in this block...]
}
}
[...]
def edit = {
Person.withTransaction {
[...original code stays in this block...] }
}
}
def update = {
Person.withTransaction {
[...original code stays in this block...]
}
}
def delete = {
Person.withTransaction {
[...original code stays in this block...]
}
}
[...]
Now we define a persitence unit "manager" that specifies a set of classes to manage persistence for (class "Person") and which JPA provider to use for these classes (in our case EclipseLink).
Create a file "web-app\WEB-INF\classes\META-INF\persistence.xml" as follows:
<?xml version="1.0" encoding="UTF-8"?>
<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_1_0.xsd" version="1.0">
<persistence-unit name="manager" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>Person</class>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>
Please note: The file will be deleted if "target" dir of project is cleaned, e.g. when "grails clean" is called explicitly. So it's a good idea to make a backup of the file outside of the "target" dir.
To make EclipseLink available to the grails project, download EclipseLink 2.3.0 installer ZIP and extract "eclipselink.jar" from "eclipselink\jlib\" in ZIP to "lib" folder of grails project:
lib\eclipselink.jar
Now we need to make sure, that an "entityManagerFactory" and "transactionManager" bean are created when the web application is started. The beans will provide the needed access to the JPA provider that will manage all the persistency.
Edit "grails-app\conf\spring\resources.groovy" as follows:
beans = {
entityManagerFactory(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean) {
dataSource = ref("dataSource")
beanClassLoader = ref("classLoader")
loadTimeWeaver = new org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver()
}
transactionManager(org.springframework.orm.jpa.JpaTransactionManager) {
entityManagerFactory = entityManagerFactory
}
}
Please note that we specified a special loadTimeWeaver in the above declarations, that enables the JPA persistence provider to hook into java bytecode on the fly during runtime. When using EclipseLink this is essential. If just using org.springframework.instrument.classloading.SimpleLoadTimeWeaver for testing purposes, this enables the web app to start, but when accessing JPA entities you will encounter exceptions like "0 is not a known entity type", as the persistence provider is unable to hook into the management of the entity classes at runtime.
The use of InstrumentationLoadTimeWeaver is a bit of a hassle, as it will only work, if
the java virtual machine executing the web app server is started using "spring-agent" java agent, AND
our web app is loaded by the Tomcat server using a special classloader named "TomcatInstrumentableClassLoader"
To achieve this, first download spring-agent-2.5.6.SEC02.jar and spring-instrument-tomcat-3.0.5.RELEASE.jar.
Assume that you have installed Tomcat server in directory %CATALINA_HOME%.
Copy the downloaded jar files "spring-agent-2.5.6.SEC02.jar" and "spring-instrument-tomcat-3.0.5.RELEASE.jar" to %CATALINA_HOME%\lib
Now we modify "%CATALINA_HOME%\bin\catalina.bat" that is used by e.g. the start and stop scripts of Tomcat to make sure the JVM executing Tomcat runs with the "spring-agent" java agent.
Add the following to "%CATALINA_HOME%\bin\catalina.bat" in section "Execute The Requested Command" after all the echos:
if exist "%CATALINA_HOME%\lib\spring-agent-2.5.6.SEC02.jar" set JAVA_OPTS=%JAVA_OPTS% -javaagent:%CATALINA_HOME%\lib\spring-agent-2.5.6.SEC02.jar
When Tomcat is started, the script will now check if "spring-agent-2.5.6.SEC02.jar" is in the lib dir, and if this is the case, it will add it as the java agent to the JAVA_OPTS that are used as command line parameters to the JVM when starting Tomcat.
To enable the "TomcatInstrumentableClassLoader" as class loader for our web application we add the file "web-app\META-INF\context.xml" to our grails project, with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"/>
</Context>
Please note that the tags in "context.xml" are case sensitive. So do not try to change <Context> to <context> (or similar things) - this will fail!
Before we package and deploy our web application, we define which datasource to use for persistency. For testing, we just define a HSQLDB in-memeory database.
Edit "grails-app\conf\DataSource.groovy" as follows:
[...]
development {
dataSource {
dbCreate = "create-drop"
url = "jdbc:hsqldb:mem:testDB"
}
}
test {
dataSource {
dbCreate = "create-drop"
url = "jdbc:hsqldb:mem:testDb"
}
}
production {
dataSource {
dbCreate = "create-drop"
url = "jdbc:hsqldb:mem:testDB"
}
}
[...]
Now we are ready to create a WAR archive of our web app using:
grails war
The WAR will be placed in the "target" directory of our project.
In "%CATALINA_HOME%\webapps"
create a directory "GrailsJPA"
extract all contents of the created WAR archive into this directory
Please note: Do not place WAR in "%CATALINA_HOME%\webapps" and hope that it is deployed on startup of Tomcat. This will fail!
Now start the Tomcat server using script
"%CATALINA_HOME%\bin\startup.bat"
After Tomcat is up and running, use your browser to browse to
http://localhost:8080/GrailsJPA
Now click on controller "PersonController" to create, update, list and delete Person entities via JPA using EclipseLink JPA provider.
But using domain classes that are inside of a package will still fail with the exception mentioned in the above post. This issue is still unresolved.
Download links
Grails 1.3.7
http://grails.org/Download
EclipseLink 2.3.0
http://www.eclipse.org/eclipselink/downloads/2.3.0
Tomcat 6
http://tomcat.apache.org/download-60.cgi
spring-instrument-tomcat-3.0.5.RELEASE.jar
http://mvnrepository.com/artifact/org.springframework/spring-instrument-tomcat
spring-agent-2.5.6.SEC02.jar
http://mvnrepository.com/artifact/org.springframework/spring-agent

Resources