Seam is an excellent framework. Hopefully having its' model implemented as part of the JEE spec will push adoption!
Showing posts with label JBoss Seam. Show all posts
Showing posts with label JBoss Seam. Show all posts
Thursday, November 19, 2009
Infoq Interview with Gavin King about Weld anc CDI
Infoq has a nice interview with Gavin King about Weld and CDI.
Thursday, July 16, 2009
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 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, 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.
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.
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 :
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.
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.
Thursday, December 4, 2008
Seam Tip Number 5
If you ever copy and paste a project directory be sure to change the seam-gen.properties file.
I got a new MacBook Pro. I copied my Eclipse workspaces over of course.
I made some changes to the entities in a project. I then opened a terminal and ran "seam generate-ui." I got a FileNotFound exception in build.xml line 1154 . Something was still pointing to the C:/ drive.
Inside the root Eclipse project directory there is a seam-gen.properties file. Changing that fixes anything.
I got a new MacBook Pro. I copied my Eclipse workspaces over of course.
I made some changes to the entities in a project. I then opened a terminal and ran "seam generate-ui." I got a FileNotFound exception in build.xml line 1154 . Something was still pointing to the C:/ drive.
Inside the root Eclipse project directory there is a seam-gen.properties file. Changing that fixes anything.
Wednesday, November 12, 2008
Seam-gen and Oracle Express
I installed Oracle Express. I created a user, "local," with the creative password, "local." I created a project with seam-gen. I created an entity object and annotated the id column with :
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@Column(name = "id", unique = true, nullable = false)
private Long id;
On deploy I saw in the logs :
09:42:14,281 INFO [SchemaExport] exporting generated schema to database
09:42:14,609 ERROR [SchemaExport] Unsuccessful: create table TABLE_NAME (id number(19,0) not null unique, name varchar2(30) not null, description varchar2(200) not null, inputChannel varchar2(100) not null, outputChannel varchar2(100) not null, parser varchar2(100), primary key (id))
09:42:14,609 ERROR [SchemaExport] ORA-02261: such unique or primary key already exists in the tableThe message, "such unique or primary key already exists in the table," led me to believe that the table existed. However, I couldn't see it using the Oracle web interface. Or SQL Developer. Or MyEclipse.
So I ran the statement in the web interface. Same error.
The problem turned out to be that the statement was creating the id twice. First with, "id number(19,0) not null unique," and second with, "primary key (id)."
I changed the syntax, and it worked. As for the annotations, I removed the "Column" annotation :
@Column(name = "id", unique = true, nullable = false)When I redeployed it worked fine.
The working annotation was :
@Id
@SequenceGenerator(name = "TABLE_NAME_SEQUENCE_GENERATOR", sequenceName = "TABLE_NAME_SEQUENCE")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "TABLE_NAME_SEQUENCE_GENERATOR")
private Long id;
Thursday, February 28, 2008
Hibernate reverse engineering and "yes_no" columns
Since attending JBossWorld Orlando, I've been playing with the JBoss Developer Studio. I've had some problems with reverse generation of my entities, and so I thought I'd post some of the solutions.
My database uses logical deletes ("Y" and "N".) The generated entities, which were typed as Boolean's choked on insert.
I haven't had much luck yet customizing the generation from the JBoss Developer Studio menu , and so I've been using the Hibernate Tools for Eclipse to generate my entities into a separate project, ModelProject, and then copying them into a seam project.
My plan was to use Seam tools to generate the crud ui from the project. However, right clicking the project and choosing "New -> Seam Generate Entities" and then selecting "Use existing entities" didn't do anything.
I started over and did the following :
ran seam-gen from the command line and created a new project, SeamProject
imported the resulting project into Eclipse
copied the reverse-engineered entities from ModelProject into SeamProject
ran "seam generate-ui" from the command line
This worked beautifully. The only hitch was I kept getting a vague error from DB2/400 when I tried to create a new entity, "[SQL0545] INSERT or UPDATE not allowed by CHECK constraint."
I checked all the constraints and after a few failed attempts determined that I wasn't violating any foreign keys. There were only a couple of not null fields one of which was the logical delete column. I had entered the translation I wanted into the hibernate.reveng.xml file (or at least I thought I had), but there was no annotation for "yes_no." I simply added @Type(type="yes_no") to the field, and everything worked.
My database uses logical deletes ("Y" and "N".) The generated entities, which were typed as Boolean's choked on insert.
I haven't had much luck yet customizing the generation from the JBoss Developer Studio menu , and so I've been using the Hibernate Tools for Eclipse to generate my entities into a separate project, ModelProject, and then copying them into a seam project.
My plan was to use Seam tools to generate the crud ui from the project. However, right clicking the project and choosing "New -> Seam Generate Entities" and then selecting "Use existing entities" didn't do anything.
I started over and did the following :
ran seam-gen from the command line and created a new project, SeamProject
imported the resulting project into Eclipse
copied the reverse-engineered entities from ModelProject into SeamProject
ran "seam generate-ui" from the command line
This worked beautifully. The only hitch was I kept getting a vague error from DB2/400 when I tried to create a new entity, "[SQL0545] INSERT or UPDATE not allowed by CHECK constraint."
I checked all the constraints and after a few failed attempts determined that I wasn't violating any foreign keys. There were only a couple of not null fields one of which was the logical delete column. I had entered the translation I wanted into the hibernate.reveng.xml file (or at least I thought I had), but there was no annotation for "yes_no." I simply added @Type(type="yes_no") to the field, and everything worked.
Blogged with Flock
Friday, February 15, 2008
JBoss World Orlando - Friday
EJB3, Seam, JSF, and RichFaces on JBoss 4.2.0 was the first session I attended. It was a case study of easycredit a German loan system. I've found the case studies useful.
The second session I attended was a 90 minute JBoss Developer Studio workshop. I had already installed the JBoss Tools project into Eclipse so I was glancingly familiar with it; however, I've used seam-gen for the projects I've been working on and hadn't made use of the Developer Studio tooling. Reverse engineering a domain model is stupidly simple.
Agile Development Using JBoss Seam was the third session I attended. Daniel Hinojosa was the speaker, and he had some cool tips on using Groovy for unit testing that I want to check out. He also showed off some stuff that I didn't know Hudson could do.
Testing JSF Applications which was an intro to JSFUnit by Stan Silvert was another session that I really liked, meaning I will start using JSFUnit next week. The executive summary is that resulting from his hatred of Mock objects, Stan created a JSF testing framework that works inside the the container without all the overhead of Cactus.
The second session I attended was a 90 minute JBoss Developer Studio workshop. I had already installed the JBoss Tools project into Eclipse so I was glancingly familiar with it; however, I've used seam-gen for the projects I've been working on and hadn't made use of the Developer Studio tooling. Reverse engineering a domain model is stupidly simple.
Agile Development Using JBoss Seam was the third session I attended. Daniel Hinojosa was the speaker, and he had some cool tips on using Groovy for unit testing that I want to check out. He also showed off some stuff that I didn't know Hudson could do.
Testing JSF Applications which was an intro to JSFUnit by Stan Silvert was another session that I really liked, meaning I will start using JSFUnit next week. The executive summary is that resulting from his hatred of Mock objects, Stan created a JSF testing framework that works inside the the container without all the overhead of Cactus.
Wednesday, February 13, 2008
JBoss World Orlando - Wednesday
I'm at JBossWorld Orlando. We got the usual t-shirt and bag, but the 1G flash drive was definitely the best schwag I've picked up (I didn't take a single pen during the vendor meet and greet!)
I checked out the jBPM session, "A Lightweight Approach to Business Processes With JBoss jBPM", first. I would've liked more practical use information, but the overview of the jBPM platform, which is how Tom Bayens described it, was interesting.
The next session on "Seam, SEAM, AS, EJB3, Hibernate, AJAX4JSF, RichFaces, and Facelets", was given by four guys from Big Lots. It was an excellent talk. I don't know how much presenting they do, but they traded off easily and kept the talk moving really well. It didn't hurt that their case study was very relevant to the project I'm working on.
I checked out the jBPM session, "A Lightweight Approach to Business Processes With JBoss jBPM", first. I would've liked more practical use information, but the overview of the jBPM platform, which is how Tom Bayens described it, was interesting.
The next session on "Seam, SEAM, AS, EJB3, Hibernate, AJAX4JSF, RichFaces, and Facelets", was given by four guys from Big Lots. It was an excellent talk. I don't know how much presenting they do, but they traded off easily and kept the talk moving really well. It didn't hurt that their case study was very relevant to the project I'm working on.
Monday, November 19, 2007
Seam Tip Number 4
Seam Tip Number 4 : @In(required = false) pitfall
In retrospect this is really obvious, but a member variable annotated with @In will be overwritten in subsequent invocations of a Stateful Session Bean even with a "required = false" on the annotation.
I had assumed that the "required = false" would prevent the variable from being injected if it wasn't present, but that isn't the case.
In retrospect this is really obvious, but a member variable annotated with @In will be overwritten in subsequent invocations of a Stateful Session Bean even with a "required = false" on the annotation.
I had assumed that the "required = false" would prevent the variable from being injected if it wasn't present, but that isn't the case.
Blogged with Flock
Tuesday, October 30, 2007
Seam Tip Number 3
Seam Tip Number 3
This isn't so much a tip, but a "gotcha" to avoid.
Make sure that you have an <h:messages /> tag in your page and that it does not have "globalOnly" set to "true."
I spent a lot of time wondering my my method wasn't getting called when the problem was a not null value being trapped.
This isn't so much a tip, but a "gotcha" to avoid.
Make sure that you have an <h:messages /> tag in your page and that it does not have "globalOnly" set to "true."
I spent a lot of time wondering my my method wasn't getting called when the problem was a not null value being trapped.
Blogged with Flock
Wednesday, October 24, 2007
Seam Tip Number 2
Seam Tip Number 2
Keep insert statements inside the import.sql file on the same line.
One of the coolest things about developing in Seam is the "create-drop" setting for data.
If you create your project with seam-gen and choose "y" for the prompt, "Do you want to drop and recreate the database tables and data in import.sql each time you deploy?" there will be three files, import-dev.sql, import-test.sql and import-prod.sql. The data in these files will be used to populate tables generated from your entities. You can of course do this manually, but I want to be brief.
I mocked up some data and redeployed, but I wasn't seeing anything when I hit the page. Watching the log files after restarting the server showed an sql error on import which turned out to be the line break. I was using Eclipse to edit the file so I found that odd, but stranger things have of course happened. I removed the line breaks and everything worked.
Keep insert statements inside the import.sql file on the same line.
One of the coolest things about developing in Seam is the "create-drop" setting for data.
If you create your project with seam-gen and choose "y" for the prompt, "Do you want to drop and recreate the database tables and data in import.sql each time you deploy?" there will be three files, import-dev.sql, import-test.sql and import-prod.sql. The data in these files will be used to populate tables generated from your entities. You can of course do this manually, but I want to be brief.
I mocked up some data and redeployed, but I wasn't seeing anything when I hit the page. Watching the log files after restarting the server showed an sql error on import which turned out to be the line break. I was using Eclipse to edit the file so I found that odd, but stranger things have of course happened. I removed the line breaks and everything worked.
Blogged with Flock
Tuesday, October 23, 2007
Seam Tip Number 1
Seam Tip Number 1
Seam-gen saves your defaults in the build.properties (Ant of course) file inside the [Seam dist]/seam-gen folder.
If like me you have accidentally typed the wrong directory for your project workspace or the wrong directory for your db driver jar file, simply edit the build.properties and the defaults will change.
Seam-gen is a cool part of JBoss Seam. From the Seam docs,
"This is the easy way to get your feet wet with Seam, and gives you some ammunition for next time you find yourself trapped in an elevator with one of those tedious Ruby guys ranting about how great and wonderful his new toy is for building totally trivial applications that put things in databases."
Seam-gen saves your defaults in the build.properties (Ant of course) file inside the [Seam dist]/seam-gen folder.
If like me you have accidentally typed the wrong directory for your project workspace or the wrong directory for your db driver jar file, simply edit the build.properties and the defaults will change.
Seam-gen is a cool part of JBoss Seam. From the Seam docs,
"This is the easy way to get your feet wet with Seam, and gives you some ammunition for next time you find yourself trapped in an elevator with one of those tedious Ruby guys ranting about how great and wonderful his new toy is for building totally trivial applications that put things in databases."
Blogged with Flock
Friday, October 19, 2007
Seam Lifecycle
I've been playing with JBoss' Seam for a brief while now. I've used Struts for years so I'm completely familiar with its' action based lifecycle. I have considerably less experience with JSF. Knowing a framework's lifecycle is definitely useful, and I wanted a diagram of Seam's.
This article from IBM Developerworks has a gif diagram that nicely outlines Seam's enhancements to the JSF lifecycle. I printed it out and tacked it onto my cube.
This article from IBM Developerworks has a gif diagram that nicely outlines Seam's enhancements to the JSF lifecycle. I printed it out and tacked it onto my cube.
Blogged with Flock
Wednesday, October 10, 2007
Seam-gen and TestNG problems
I created a project using Seam-gen, taking the database defaults (I wanted hsqldb for development anyway.)
First thing I wrote a test for the Manager/Action class that I was starting with. I also added a testng.xml to the src/test folder. I was using Eclipse so I right clicked on the build.xml's test target and ran it. Nothing.
The testng.xml file wasn't get copied to the test-build directory so I updated the build.xml withe the following :
Right clicking and running the TestNG plugin didn't do anything though. I opened the Run dialog (Run -> Open Run Dialog) and updated the classpath of the TestNG test to include the lib/test folder and ran the test from there. I got a different but no better result. (The stack trace is pasted below in the possibly vain belief that someone may stumble onto this posting while Googling the same problem)
javax.persistence.PersistenceException: org.hibernate.HibernateException: The chosen transaction strategy requires access to the JTA TransactionManager
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:737)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:121)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60)
I found this entry on JBoss' Forums which suggested using a non-jta-data-source in the persistence-test.xml. I updated my persistence-test.xml to the following (changes in bold) :
<?xml version="1.0" encoding="UTF-8"?>
<!-- Persistence deployment descriptor for tests -->
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="project_name" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>java:/DefaultDS</non-jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.show_sql" value="true"/>
<property name="jboss.entity.manager.factory.jndi.name" value="java:/project_nameEntityManagerFactory"/>
</properties>
</persistence-unit>
</persistence>
That did the trick; although, it doesn't appear that my test data is getting loaded. I'll blog that solution later.
First thing I wrote a test for the Manager/Action class that I was starting with. I also added a testng.xml to the src/test folder. I was using Eclipse so I right clicked on the build.xml's test target and ran it. Nothing.
The testng.xml file wasn't get copied to the test-build directory so I updated the build.xml withe the following :
- test target - changed line 315 to read <xmlfileset dir="${test.dir}" includes="testng.xml" /> instead of <xmlfileset dir="${test.dir}" includes="*Test.xml" />
- copytestclasses target - added <include name="*.xml" /> in the last copy statement so that the testng.xml file was copied from classes/test directory along with the class files
- copytestclasses target - removed "if='eclipse.running'" from the target. I don't know why, but the files weren't copied at all with this qualifier even though I was running out of Eclipse.
Right clicking and running the TestNG plugin didn't do anything though. I opened the Run dialog (Run -> Open Run Dialog) and updated the classpath of the TestNG test to include the lib/test folder and ran the test from there. I got a different but no better result. (The stack trace is pasted below in the possibly vain belief that someone may stumble onto this posting while Googling the same problem)
javax.persistence.PersistenceException: org.hibernate.HibernateException: The chosen transaction strategy requires access to the JTA TransactionManager
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:737)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:121)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60)
I found this entry on JBoss' Forums which suggested using a non-jta-data-source in the persistence-test.xml. I updated my persistence-test.xml to the following (changes in bold) :
<?xml version="1.0" encoding="UTF-8"?>
<!-- Persistence deployment descriptor for tests -->
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="project_name" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>java:/DefaultDS</non-jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.show_sql" value="true"/>
<property name="jboss.entity.manager.factory.jndi.name" value="java:/project_nameEntityManagerFactory"/>
</properties>
</persistence-unit>
</persistence>
That did the trick; although, it doesn't appear that my test data is getting loaded. I'll blog that solution later.
Blogged with Flock
Tuesday, October 9, 2007
Seam and TestNG and a missing rar file
Generated a new project with seam-gen.
Had a problem with the build.xml's "test" task. I got the error "You need to specify at least one testng.xml or one class"
I downloaded last night's snapshot from JBoss. (On a side note, I've started using Hudson after seeing it used by JBoss, and its very nice. I like it more than Continuum and CruiseControl.) Same error.
I added a testng.xml file to src/test directory.
I changed buildxml :
added "<include name="**/*.class"/>" to line 282
added "<copy tofile="${test.dir}/testng.xml" file="${src.test.dir}/testng.xml" overwrite="true"/>" to line 296.
changed line 320 (324 after adding the above) to "<xmlfileset dir="${test.dir}" includes="testng.xml" />"
The test ran, which was good; however, there were errors in the output.
"Error parsing meta data jboss-local-jdbc.rar"
Looking through the output I noticed that there was an io.FileNotFound for "C:\Documents%20%and%20%Settings." The actual file was referenced correctly in several of the other lines, but I decided to start over with seam-gen and put the folder directly on the C drive with no spaces.
It worked.
The moral : put my Eclipse workspaces on the C drive.
Had a problem with the build.xml's "test" task. I got the error "You need to specify at least one testng.xml or one class"
I downloaded last night's snapshot from JBoss. (On a side note, I've started using Hudson after seeing it used by JBoss, and its very nice. I like it more than Continuum and CruiseControl.) Same error.
I added a testng.xml file to src/test directory.
I changed buildxml :
added "<include name="**/*.class"/>" to line 282
added "<copy tofile="${test.dir}/testng.xml" file="${src.test.dir}/testng.xml" overwrite="true"/>" to line 296.
changed line 320 (324 after adding the above) to "<xmlfileset dir="${test.dir}" includes="testng.xml" />"
The test ran, which was good; however, there were errors in the output.
"Error parsing meta data jboss-local-jdbc.rar"
Looking through the output I noticed that there was an io.FileNotFound for "C:\Documents%20%and%20%Settings." The actual file was referenced correctly in several of the other lines, but I decided to start over with seam-gen and put the folder directly on the C drive with no spaces.
It worked.
The moral : put my Eclipse workspaces on the C drive.
Blogged with Flock
Monday, September 17, 2007
Seam, Enums and Select Boxes
While building a form I wanted the option elements inside a select to reflect the values of an Enum that I had.
I tried giving an @Name annotation to the Enum, which didn't work. This post on the JBoss forums explained that Enums can't be instantiated and therefore can't be used as a Seam component. I felt sort of dumb for trying that and decided to implement the suggested solution.
I built the piece I was working on from the "stateful" example from Michael Yuan's book, Jboss Seam : Power and Simplicity Beyond Java EE (Amazon link). My form was on "main.xhtml" and was submitting to "ManagerAction" which implemented "Manager" interface. The Enum I wanted for the select was "ServiceTicketStatus."
I added the following to my ManagerAction class,
@Factory("serviceTicketStatuses")
public ServiceTicketStatus[] getServiceTicketStatuses()
{
return ServiceTicketStatus.values();
}
and this to the Manager interface,
public ServiceTicketStatus[] getServiceTicketStatuses();
and this to the form in main.xhtml,
<h:selectOneMenu id="searchStatus" value="#{manager.statusSearch}" >
<f:selectItem itemValue="" itemLabel="Please Select" />
<s:selectItems value="#{serviceTicketStatuses}" var="statuses" />
</h:selectOneMenu>
It worked as advertised.
I tried giving an @Name annotation to the Enum, which didn't work. This post on the JBoss forums explained that Enums can't be instantiated and therefore can't be used as a Seam component. I felt sort of dumb for trying that and decided to implement the suggested solution.
I built the piece I was working on from the "stateful" example from Michael Yuan's book, Jboss Seam : Power and Simplicity Beyond Java EE (Amazon link). My form was on "main.xhtml" and was submitting to "ManagerAction" which implemented "Manager" interface. The Enum I wanted for the select was "ServiceTicketStatus."
I added the following to my ManagerAction class,
@Factory("serviceTicketStatuses")
public ServiceTicketStatus[] getServiceTicketStatuses()
{
return ServiceTicketStatus.values();
}
and this to the Manager interface,
public ServiceTicketStatus[] getServiceTicketStatuses();
and this to the form in main.xhtml,
<h:selectOneMenu id="searchStatus" value="#{manager.statusSearch}" >
<f:selectItem itemValue="" itemLabel="Please Select" />
<s:selectItems value="#{serviceTicketStatuses}" var="statuses" />
</h:selectOneMenu>
It worked as advertised.
Blogged with Flock
Wednesday, September 12, 2007
Another cool thing about JBoss Seam : The s:selectItems tag
I've been using JBoss Seam and reading JBoss Seam : Power and Simplicity Beyond Java EE (Amazon link). I've been working through the examples from Michael Yuan's site and tweaking the "Stateful" example into something resembling my current project.
I just came across the Seam JSF Controls. The s:selectItems tag is really nice. It converts a List of Objects, in my case a List<String> into a List<SelectItem>.
The more I use Seam the more impressed I am with the way it addresses the headaches of JSF and web development.
I just came across the Seam JSF Controls. The s:selectItems tag is really nice. It converts a List of Objects, in my case a List<String> into a List<SelectItem>.
The more I use Seam the more impressed I am with the way it addresses the headaches of JSF and web development.
Blogged with Flock
Subscribe to:
Posts (Atom)