I'm trying to implement Tomee on my existing project that currently uses Tomcat 7. Tomee's website youtube video makes it deceptively simple to implement. Funny how they never show the mess created when the real world meets open source. In our case we always have existing projects, not a clean machine for demonstration. So now you know the back story.
So, I mucked up my tomcat 7 configuration in eclipse. I can set up Tomcat 7 in Eclipse' Preference>Servers. But, i'm unable to attach it to my project. Sisyphus had it easy compared to my feeble attempts to resurrect 7 in eclipse. I found this link: Eclipse me with a butter knife. The masochist in the message board did provide big help: just blow Tomcat configuration out.
Do this:
1. Close Eclipse
2. Navigate to {workspace-directory}/.metadata/.plugins/org.eclipse.core.runtime/.settings
3. Delete the following two files:
a. org.eclipse.wst.server.core.prefs
b. org.eclipse.jst.server.tomcat.core.prefs
4. Restart Eclipse
Now, I can create my Tomcat 7 instance in Eclipse and my project can see it.
grrrr...
This blog is dedicated to those that have helped me gain technical expertise and make a living. You make the world a better place.
Saturday, June 21, 2014
Wednesday, May 7, 2014
Eclipse with Tomcat Server: Whither Context.xml in Tomcat Connection Pooling
I'm implementing a web application with the following configuration:
Apparently, when you run your app in Eclipse, the attached Tomcat server only recognizes the context.xml file it has, and it ignores the one in the application. Painful.
- Java 1.7
- Hibernate 4
- Tomcat 7
- MySQL
Hibernate declares quite plainly that developers should avoid using its own connection pooling implementation for production systems. The dearth of good documentation could paper a welcome mat. Tomcat doesnt do much better.
What's more, if you're using Eclipse to build the application and you want to debug on a tomcat server, how do you connect to MySQL without using Hibernate's connection pooling in hibernate.cfg.xml? I cant provide the entire answer, but here's an important point for configuration:
The tomcat server in your Eclipse IDE has its own context.xml. This is the file where you identify the database and its credentials to use by your applications. If you assumed that the context.xml file located in your application's META-INF would be exercised, you'd be dead wrong.
Apparently, when you run your app in Eclipse, the attached Tomcat server only recognizes the context.xml file it has, and it ignores the one in the application. Painful.
So do yourself a favor and add your database connection information into the server's context.xml file or feel the wrath of "org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'".
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.
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,
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"/>
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,
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!
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!
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.
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.
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.
Subscribe to:
Comments (Atom)




