Friday, November 20, 2009

Django properties for settings.py

I wanted to externalize all of the properties in settings.py for obvious reasons. I found a couple of suggestions.

What I did was create to files, properties_local.py and properties_dev.py. Working locally I imported, "import properties_local as properties"
# Django settings for [project name] project.
import properties_local as properties

and then set the variables accordingly:
DATABASE_ENGINE = properties.DATABASE_ENGINE
DATABASE_NAME = properties.DATABASE_NAME
DATABASE_USER = properties.DATABASE_USER
DATABASE_PASSWORD = properties.DATABASE_PASSWORD
DATABASE_HOST = properties.DATABASE_HOST
DATABASE_PORT = properties.DATABASE_PORT
I only have to change the import setting. I should figure out a way around that soon though.

Thursday, November 19, 2009

Django template does not exist

I got a really annoying error while putting up a new Django site:

TemplateDoesNotExist
at /flatpage/
flatpages/default.html
Request Method: GET
Request URL: http://[site url]/flatpage/
Exception Type: TemplateDoesNotExist
Exception Value:
flatpages/default.html
Exception Location: /usr/lib/python2.4/site-packages/django/template/loader.py in find_template_source, line 74
Python Executable: /usr/bin/python
Python Version: 2.4.3
Python Path: ['/[python path]', '/usr/lib/python24.zip', '/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk', '/usr/lib/python2.4/lib-dynload', '/usr/lib/python2.4/site-packages']
Server time: Thu, 19 Nov 2009 22:39:37 -0500
Of course I had templates in Apache's directory. The Template-loader postmortem (great name) showed that Django was looking for the wrong directory (in italics below.)

Template-loader postmortem

Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.load_template_source:
/[development path]/flatpages/default.html (File does not exist)
Using loader django.template.loaders.app_directories.load_template_source:
/usr/lib/python2.4/site-packages/django/contrib/admin/templates/flatpages/default.html (File does not exist)
I know these things should be put into properties. I was being lazy.

I restarted the server to clear out whatever had cashed the older directory entry. Everything was fine.

Nice!

Infoq Interview with Gavin King about Weld anc CDI

Infoq has a nice interview with Gavin King about Weld and CDI.

Seam is an excellent framework. Hopefully having its' model implemented as part of the JEE spec will push adoption!

Tuesday, November 10, 2009

Django flatpages, templatetags and dynamic menus

One thing that Django's flatpages app is missing is a dynamic menu.

Coming from a Java background I am used to a huge user base and lots of open source code. The Django user base continues to meet my expectations.

I found this post detailing the creation of such a menu tag. I hadn't explored custom tags before anyway so I looked forward to trying it out.

I followed the instructions and got the following error :

TemplateSyntaxError at /menu/
'flatpage_menu' is not a valid tag library: Could not load template library from django.templatetags.flatpage_menu, No module named flatpage_menu
Request Method: GET
Request URL: http://127.0.0.1:8000/menu/
Exception Type: TemplateSyntaxError
Exception Value:
'flatpage_menu' is not a valid tag library: Could not load template library from django.templatetags.flatpage_menu, No module named flatpage_menu
Exception Location: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/template/defaulttags.py in load, line 927
Python Executable: /Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python
Python Version: 2.6.4
Python Path: ['/Users/jdavis/Documents/django_workspace/cantina76', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages']

The post was from last year. I was using the Django 1.1.1. I figured something had changed since his post.

I found a couple of references in Google Groups to this same example, but their suggestions didn't work for me.

The solution was to add my own app to INSTALLED_APPS and "from django import template" to the "flatpage_menu.py" file.

It worked fine after that.

Tuesday, September 22, 2009

The excellent Mr. Haki blog

My morning routine has changed recently. I check out Mr. Haki, fire up the Groovy console and run the latest example.

I have been seriously impressed with the work Mr. Haki is doing.

Even if nobody reads this post, I want to at least help his search rankings!


Wednesday, September 16, 2009

jRecruiter presentation at AJUG

Gunnar Hillert gave an excellent presentation on his jRecruiter project at AJUG last night.

I will soon be downloading jRecruiter to check it out in more depth. Gunnar mentioned that the Maven build is a little wonky at the moment. He said he would fix it in the next week or two.

He has a lot of really cool stuff in the app:
  • Struts 2.1, which I have not used. I spent years using the Struts 1.* releases, but have been in the JSF camp for a while now.
  • Twitter integration, which I've wanting to check out.
  • GZip and minification.
Check out the project or his blog for a complete list.


Friday, September 11, 2009

"The processing instruction target matching "[xX][mM][lL]" is not allowed."

I often put the Xml I use for test cases inside of Groovy classes. This allows me to make use of multiline Strings.

String inputXml = '''
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<records>
<record>
<recordid>833432</recordid>
<name>Lorem ipsum dolor</name>
<parentid>0</parentid>
<link>http://consectetueradipiscingelit</link>
<date>9/10/2009</date>
<description>Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.</description>
<category ID="48015"></category>
<category>In enim justo</category>
</record>
</records>
'''


I ran into this error today :

"The processing instruction target matching "[xX][mM][lL]" is not allowed."

I'm surprised I hadn't run into it before. The problem was that I had white space before the xml prolog.

There are two easy solutions :
  1. Remove the whitespace.
  2. Call "trim()" on the String.

Whitespace removed :
String inputXml = '''<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<records>
<record>
<recordid>833432</recordid>
<name>Lorem ipsum dolor</name>
<parentid>0</parentid>
<link>http://consectetueradipiscingelit</link>
<date>9/10/2009</date>
<description>Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.</description>
<category ID="48015"></category>
<category>In enim justo</category>
</record>
</records>


trim() called :

String inputXml = '''
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<records>
<record>
<recordid>833432</recordid>
<name>Lorem ipsum dolor</name>
<parentid>0</parentid>
<link>http://consectetueradipiscingelit</link>
<date>9/10/2009</date>
<description>Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.</description>
<category ID="48015"></category>
<category>In enim justo</category>
</record>
</records>
'''.trim()


Thursday, August 27, 2009

app-engine-patch Database problems

I've been using app-engine-patch to get some Django stuff running on Google AppEngine.

Several times my admin password has been reset or invalidated. On a couple of occasions I recreated the admin user from the link on the default page. After styling the site this wasn't possible.

I added the "create_admin_user" entry from the generated myapp/urls.py to the root level urls.py and manually entered the url. That worked.



Unexpected Groovy return value

I like Groovy's multiline Strings. I use them all the time in my test cases. Usually I have a utility class that returns whatever content I need.

Yesterday I decided to do the whole test in Groovy. Inside my TestNG test case I had a method that returned some xml :

    String createInputFile(){
return
'''
<xml><one>Hello</one><two>World!</two></xml>
'''
}


The output was null. Kind of silly of me. Adding a semicolon after the String didn't produce an output. Putting the opening quote on the same line as the return statement did.

I still don't miss semicolons though.

Thursday, July 16, 2009

Practical Django Projects, coltrane weblog app and django-tagging

I'm working through Practical Django Projects 2nd Edition.

There is a problem with Chapter 4's weblog application, "coltrane." I won't go into detail about the coltrane app, but in the event that you encounter the same problem I've posted a solution.

I downloaded django-tagging. The current version was 0.2.1.

I created a symlink from my projects directory to the downloaded directory.

I added "'taggigng'" to "INSTALLED_APPS" and tried to start the server. I got the following :
Validating models...
Unhandled exception in thread started by <function inner_run at 0x652c30>
Traceback (most recent call last):
File "/Library/Python/2.5/site-packages/django/core/management/commands/runserver.py", line 48, in inner_run
self.validate(display_num_errors=True)
File "/Library/Python/2.5/site-packages/django/core/management/base.py", line 246, in validate
num_errors = get_validation_errors(s, app)
File "/Library/Python/2.5/site-packages/django/core/management/validation.py", line 28, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/Library/Python/2.5/site-packages/django/db/models/loading.py", line 128, in get_app_errors
self._populate()
File "/Library/Python/2.5/site-packages/django/db/models/loading.py", line 57, in _populate
self.load_app(app_name, True)
File "/Library/Python/2.5/site-packages/django/db/models/loading.py", line 72, in load_app
mod = __import__(app_name, {}, {}, ['models'])
File "/[path to django projects]/coltrane/models.py", line 6, in <module>
from tagging.fields import TagField
File "/[path to django projects]/tagging/fields.py", line 10, in <module>
File "/[path to django projects]/tagging/models.py", line 9, in <module>
File "/[path to django projects]/tagging/managers.py", line 6, in <module>
ImportError: cannot import name parse_lookup
Sweet!

Turns out a lot of people have had this problem.

I checked out the current version from svn and recreated the symlink. All was well.

Django syncdb and create/drop

Django's manage.py syncdb command doesn't drop/create. It is clearly stated in the documentation. Naturally it took me a while to figure that out.

There is an easy solution :


python ./Documents/DjangoWorkspace/cms/manage.py reset coltrane
I've used it a few times now.


Creating a build.xml for a JBoss Tools Seam project continued

I posted earlier about a really nice blog entry outlining the differences between JBoss Tools and Seam-Gen generated projects. I grabbed the build.xml the author supplied, saving myself a few hours. However, I ran into an annoying hiccup.

I usually develop with an exploded .ear. The ant target,"explode," worked fine.

I ran the "deploy" target to verify before committing my latest changes. The app wouldn't start.
java.lang.NoClassDefFoundError: org/ajax4jsf/application/ViewHandlerWrapper
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:675)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at org.jboss.mx.loading.RepositoryClassLoader.findClassLocally(RepositoryClassLoader.java:682)
at org.jboss.mx.loading.RepositoryClassLoader.findClass(RepositoryClassLoader.java:662)
at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
at org.jboss.mx.loading.RepositoryClassLoader.loadClassLocally(RepositoryClassLoader.java:200)
at org.jboss.mx.loading.ClassLoadingTask$ThreadTask.run(ClassLoadingTask.java:131)
at org.jboss.mx.loading.LoadMgr3.nextTask(LoadMgr3.java:399)
at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:527)
at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:415)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357)
at java.lang.Class.getConstructor0(Class.java:2671)
at java.lang.Class.newInstance0(Class.java:321)
at java.lang.Class.newInstance(Class.java:303)
at com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:825)
at com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:486)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:381)
at org.jboss.web.jsf.integration.config.JBossJSFConfigureListener.contextInitialized(JBossJSFConfigureListener.java:69)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3856)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4361)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:790)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:770)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.apache.catalina.core.StandardContext.init(StandardContext.java:5312)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java:301)
at org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java:104)
at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:375)
at org.jboss.web.WebModule.startModule(WebModule.java:83)
at org.jboss.web.WebModule.startService(WebModule.java:61)
at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
at $Proxy0.start(Unknown Source)
at org.jboss.system.ServiceController.start(ServiceController.java:417)
at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy44.start(Unknown Source)
at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:466)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
at org.jboss.wsf.container.jboss42.DeployerInterceptor.start(DeployerInterceptor.java:87)
at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy45.start(Unknown Source)
at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1015)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy9.deploy(Unknown Source)
at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:336)
at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
at $Proxy0.start(Unknown Source)
at org.jboss.system.ServiceController.start(ServiceController.java:417)
at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy4.start(Unknown Source)
at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy5.deploy(Unknown Source)
at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
at org.jboss.Main.boot(Main.java:200)
at org.jboss.Main$1.run(Main.java:508)
at java.lang.Thread.run(Thread.java:613)
IN
Nice.

I tried again with "explode," and everything was fine. I love these kinds of errors.

I uzipped the .ear file and diffed the resulting folder with the exploded ear folder.

The first difference I noticed was that the MANIFEST.MF in the .ear/META-INF did not contain a Class-Path entry while the exploded one contained an entry with "/lib/groovy-all,jar quartz.jar".

I added a manifest tag to the jar command of the build.xml. The result was :

    <target name="archive" depends="jar,war,ear"
description="Package the archives">
<jar jarfile="${dist.dir}/${project.name}-ejb.jar" basedir="${jar.dir}" />
<jar jarfile="${dist.dir}/${project.name}.war" basedir="${war.dir}" />
<jar jarfile="${dist.dir}/${project.name}.ear">
<manifest >
<attribute name="Class-Path" value="lib/groovy-all.jar quartz.jar"/>
</manifest>
<fileset dir="${ear.dir}" />
<fileset dir="${dist.dir}" >
<include name="${project.name}-ejb.jar" />
<include name="${project.name}.war" />
</fileset>
</jar>
</target>


It didn't matter. I ran "deploy" and got the same error. So I checked the MANIFEST.MF in the ear. Sure enough the exploded one contained a "Class-Path" entry and the archived one didn't.
Adding the "Class-Path" attribute to the manifest fixed it. The result was :

    <target name="archive" depends="jar,war,ear"
description="Package the archives">
<jar jarfile="${dist.dir}/${project.name}-ejb.jar" basedir="${jar.dir}" >
<manifest>
<attribute name="Class-Path" value="antlr-runtime.jar drools-compiler.jar drools-core.jar jboss-el.jar jboss-seam.jar jbpm-jpdl.jar mvel14.jar richfaces-api.jar" />
</manifest>
</jar>
<jar jarfile="${dist.dir}/${project.name}.war" basedir="${war.dir}" />
<jar jarfile="${dist.dir}/${project.name}.ear">
<manifest >
<attribute name="Class-Path" value="lib/groovy-all.jar quartz.jar"/>
</manifest>
<fileset dir="${ear.dir}" />
<fileset dir="${dist.dir}" >
<include name="${project.name}-ejb.jar" />
<include name="${project.name}.war" />
</fileset>
</jar>
</target>


Finally, back to real work.

Friday, July 10, 2009

Creating a build.xml for a JBoss Tools Seam project

I usually use seam-gen to create my Seam projects. I have also been relying on a lot of JBoss Tools. JBoss Tools is a suite of Eclipse plugins.

I created my most recent project using the ide. The generated project does not contain a build.xml. This is of course a problem when you want to automate the build process.

There is a resolved JIRA issue so I imagine this won't be a problem much longer.

In the meantime this really nice blog entry contains a template build.xml.

Tuesday, June 23, 2009

Adjusting log4j in JBoss

JBoss' log4j configuration can be found at [server root]/server/default/conf/jboss-log4j.xml.

There are two important parts to tweaking your logging, the appender settings and limit categories.

The appender settings start on line 64 for jboss-4.2.2.GA. The default is :
   <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="Target" value="System.out"/>
<param name="Threshold" value="INFO"/>

<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
</layout>
</appender>

Mine look like this :

   <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="Target" value="System.out"/>

<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%-5p [%c{7}.%M] %m %n"/>

</layout>
</appender>


The difference is the ConversionPattern. Inside the brackets I use %c{7}.%M. That means that the class name will append 7 levels back, i.e. com.foo.bar.baz.buz.bam.SomeClass. The ".%M" appends the method name as well, i.e. com.foo.bar.baz.buz.bam.SomeClass.someMethod.

This way I can see the fully qualified class name and method.

Sunday, June 21, 2009

Distilled Brilliance on Python Integer equality

Excellent blog post on DZone this morning. I like the name of this blog, "Distilled Brilliance," too.

Wednesday, June 10, 2009

Safari 4

If you are a Mac user run Software Update and get Safari 4 now.

This release is significantly faster in loading pages and url completion.

The new "Top Sites" feature is really cool. Apple cribbed it from Opera, but they've improved on it.

Saturday, May 30, 2009

httpd.conf on Mac OSX

On Mac OSX Apache's httpd.conf is located here : /private/etc/apache2.

I wanted to add .xhtml files to the list of default pages served.  The solution is to simply add "index.xhtml" the "IfModule dir_module" entry on line 224:

<IfModule dir_module>
DirectoryIndex index.html, index.xhtml
</IfModule>

Thursday, May 28, 2009

Lorem ipsum generator

I've used http://www.lipsum.com/ for generating lorem ipsum text for ages.

Thanks to this nettuts.com tutorial I discovered a new Lorem ipsum generator : http://www.blindtextgenerator.com/. It is nicely configurable.

Tuesday, April 28, 2009

Where is the site-packages directory on Mac OSX?

/Library/Python/2.5/site-packages

Running :
 python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"

As suggested in the Django documentation displays the directory.

can not perform DDL/DML over objects in Recycle Bin

I got this error today while trying to run jBPM drop/create scripts.

I didn't know Oracle had a recycle bin?

Theoretically the solution is to run, "purge recyclebin;" and wait. I say theoretically because my solution required dropping and recreating the user. Somehow my foreign keys didn't get moved to the recycle bin at the same time as my tables.

Additionally the "purge" command needs to be added to delete statements.

Thursday, April 23, 2009

Useful Eclipse Plugins

I changed laptops recently. While updating Eclipse I realized that I did not have a list of the update sites I use. I figured this place was as good as any.

JBoss tools wraps some other useful plugins like Hibernate. It also has functionality for Seam and JBoss AS administration.

Seam leverages TestNG so the plugin is useful.

I have to use Groovy now.

Subclipse

Wednesday, April 22, 2009

Linkage error

I got the following error after redeploying this morning :
java.lang.RuntimeException: Could not create Component: ClassName
at org.jboss.seam.init.Initialization.addComponent(Initialization.java:1178)
at org.jboss.seam.init.Initialization.installComponents(Initialization.java:1094)
at org.jboss.seam.init.Initialization.init(Initialization.java:728)
at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:35)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3856)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4361)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:790)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:770)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.apache.catalina.core.StandardContext.init(StandardContext.java:5312)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java:301)
at org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java:104)
at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:375)
at org.jboss.web.WebModule.startModule(WebModule.java:83)
at org.jboss.web.WebModule.startService(WebModule.java:61)
at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
at $Proxy0.start(Unknown Source)
at org.jboss.system.ServiceController.start(ServiceController.java:417)
at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy44.start(Unknown Source)
at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:466)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
at org.jboss.wsf.container.jboss42.DeployerInterceptor.start(DeployerInterceptor.java:87)
at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy45.start(Unknown Source)
at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1015)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy9.deploy(Unknown Source)
at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:610)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
Caused by: java.lang.LinkageError: loader constraints violated when linking fully/qualified/ClassName class
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2395)
at java.lang.Class.privateGetPublicMethods(Class.java:2519)
at java.lang.Class.getMethods(Class.java:1406)
at org.jboss.seam.Component.hasAnnotation(Component.java:1125)
at org.jboss.seam.Component.<init>(Component.java:219)
at org.jboss.seam.Component.<init>(Component.java:206)
at org.jboss.seam.init.Initialization.addComponent(Initialization.java:1162)
... 93 more

Of course the app was working when I showed up this morning and fired up JBoss.

This post on JBoss' wiki points out the problem. I liked this line from the wiki post, "Depending on how unlucky you may be, you might get a LinkageError or ClassCircularityError as well."

I checked the jboss-app.xml inside my ear and sure enough it was empty. I have no idea how that happened. However, the fix is simple. I just added the following :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-app
PUBLIC "-//JBoss//DTD J2EE Application 4.2//EN"
"http://www.jboss.org/j2ee/dtd/jboss-app_4_2.dtd">

<jboss-app>
<loader-repository>
seam.jboss.org:loader=appName
</loader-repository>
</jboss-app>

Friday, April 10, 2009

XmlUnit

XmlUnit is an insanely great tool. It has saved me a ton of time in the past few weeks.

I log the differences from my unit test like this :

        XMLUnit.setIgnoreWhitespace(true);
Diff xmlDiff = new Diff(expectedXml, result);

DetailedDiff myDiff = new DetailedDiff(xmlDiff);
List<Difference> allDifferences = myDiff.getAllDifferences();
for(Difference d : allDifferences){
log.debug("difference : " + d);
}


The "result" string comes from a Groovy class using XmlSlurper. Also I usually generate "expectedXml" from a Groovy class.

Monday, February 16, 2009

illegal character: \64 when running Eclipse on Mac OSX

I develop on a Mac. We use Luntbuild to automate our builds.

We added our new project into Luntbuild this morning. Luntbuild kicked this back :
[package name]/ChannelDetails.java:24: illegal character: \64
compile [ javac ] @Entity
Nice.

Our team has used OS X, Ubuntu, XP and Vista. We had not encountered this problem before.

Why wouldn't Eclipse just standardize on one character encoding?

The solution is to change the encoding by right clicking on the project and choose Properties -> Resource.

There are panels for "Text file encoding" and "New text file delimiter."

Wednesday, February 4, 2009

NetBeans 6.5 and svn+ssh on a Mac

I've been playing with NetBeans occaisonally. I couldn't stand it a couple of years ago. However, after Sun's Tech Days in Atlanta I decided to give it a try.

Besides, I wanted to verify a clean checkout, build, test cycle.

We use svn over ssh at work. It was a headache to get this running with NetBeans. I didn't completely succeed either.

This post has a nice tutorial from a Rails perspective. I started here. I was able to checkout fine. But when I right clicked -> Subversion -> Update I got an error stating that ssh_askpass couldn't be found.

I did some digging around. This post is a great discussion about Leopard and ssh.

I checked out this tutorial from the NetBeans site. I was pretty annoyed that I hadn't found an answer so I clicked the update button. It worked.

I can't reproduce the error now. Right clicking the project and running an update has worked since I updated from the button.

So in the event that you hit this post while having the same problems, run an update from the button.

Tuesday, January 13, 2009

JBPM_ID_USER

While helping a coworker set up jBPM I learned that part of the create script for jBPM 3.3.0.GA is missing. The user part. You can't log in without it.

This post from JBoss' forums has the solution.

Here's the missing create statements :
create table JBPM_ID_GROUP (ID_ number(19,0) not null, CLASS_ char(1 char) not null, NAME_ varchar2(255 char), TYPE_ varchar2(255 char), PARENT_ number(19,0), primary key (ID_));
create table JBPM_ID_MEMBERSHIP (ID_ number(19,0) not null, CLASS_ char(1 char) not null, NAME_ varchar2(255 char), ROLE_ varchar2(255 char), USER_ number(19,0), GROUP_ number(19,0), primary key (ID_));
create table JBPM_ID_PERMISSIONS (ENTITY_ number(19,0) not null, CLASS_ varchar2(255 char), NAME_ varchar2(255 char), ACTION_ varchar2(255 char));
create table JBPM_ID_USER (ID_ number(19,0) not null, CLASS_ char(1 char) not null, NAME_ varchar2(255 char), EMAIL_ varchar2(255 char), PASSWORD_ varchar2(255 char), primary key (ID_));
create table JBPM_JOB (ID_ number(19,0) not null, CLASS_ char(1 char) not null, VERSION_ number(10,0) not null, DUEDATE_ timestamp, PROCESSINSTANCE_ number(19,0), TOKEN_ number(19,0), TASKINSTANCE_ number(19,0), ISSUSPENDED_ number(1,0), ISEXCLUSIVE_ number(1,0), LOCKOWNER_ varchar2(255 char), LOCKTIME_ timestamp, EXCEPTION_ varchar2(4000 char), RETRIES_ number(10,0), NAME_ varchar2(255 char), REPEAT_ varchar2(255 char), TRANSITIONNAME_ varchar2(255 char), ACTION_ number(19,0), GRAPHELEMENTTYPE_ varchar2(255 char), GRAPHELEMENT_ number(19,0), NODE_ number(19,0), primary key (ID_));
For the jbpm-console app to work run the following inserts as well :
INSERT INTO JBPM_ID_USER VALUES(1,'U','user','user@sample.domain','user');
INSERT INTO JBPM_ID_USER VALUES(2,'U','manager','manager@sample.domain','manager');
INSERT INTO JBPM_ID_USER VALUES(3,'U','admin','admin@sample.domain','admin');
INSERT INTO JBPM_ID_USER VALUES(4,'U','shipper','shipper@sample.domain','shipper');
INSERT INTO JBPM_ID_GROUP VALUES(1,'G','sales','organisation',NULL);
INSERT INTO JBPM_ID_GROUP VALUES(2,'G','manager','security-role',NULL);
INSERT INTO JBPM_ID_GROUP VALUES(3,'G','hr','organisation',NULL);
INSERT INTO JBPM_ID_GROUP VALUES(4,'G','admin','security-role',NULL);
INSERT INTO JBPM_ID_GROUP VALUES(5,'G','user','security-role',NULL);
INSERT INTO JBPM_ID_MEMBERSHIP VALUES(1,'M',NULL,NULL,2,2);
INSERT INTO JBPM_ID_MEMBERSHIP VALUES(2,'M',NULL,NULL,2,4);
INSERT INTO JBPM_ID_MEMBERSHIP VALUES(3,'M',NULL,NULL,3,4);
INSERT INTO JBPM_ID_MEMBERSHIP VALUES(4,'M',NULL,NULL,2,5);
INSERT INTO JBPM_ID_MEMBERSHIP VALUES(5,'M',NULL,NULL,1,5);
INSERT INTO JBPM_ID_MEMBERSHIP VALUES(6,'M',NULL,NULL,4,3);
INSERT INTO JBPM_ID_MEMBERSHIP VALUES(7,'M',NULL,NULL,4,5);
INSERT INTO JBPM_ID_MEMBERSHIP VALUES(8,'M',NULL,NULL,3,5);
INSERT INTO JBPM_ID_MEMBERSHIP VALUES(9,'M',NULL,NULL,3,3);
INSERT INTO JBPM_ID_MEMBERSHIP VALUES(10,'M',NULL,NULL,2,3);
INSERT INTO JBPM_ID_MEMBERSHIP VALUES(11,'M',NULL,'boss',2,1);
INSERT INTO JBPM_ID_MEMBERSHIP VALUES(12,'M',NULL,NULL,1,1);

Tuesday, January 6, 2009

Seam-Gen and the TestNG plugin

Here's an interesting heads up to running SeamTest classes inside Eclipse.

I was having some problems getting my tests, extending SeamTest, to run with the Eclipse TestNG plugin. I found this post on seamframework.org which states,

"the Eclipse Run dialog to start the TestNG test will only be viable if you have a Seam Web Project created from JBoss Tools"

I used Seam-Gen instead of JBoss Tools for my project. I ran the tests from ant and they worked.

Monday, January 5, 2009

Seam 2.1.0 RefCard from Dzone

DZone has a refcard for Seam 2.1.0. Registration is required for download.

I've found these things to be useful.

Friday, January 2, 2009

SeamTest and Eclipse TestNG plugin

I encountered a small problem running a new SeamTest with Eclipse' TestNG plugin. The error was :

DEBUG [main] (KernelFactory.java:86) - Starting JBoss Kernel construction...
DEBUG [main] (KernelFactory.java:112) - Completed JBoss Kernel construction. Duration: 381 milliseconds
FAILED CONFIGURATION: @BeforeSuite startSeam
org.jboss.deployers.spi.DeploymentException: Unable to find bootstrap file: conf/bootstrap-beans.xml in classpath
at org.jboss.embedded.Bootstrap.bootstrap(Bootstrap.java:181)
at org.jboss.embedded.Bootstrap.bootstrap(Bootstrap.java:195)
at org.jboss.seam.mock.EmbeddedBootstrap.startAndDeployResources(EmbeddedBootstrap.java:11)
at org.jboss.seam.mock.AbstractSeamTest.startJbossEmbeddedIfNecessary(AbstractSeamTest.java:1025)
at org.jboss.seam.mock.AbstractSeamTest.startSeam(AbstractSeamTest.java:916)
at org.jboss.seam.mock.SeamTest.startSeam(SeamTest.java:58)
... Removed 15 stack frames
The solution is pretty simple.

Open up the run configuration (the arrow next to the run button and choose "Run Configurations...")
The most recently run test should be highlighted. If not select it.
Choose the "Classpath" tab in the right side of the pane.
Click "User Entries" which should be in the center pane.
Click "Advanced' -> "Add Folders" -> OK and navigate to the "bootstrap" folder.
Click "Add Jars" and navigate to the "lib/test" folder and add all three jars.




Ok.