Saturday, April 12, 2014

Exporting Pesky Eclipse .epf Preference File

If you're like me, you tinker with the look of your eclipse IDE.  It's probably a good idea to export your preferences, in the remote chance that Eclipse has a melt down.

If you think going to Windows > Preferences is the logical place to go, you'd be dead wrong.  Instead, navigate to File > Export.  Under the "General" node, select "Preferences".  I created a folder in my workspace called, coincidentally, "preferences".  I dont know if the automatic overwrite works, there's no mention of it in the eclipse documentation.  What the heck, it's 2014, let's see if your preferences file gets updated after you tinker.  If you dont think it does, just re-do the steps here.


Friday, March 14, 2014

Grails Deployment on New Tomcat Server

While I'm currently building a REST application using Groovy on Grails, I have also taken a swing at configuring a Dev server.

The toughest aspect of setting up Tomcat and MySQL on a brand new VM is the fact that unless you focus on building server instances all the time, these setups are deceptively easy.  I dont think they are.  As developers, we perform this task once in a blue moon.  So, here's a gotcha.

Following the Grails documentation, I created a war file from the command line, "grails war".  The system administrator had spooled up this vm, so i fired up Tomcat and deployed the war file from the "War file to deploy" section of the Tomcat Manager page.

When i clicked the "Start" button,
 Nothing.  

My grails app was not running.

In Tomcat's logs folder, I cracked open the the stacktrace.log file.  Apparently, Tomcat was unable to "Create a sessionFactory".  Take this as a grails code word that "it's possible your grails app is not communicating with the database".

After much hair pulling, I figured out a solution to my non-starting app.  I started by looking at the Tomcat documentation (figures).  I had my doubts that the system administrator had installed the MySQL Connector as mentioned in the docs.  Get the appropriate connector and place it in your Tomcat/lib (or $CATALINA_HOME/lib) location.  Then, make a reference to the targeted MySQL database in Tomcat's $CATALINA_HOME/conf/context.xml file.

You need to add a reference, like
<Resource name="jdbc/your_db" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="dbUser" password="pass234" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/your_db"/>

It helps to make these configuration changes while Tomcat is not running.  After these changes are made, you can deploy the grails app, hit the "Start" button, and you should see "Running"=true.

Good luck,
woof!

Monday, February 24, 2014

Grails and Spring Security Core Plugin: Controller Annotation Fun

i'm on Grails 2.3.5.  Couldnt seem to get the controller's create view to appear.  Consistently showed me the "Not authorized to view..." message.

So, assuming you are using "Annotation" for your securityConfigType in your Config.groovy, you might be able to get your setup to reveal the create view, too.

Perusing the same Config.groovy, peer closer.

if you're upgrading security, you might have some items missing like, css, you need to add it or you're page will block.
i added the create views and the kicker, /**.  i saw it referenced in the logging and its addition seemed to gain access to the create view.

grails.plugin.springsecurity.controllerAnnotations.staticRules =
[
'/':                              ['permitAll'],
'/index':                         ['permitAll'],
'/index.gsp':                     ['permitAll'],
'/create':      ['permitAll'],
"/create.gsp":  ['permitAll'],
'/**/js/**':                      ['permitAll'],
'/**/css/**':                     ['permitAll'],
'/**/images/**':                  ['permitAll'],
'/**/favicon.ico':                ['permitAll'],
'/login/**':                      ['permitAll'],
'/logout/**':                     ['permitAll'],
'/**':                            ['permitAll']
]

woof!


Sunday, February 23, 2014

Git Bit? Untracking generated files that you foolishly tracked

cd to the directory where the tracked files exist.  add this magic: git update-index --assume-unchanged $(git ls-files)

It all goes ignored.

woof!

Friday, February 7, 2014

Switching Windows in Windows

Had a request to ping pong between two applications running in windows.

So, when the user clicks a button from application A, it fires this executable (see below).  This program looks to see if the other application B is running, if so, it switches to application B and puts it in the foreground of the user's session.  if application B is not running, it start application B.  For this post, i'm only showing the process from A to B.  You can simply reuse this code to switch from B to A.

Microsoft's task manager gives you some insight into what needs to be done.  An application running in windows is called a "process".

From a windows desktop application, the program interrogates all processes for a particular process name, e.g. "IntuifaceComposer".

If the process exists, the program obtains a window handle and puts the application in the UI's foreground by using a function in dll import, user32.dll, SetForegroundWindow().

Otherwise, if a new application is needed, the program calls the Start method of Process and passes the file location of the application.



Saturday, November 16, 2013

Timestamps....Stinkin' timestamps

I've spent way, way too much time on resolving this issue.  I'm talking about timestamps.  You'd think the subject pretty cut and dry: i get the user's browser and obtain their time and timezone.  When she creates a new record that timestamp ought to go right into that "created date" field.

Not so fast.

Oracle has taken the position that a browser is a lousy way to get time.  It's not reliable because the user can manipulate their browser to show the wrong time or geography.  Oh well.

So what's the Oracle approach?  Well, when you set up your user account, you can set the user's timezone.  then, you can look up the timezone from the account and offset the value on a new record.  You're going to use the webserver's time.  there's no way around it, unless you want that browser time and that requires some effort using javascript.

Here's how i added a timestamp function to a "Create" button.  After the row is instantiated on the screen, you perform the timestamp function and assign the value to the "Create Date" field.


Woof!

Saturday, October 5, 2013

Connect to a Pluggable Database from JDeveloper

I've been puzzling over the dearth of results about a simple problem, once the pluggable database has been created.  How do you connect to it from your web application?

I use JDeveloper, and after some "experimentation", I believe I stumbled on the answer.  Take a look at the configuration in the screen shot


The connection information looks identical to how i connect to the CDB.  But, instead of using the SID, I'm using the Service Name field.  The Service name starts with the pluggable database' SID.  In this case my pluggable database is pdsmall.  dachshund.com is my database domain.

Woof!