fcoutel | 17 Feb 00:04 2014

Embedded database and schema fails to be created, Glassfish 4.0

Hi!

I am trying to deploy a app using Maven 3.5 and glassfish 4.0 which creates
an embedded derby database and schema on first start of the app. If I use a
local derby server instead, the database and schema is created OK.

However, when I try to deploy it using embedded method it fails; Maven says
that the app is succesfully deployed but when I access my app on the web and
the code to create the database is called I get the java exception below.
Can someone please advise what's wrong?

Also I have added the contents of persistence.xml and
glassfish-resources.xml below.

Feb 14, 2014 3:34:56 PM org.glassfish.jersey.server.ApplicationHandler
initialize
INFO: Initiating Jersey application, version Jersey: 2.0 2013-05-03
14:50:15...
Feb 14, 2014 3:34:56 PM org.glassfish.jersey.gf.ejb.EjbComponentProvider
registerEjbInterceptor
INFO: The Jersey EJB interceptor is bound. JAX-RS EJB integration support is
enabled.
Feb 14, 2014 3:34:56 PM com.sun.ejb.containers.BaseContainer postInvoke
WARNING: EJB5184:A system exception occurred during an invocation on EJB
ClientEventRepository, method: public void
com.dassault.geovia.common.AbstractReposito
y.create(java.lang.Object)
Feb 14, 2014 3:34:56 PM com.sun.ejb.containers.BaseContainer postInvoke
WARNING:
javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean
(Continue reading)

Bergquist, Brett | 15 Feb 18:57 2014

Question on why this is causing a deadlock

Here is the output from the deadlock:

Fri Feb 14 16:33:55 EST 2014 Thread[DRDAConnThread_26,5,main] (XID = 879610), (SESSIONID = 28952), (DATABASE = csemdb), (DRDAID = NF000001.F677-578992634681601532{719}), Failed Statement is: UPDATE CORE_V1.PROXY_NID_CLIENT_STATUS SET CONNECTION_STATE_DATE = ?, OPLOCK = ? WHERE ((ID = ?) AND (OPLOCK = ?)) with 4 parameters begin parameter #1: 2014-02-14 16:33:35.667 :end parameter begin parameter #2: 10607 :end parameter begin parameter #3: 2 :end parameter begin parameter #4: 10606 :end parameter 
ERROR 40001: A lock could not be obtained due to a deadlock, cycle of locks and waiters is:
Lock : ROW, PROXY_NID_CLIENT_STATUS, (1,7)
  Waiting XID : {879610, X} , CSEM, UPDATE CORE_V1.PROXY_NID_CLIENT_STATUS SET CONNECTION_STATE_DATE = ?, OPLOCK = ? WHERE ((ID = ?) AND (OPLOCK = ?))
  Granted XID : {879611, S} 
Lock : ROW, PROXY_NID_STATUS, (1,8)
  Waiting XID : {879611, S} , CSEM, SELECT COUNT(*) FROM CORE_V1.PROXY_NID_CLIENT PNC JOIN CORE_V1.PROXY_NID_CLIENT_STATUS PNCS ON PNC.STATUS_ID = PNCS.ID JOIN CORE_V1.PROXYNID_PROXYNIDCLIENT PNPNC ON PNC.ID = PNPNC.PROXYNIDCLIENT_ID JOIN CORE_V1.PROXY_NID PN ON PNPNC.PROXYNID_ID = PN.ID JOIN CORE_V1.PROXY_NID_STATUS PNS ON PN.STATUS_ID = PNS.ID JOIN CORE_V1.AGENT_MANAGED_HARDWARE AMH ON PN.ID = AMH.PROXYNID_ID JOIN CORE_V1.HARDWARE HW ON AMH.ID = HW.ID JOIN CORE_V1.SNMP_DEVICE SD ON AMH.ID = SD.AGENT_MANAGED_HARDWARE_ID JOIN CORE_V1.SNMP_DEVICE_IP SDIP ON SD.ID = SDIP.SNMPDEVICE_ID
  Granted XID : {879610, X} 
. The selected victim is XID : 879610.

There are two separate processes running.  One is periodically querying which is the “SELECT COUNT(*)…” above.  The second is updating the state of one of the rows which is the “UPDATE” above.  

I am not sure how to read the above and what I can do about it.   

The query is done using a native JPA query and the second is using JPA directly.  Both are being done within a Java EE stateless session being with a transaction.   The isolation level is read committed.  

Any help will be appreciated.

Brett
Bob M | 15 Feb 03:57 2014
Picon

adding a record to a table

Hi

I have a table in which the key is the first two fields viz date and time
the last two records in the table are
2014-02-14      0   .......................
2014-02-14      6   ......................

When I try to add a new record

2014-02-14     12   ........................

I get Error code-1, SQL state 23505
Insert command failed: The statement was aborted because it would have
caused a duplicate key value in a unique or primary key constraint or unique
index indentified by 'SQL14021012215370' defined on 'table name'

What does this error mean ?

--
View this message in context: http://apache-database.10148.n7.nabble.com/adding-a-record-to-a-table-tp137120.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.

Derek Lewis | 13 Feb 20:55 2014

ERROR 42846: Cannot convert types 'BLOB' to 'CHAR () FOR BIT DATA'.

Hello,

I'm struggling to write upgrade and rollback SQL for a CHAR(16) FOR BIT DATA column.  It's currently 16-bytes long, but I'd like to migrate it to a BLOB since I'll need to put more data in it soon.

I'm using liquibase for the migration.  Upgrading is fine, I add a new column, and do "update <table> set newColumn = CAST(oldColumn AS BLOB)".

Rolling back is giving me problems though.
I'm trying to do "update <table> set oldColumn = CAST(newColumn AS CHAR FOR BIT DATA)", but I keep getting the error in the subject.

The documentation I found at http://db.apache.org/derby/docs/10.10/ref/rrefsqlj33562.html indicates that casting from CHAR FOR BIT DATA to BLOB should be possible.  I'm using Derby 10.10.1.1, so I believe those are the correct docs.

Any idea what could be wrong?  For what it's worth, this test is taking place on empty tables.

Cheers,
Derek
Frank Rivera | 12 Feb 16:38 2014

How best to handle null in cast of column subquery

How best to handle null in cast of column subquery?
There are five records each with data in every column but when we run this statement below only some of the columns are returned. 
If we remove the cast statement then all columns are returned. The Age column is null in the records not being returned.

Embedded Derby 10.1.1

SELECT 
( SELECT 
first_name ||'|'||
last_name ||'|'||
GENDER ||'|'||
CAST(AGE AS varchar(3)) ||'|'||
MARITAL_STATUS
FROM esq.contact WHERE esq.contact.guid=esq.contact_list.contact_guid) AS "name"
FROM esq.contact_list WHERE esq.contact_list.link_table='mat' AND esq.contact_list.link_guid=78360;

println to Apache Tomcat Log 


  Record: 1
   name: Jane | Doe | F | 46 | Married 

  Record: 2
   name:

  Record: 3
   name: 

  Record: 4
   name: 

  Record: 5
   name: 


Sincerely,

   - Frank
Bob M | 10 Feb 10:19 2014
Picon

accessing records problem

Hi

I am calling derby within a larger java program....................

Step1: I allocate a database "Connection" object
Step2: I allocate a "Statement" object in the connection
Step 3: I execute a SQL SELECT query, the query result is returned in a
"ResultSet" object
so far so good (I update the latest database record, I add a new record and
I delete the oldest record
I then call a data mining program [Weka]
I setup a few Weka models etc......
I then wish to look at the last 100 records in my database, one at a time
The code I have currently is as follows:-
***********************
try {
Statement s = null;
ResultSet rs = null;
rs = s.executeQuery ("SELECT".................);
int k = 0
while (k < 101) {
rs.next();
...
...
}
k++;
}
}
catch (Exception e)
{
myConsole.getOut().println(e);
}

I get the following error:-
java.lang.NullPointerException

do I need to do something further to read my 100 records?

Bob M

--
View this message in context: http://apache-database.10148.n7.nabble.com/accessing-records-problem-tp136964.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.

Jacopo Cappellato | 7 Feb 18:59 2014
Picon

Unexpected behavior for concurrent selection of an uncommitted record inserted in a different thread

Hi all!

While I was writing some unit tests for the Apache OFBiz project (that by default runs on Derby) I noticed a
behavior of Derby that I didn't expect and I would love to get your opinion.
Here is my use case:

* Derby 10.10.1.1
* there are two concurrent transactions T1 and T2
* isolation level is "Read Committed"
* in transaction T1 a record with primary key 123 is inserted in a table; then other long running tasks are
executed (i.e. the transaction is not immediately committed)
* in the meantime T2 attempts to select from the same table the record with primary key 123

Behavior: T2 blocks on the select statement waiting for transaction T1 to release the write lock; this can
cause a lock wait timeout
Expected behavior: since T1 is not committed, T2 should not be able to select the record; I was expecting
that the select statement in T2 would return an empty result set rather than blocking waiting for the lock
held by T1 to be released; in fact this is what we get with MySQL and Postgres.

What do you think?

Thanks,

Jacopo Cappellato
Paul Linehan | 1 Feb 21:14 2014
Picon
Picon

How to log queries in Apache Derby?

Hi all,

I am trying to log queries to my Apache Derby server.

My $DERBY_HOME is as follows - Ubuntu Linux 64bit - Java jdk1.7.0_45.
Can access my database through Squirrel and ij.

=======================================
linehanp <at> lg12l9:~/derby/db-derby-10.10.1.1-bin/bin$ echo $DERBY_HOME
/users/ugrad/linehanp/derby/db-derby-10.10.1.1-bin
linehanp <at> lg12l9:~/derby/db-derby-10.10.1.1-bin/bin$
=======================================

I launch derby by issuing the command (from $DERBY_HOME)

java -jar $DERBY_HOME/lib/derbyrun.jar server start
or sometimes
./bin/startNetworkServer

I created a file called derby.properties in $DERBY_HOME/bin
in which there is one line

======================
linehanp <at> lg12l9:~/derby/db-derby-10.10.1.1-bin/bin$ more derby.properties
derby.language.logStatementText=true
linehanp <at> lg12l9:~/derby/db-derby-10.10.1.1-bin/bin$
======================

Restart server.

I run ij from $DERBY_HOME and issue a query.

==========================================
ij> connect 'jdbc:derby://localhost:1527/pdata/firstdb';
ij> set schema linehanp;
0 rows inserted/updated/deleted
ij> select * from analysis;
ANALYSIS_ID|CREATED
.... Result set deleted.
ij> commit;
ij> exit;
=============================

I've looked everywhere and can't find my logged query

======================
linehanp <at> lg12l9:~/derby/db-derby-10.10.1.1-bin$ find . -name "*.log"
./pdata/derby.log  <<====== same as ./derby.log below.
./derby.log  <<<<==== a line about shutting down, nothing else
./bin/derby.log  <<<=== empty file.
linehanp <at> lg12l9:~/derby/db-derby-10.10.1.1-bin$ cd bin/
============================

Could some kind soul tell me what I'm doing wrong - thanks.

If any other information is required, please don't hesitate to let me know.

Rgs,

Paul...

--

-- 

linehanp@...

Mob: 00 353 86 864 5772

Paul Linehan | 1 Feb 17:35 2014
Picon
Picon

Can't open more than one connection to database?

Hi all,

A curious one is happening today.

I normally connect to derby using either ij or SQuirreL SQL
or both.

Today though, if I connect with Squirrel, I can't connect with ij
and vice versa.

Error is here
==================
linehanp <at> lg12l9:~/derby/db-derby-10.10.1.1-bin/pdata$ ij
ij version 10.10
ij>  CONNECT 'jdbc:derby:firstdb';
ERROR XJ040: Failed to start database 'firstdb' with class loader
sun.misc.Launcher$AppClassLoader <at> 591ce4fe, see the next exception for
details.
ERROR XSDB6: Another instance of Derby may have already booted the
database /users/ugrad/linehanp/derby/db-derby-10.10.1.1-bin/pdata/firstdb.
ij>
==============

I'm using the Client/Server version - and I'm *_almost_* certain this
didn't happen before.

Any ideas?

TIA and rgs,

Paul...

--

-- 

linehanp@...

Mob: 00 353 86 864 5772

Amitava Kundu1 | 30 Jan 07:46 2014
Picon

Issue with large delete in derby


Hi,
We are using embedded derby 10.5.1.1 in our product, This derby database is
used as regular RDBMS where lot of insert, delete and select happens, There
are business entities each of its occurrence could be of size 10 GB and
upward e.g. a huge log file data.
In our application, we use cascade delete and also has referential
integrity constraints ON.

This application runs on 64 bit Linux with 8 GB RAM allocated to JVM.
Similar time is observed in our development Windows box.

 It takes more than 3 hour to delete those entities. During this time all
the relevant tables stay locked and no other operation is feasible.

We'd like know what could be different options/ strategy be adopted for:
   Speeding up the delete process
   Ability to other database activities in parallel

Thanks
	Amitava Kundu

John I. Moore, Jr. | 30 Jan 15:27 2014
Picon
Picon

Configuring a Server Policy for Derby on Windows

I am sending this email to the Derby user list with the hope that I can save someone time and frustration when trying to run the Derby network server on Windows with the latest version of Java (currently 1.7.0_51).  With the latest version of Java, it is no longer possible to use the batch file “startNetworkServer.bat” to start the network server.  If you run derby under Linux or some variation of Unix, or if you are already familiar with how to use a server policy file with Derby, you can probably ignore this message.  (Note to Derby developers:  You might want to add some of the descriptions below to the appropriate pages in the Derby documentation, especially https://db.apache.org/derby/docs/10.4/adminguide/tadminnetservcustom.html.)

 

To run the Derby network server on Windows, you will need to download a copy of the server policy file 1010_server.policy from https://issues.apache.org/jira/browse/DERBY-6438 and edit it for your use or define appropriate system properties when starting the Derby network server.  I will give an example for editing the file.

 

When editing the file, replace “${derby.install.url}” with the full path name for the Derby jar files in the four sections that start with “grant codebase”.  The syntax is a little tricky.  For example, assume that derby has been installed in C:\Java\db-derby-10.10.1.1-bin.  You use a “file:” specification, but you need to use forward slashes, not back slashes.  Also, the file specification can contain zero, one, or three forward slashes, but not two.  Thus, any of the following will work

     grant codeBase "file:C:/Java/db-derby-10.10.1.1-bin/lib/derby.jar"

     grant codeBase "file:/C:/Java/db-derby-10.10.1.1-bin/lib/derby.jar"

     grant codeBase "file:///C:/Java/db-derby-10.10.1.1-bin/lib/derby.jar"

but not

     grant codeBase "file://C:/Java/db-derby-10.10.1.1-bin/lib/derby.jar"

 

This is an important point since the sample files in the Derby Developer's Guide seem to imply that two slashes are acceptable – see http://db.apache.org/derby/docs/10.10/devguide/cdevcsecure871387.html.  If you use two slashes in you file specification, you will get an error message similar to the following:

 

Thu Jan 30 09:09:33 EST 2014 : access denied ("java.util.PropertyPermission" "derby.__serverStartedFromCmdLine" "write")

java.security.AccessControlException: access denied ("java.util.PropertyPermission" "derby.__serverStartedFromCmdLine" "write")

        at java.security.AccessControlContext.checkPermission(Unknown Source)

        at java.security.AccessController.checkPermission(Unknown Source)

        at java.lang.SecurityManager.checkPermission(Unknown Source)

        at java.lang.System.setProperty(Unknown Source)

        at org.apache.derby.drda.NetworkServerControl$1.run(Unknown Source)

        at org.apache.derby.drda.NetworkServerControl$1.run(Unknown Source)

        at java.security.AccessController.doPrivileged(Native Method)

        at org.apache.derby.drda.NetworkServerControl.main(Unknown Source)

        at org.apache.derby.iapi.tools.run.main(Unknown Source)

 

You also need to replace “${derby.security.port}” with the appropriate port number (e.g., 1527).   Alternatively, you can define “${derby.security.port}” in your call to start the Derby network server, as in “-Dderby.security.port=1527”.  Other policy file parameters can be handled similarly, but these are the most important ones, and these changes are the minimum needed to get the Derby network server started.

 

I saved the policy file in my DERBY_HOME directory as simply server.policy, and I edited only the four “grant codebase” sections as described above.  I can then start the Derby network server using a command similar to the following (which I placed in a batch file):

start java -Dderby.system.home=%DERBY_HOME% -Dderby.security.port=1527 -Djava.security.manager -Djava.security.policy=%DERBY_HOME%\server.policy -jar %DERBY_HOME%\lib\derbyrun.jar server start

 

Alternatively, if your class path contains the appropriate Derby jar files (which can ensure by running %DERBY_HOME%\bin\setNetworkServerCP.bat), you can start the Derby network server using the following:

start java -Dderby.system.home=%DERBY_HOME% -Dderby.security.port=1527 -Djava.security.manager -Djava.security.policy=%DERBY_HOME%\server.policy org.apache.derby.drda.NetworkServerControl start

 

I hope this helps.  I wasted a lot of time before I figured out that the two forward slashes in the file specification was causing the problem.

 

_________________________________________

 

John I. Moore, Jr.

SoftMoore Consulting

 


Gmane