The problem is that the Maven target directory is also fairly
unintuitive for many folks (i.e. for manually deleting the database or
pointing a GUI DB browser against the Derby files) and we do use /tmp
for stuff other than the DB, such as the file scanner process that does
require manual interaction.
On 10/7/2013 1:46 PM, Bruno Borges wrote:
> Instead of /tmp or ${user.home}, why not use the target folder of the
> Maven build?
> It will be deleted automatically also, in case of a mvn clean.
> I don't like when a Maven project creates files/folders out of its
> boundaries.
>
> m2c
>
> On 10/07/2013 01:32 PM, Reza Rahman wrote:
>> Just tested things out on Linux - /tmp seems to work well. I have
>> already checked in my changes and the download is refreshed too.
>>
>> The problem with ${user.home} is that on Windows it turns out to be a
>> pretty unintuitive location, so /tmp is a good compromise. It also
>> works well with the intent of the database in our application.
>>
>> If you can give things a spin when you get a chance just to make
>> sure, it'll be great. The unit testing that also uses /tmp is now
>> active.
>>
>> On 10/5/2013 1:19 PM, David Heffelfinger wrote:
>>> I know I said I was busy, but I had an idea and had to try it,
>>> otherwise I wouldn't be able to focus on what I really should be doing.
>>>
>>> I changed pom.xml to read:
>>>
>>> <webapp.databaseTempDir>${user.home}/temp</webapp.databaseTempDir>
>>>
>>> So that the "temp" directory would be created under my home
>>> directory instead of under the root directory.
>>>
>>> Did a clean built and redeployed and everything worked as expected.
>>> a "temp" directory was created under my home directory containing
>>> the database.
>>>
>>> Maybe we should make this change permanently? Everybody should have
>>> write permissions to their own home directory, this way we avoid
>>> permissions issue on operating systems other than Windows.
>>>
>>> Now for real, I have work, that needs to get done.
>>>
>>> David
>>>
>>>
>>> On Sat, Oct 5, 2013 at 1:05 PM, Reza Rahman <Reza.Rahman_at_oracle.com
>>> <mailto:Reza.Rahman_at_oracle.com>> wrote:
>>>
>>> Inline...
>>>
>>>
>>> On 10/5/2013 12:56 PM, David Heffelfinger wrote:
>>>> Makes sense that changing pom.xml should be the only change
>>>> needed to change the database location. I was surprised when
>>>> the problem persisted after making the change.
>>>>
>>>> I cleaned and built a few times just to make sure, the problem
>>>> persisted, maybe GlassFish is seeing an old version of the war
>>>> file somewhere?
>>> Another GF/NB bug maybe?
>>>
>>>>
>>>> I'll try changing the values for "databaseTempDir" when I get a
>>>> chance. I'm kind of swamped with other stuff at the moment.
>>> No worries, take your time. I'll see if I can get a Linux
>>> instance up and running on my end.
>>>
>>>>
>>>> David
>>>>
>>>>
>>>> On Sat, Oct 5, 2013 at 12:51 PM, Reza Rahman
>>>> <Reza.Rahman_at_oracle.com <mailto:Reza.Rahman_at_oracle.com>> wrote:
>>>>
>>>> The previous problem you were having was very likely a
>>>> GlassFish bug. The promoted version of GlassFish you are
>>>> running also has knows bugs that we've documented on the
>>>> site FYI.
>>>>
>>>> To change the database location, all you should need to do
>>>> is change the <webapp.databaseTempDir> entry in pom.xml and
>>>> rebuild. The test-web.xml entry is used only for tests.
>>>>
>>>> Could you kindly try out different values for
>>>> 'databaseTempDir' and see if something can work without
>>>> needing to muck with permissions/creating directories?
>>>> Otherwise, we really need to add this to our setup
>>>> instructions ASAP:
>>>> https://java.net/projects/cargotracker/pages/NetBeans. I
>>>> would do this myself but I'll take me a while to get a
>>>> Linux/UNIX version up and running...
>>>>
>>>>
>>>> On 10/5/2013 12:36 PM, David Heffelfinger wrote:
>>>>> Better, but not a flawless experience.
>>>>>
>>>>> Originally I got an exception:
>>>>>
>>>>> java.sql.SQLException: *Failed to create database
>>>>> '/temp/cargo-tracker-database', see the next exception for
>>>>> details.*
>>>>> at
>>>>> org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown
>>>>> Source)
>>>>> at
>>>>> org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown
>>>>> Source)
>>>>>
>>>>> I'm on a Linux system, not running as root, and there is
>>>>> no /temp directory, so I changed the following line in
>>>>> pom.xml:
>>>>>
>>>>> <webapp.databaseTempDir>/temp</webapp.databaseTempDir>
>>>>>
>>>>> to
>>>>>
>>>>> <webapp.databaseTempDir>/tmp</webapp.databaseTempDir>
>>>>>
>>>>> Then changed the following line in test-web.xml
>>>>>
>>>>> <url>jdbc:derby:/temp/test/cargo-tracker-database;create=true</url>
>>>>>
>>>>> to
>>>>>
>>>>> <url>jdbc:derby:/tmp/test/cargo-tracker-database;create=true</url>
>>>>>
>>>>> Rebuilt and redeployed, but I was still getting the
>>>>> exception, I searched all over the code for references to
>>>>> "/temp" but couldn't find any.
>>>>>
>>>>> As a workaround I sudo'ed to root, created /temp and
>>>>> chmod'ed it 777, and was finally able to deploy.
>>>>>
>>>>> FWIW, this is the version of GlassFish I downloaded:
>>>>>
>>>>> http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/latest-glassfish.zip
>>>>> <http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/>
>>>>>
>>>>> Added it to NetBeans ("Services" tab, right click
>>>>> "Servers" | "Add Server")
>>>>>
>>>>> David
>>>>>
>>>>>
>>>>>
>>>>> On Sat, Oct 5, 2013 at 12:05 PM, Reza Rahman
>>>>> <reza.rahman_at_oracle.com <mailto:reza.rahman_at_oracle.com>>
>>>>> wrote:
>>>>>
>>>>> Could you kindly try the nightly build of GlassFish 4
>>>>> and tell me what happens?
>>>>>
>>>>> Sent from my iPhone
>>>>>
>>>>> On Oct 5, 2013, at 12:01 PM, David Heffelfinger
>>>>> <dheffelfinger_at_gmail.com
>>>>> <mailto:dheffelfinger_at_gmail.com>> wrote:
>>>>>
>>>>>> All,
>>>>>>
>>>>>> I got the latest source code from SVN as of this
>>>>>> morning (revision 123).
>>>>>>
>>>>>> I loaded the project into NetBeans 7.4 RC2, and built
>>>>>> it without a problem.
>>>>>>
>>>>>> I then attempted to deploy and run the project to
>>>>>> GlassFish 4 (included with NetBeans), but was
>>>>>> unsuccessful, I got a NoClassDefFoundError.
>>>>>>
>>>>>> Here is a partial stack trace:
>>>>>>
>>>>>> SEVERE: Exception while preparing the app :
>>>>>> java.lang.NoClassDefFoundError: Could not initialize
>>>>>> class org.apache.derby.jdbc.EmbeddedDriver
>>>>>> java.lang.NoClassDefFoundError: Could not initialize
>>>>>> class org.apache.derby.jdbc.EmbeddedDriver
>>>>>> at java.lang.Class.forName0(Native Method)
>>>>>> at java.lang.Class.forName(Class.java:188)
>>>>>> at
>>>>>> com.sun.gjc.spi.DMManagedConnectionFactory.createManagedConnection(DMManagedConnectionFactory.java:114)
>>>>>> at
>>>>>> com.sun.enterprise.resource.allocator.LocalTxConnectorAllocator.createResource(LocalTxConnectorAllocator.java:87)
>>>>>> at
>>>>>> com.sun.enterprise.resource.pool.ConnectionPool.createSingleResource(ConnectionPool.java:907)
>>>>>> at
>>>>>> com.sun.enterprise.resource.pool.ConnectionPool.createResource(ConnectionPool.java:1189)
>>>>>> at
>>>>>> com.sun.enterprise.resource.pool.datastructure.RWLockDataStructure.addResource(RWLockDataStructure.java:98)
>>>>>>
>>>>>> I made sure I had derby.jar under .../domain1/lib but
>>>>>> the problem persists.
>>>>>>
>>>>>> I would look deeper into it but unfortunately I'm
>>>>>> busy with some other stuff.
>>>>>>
>>>>>> Is this a known issue or am I missing something here?
>>>>>>
>>>>>> Thanks,
>>>>>> David
>>>>>>
>>>>>>
>>>>>> --
>>>>>> http://ensode.net <http://ensode.net/> - A Guide to
>>>>>> Java, Linux and Other Technology Topics
>>>>>> My Books:
>>>>>> http://www.packtpub.com/authors/profiles/david-heffelfinger
>>>>>> My Video Training:
>>>>>> http://www.packtpub.com/java-ee-development-with-netbeans-7/video
>>>>>> Follow me on Twitter: https://twitter.com/ensode
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> http://ensode.net <http://ensode.net/> - A Guide to Java,
>>>>> Linux and Other Technology Topics
>>>>> My Books:
>>>>> http://www.packtpub.com/authors/profiles/david-heffelfinger
>>>>> My Video Training:
>>>>> http://www.packtpub.com/java-ee-development-with-netbeans-7/video
>>>>> Follow me on Twitter: https://twitter.com/ensode
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> http://ensode.net <http://ensode.net/> - A Guide to Java, Linux
>>>> and Other Technology Topics
>>>> My Books:
>>>> http://www.packtpub.com/authors/profiles/david-heffelfinger
>>>> My Video Training:
>>>> http://www.packtpub.com/java-ee-development-with-netbeans-7/video
>>>> Follow me on Twitter: https://twitter.com/ensode
>>>
>>>
>>>
>>>
>>> --
>>> http://ensode.net <http://ensode.net/> - A Guide to Java, Linux and
>>> Other Technology Topics
>>> My Books: http://www.packtpub.com/authors/profiles/david-heffelfinger
>>> My Video Training:
>>> http://www.packtpub.com/java-ee-development-with-netbeans-7/video
>>> Follow me on Twitter: https://twitter.com/ensode
>>
>
> --
> |Bruno Borges (twitter @brunoborges)
> Principal Product Manager | Java WebLogic Coherence GlassFish
> Oracle LAD PM Team | Cloud Application Foundation
> +55 11 5187 6514 (Work) | +55 11 99564 9058 (Mobi)|