-
1. Re: Maven2 example application for Seam2
marx3 Jan 2, 2008 3:27 AM (in response to cory_prowse)Very good idea! We need something which works. Unfortunatelly I can't help because i'm not good with Maven
-
2. Re: Maven2 example application for Seam2
pmuir Jan 2, 2008 5:21 AM (in response to cory_prowse)Would it require the new version of JBoss Embedded to be released first?
Highly unlikely, there is nothing wrong with Seam or Embedded here, just the way Maven sets up the classpath when running tests.Hopefully those working on Seam and/or JBossEmbedded can review this before their respective projects make their next releases.
Its not likely to happen for the next release, but perhaps 2.0.2 -
3. Re: Maven2 example application for Seam2
cory_prowse Jan 3, 2008 1:31 AM (in response to cory_prowse)"pete.muir@jboss.org" wrote:
there is nothing wrong with Seam or Embedded here, just the way Maven sets up the classpath when running tests.
Aha!
The problem then appears to be with the thirdparty-all-beta*.jar file as it contains a separate copy of javassist.
Adding an exclusion for javassist to jboss-seam and hibernate-entitymanager in the Ejb's POM as follows:<dependency> <groupId>org.jboss.seam</groupId> <artifactId>jboss-seam</artifactId> <exclusions> <exclusion> <groupId>jboss</groupId> <artifactId>javassist</artifactId> </exclusion> </exclusions> </dependency> ... <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <exclusions> <exclusion> <groupId>jboss</groupId> <artifactId>javassist</artifactId> </exclusion> </exclusions> </dependency>
causes the tests to now fail with:ERROR [AbstractKernelController] Error installing to Start: name=java:comp state=Create javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247) at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284) at javax.naming.InitialContext.lookup(InitialContext.java:351) at org.jboss.naming.JavaCompInitializer.start(JavaCompInitializer.java:83)
So it appears the dependencies need to be properly and fully speced out in the appropriate poms.
The use of these "*-all-*.jar" files appear the be the culprit.
Namely:hibernate-all-*.jar
jboss-embedded-all-*.jar
thirdparty-all-*.jar
These are not very useful in their current form for Maven.
Unless someone knows of a way to exclude certain dependencies in the test scope within maven? (I can't see a way) -
4. Re: Maven2 example application for Seam2
marx3 Jan 3, 2008 5:30 AM (in response to cory_prowse)I've tied to build your example but no luck:
[INFO] [enforcer:enforce {execution: enforce-java}] [WARNING] Rule 1: org.apache.maven.plugins.enforcer.RequireJavaVersion failed with message: Detected JDK Version: 1.6.0-3 is not in the allowed range [1.5,1.6).
-
5. Re: Maven2 example application for Seam2
marx3 Jan 3, 2008 5:34 AM (in response to cory_prowse)i've change
[1.5,1.6)
to
[1.5,1.6.0-3]
and it went ahead -
6. Re: Maven2 example application for Seam2
cory_prowse Jan 3, 2008 5:42 AM (in response to cory_prowse)I don't believe Embedded JBoss supports Java6?
Also Postgres JDBC doesn't support Java6 so I have that enforcement in place for both of these reasons (the 1st one should apply to everyone) -
7. Re: Maven2 example application for Seam2
pmuir Jan 3, 2008 5:46 AM (in response to cory_prowse)http://in.relation.to/Bloggers/EmbeddedJBossUpdate tells you how to run Embedded on Java 1.6
-
8. Re: Maven2 example application for Seam2
marx3 Jan 3, 2008 5:48 AM (in response to cory_prowse)everything compiled ok (1.6 is backwards compatible), i think you have mistake in right parenthese:
is: [1.5,1.6)
probably should be:[1.5,1.6]
There seems to be problem with local repository. I think I need to create one, but don't know how.Downloading: http://repository.jboss.org/maven2/org/richfaces/ui/richfaces-ui/3.1.2.SP1/richfaces-ui-3.1.2.SP1.jar 1485K downloaded Downloading: http://repository.jboss.org/maven2/concurrent/concurrent/1.3.4/concurrent-1.3.4.jar Downloading: http://snapshots.jboss.org/maven2/concurrent/concurrent/1.3.4/concurrent-1.3.4.jar Downloading: http://repo1.maven.org/maven2/concurrent/concurrent/1.3.4/concurrent-1.3.4.jar 184K downloaded Downloading: http://repository.jboss.org/maven2/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1.jar 98K downloaded [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] Failed to resolve artifact. Missing: ---------- 1) au.prowse.cory.seammavenexample:seamMavenExampleEjbs:ejb-client:client:1.0-SNAPSHOT Try downloading the file manually from the project website. Then, install it using the command: mvn install:install-file -DgroupId=au.prowse.cory.seammavenexample -DartifactId=seamMavenExampleEjbs -Dversion=1.0-SNAPSHOT -Dclassifier=client -Dpackaging=ejb-client -Dfile=/path/to/file Alternatively, if you host your own repository you can deploy the file there: mvn deploy:deploy-file -DgroupId=au.prowse.cory.seammavenexample -DartifactId=seamMavenExampleEjbs -Dversion=1.0-SNAPSHOT -Dclassifier=client -Dpackaging=ejb-client -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id] Path to dependency: 1) au.prowse.cory.seammavenexample:seamMavenExampleWar:war:1.0-SNAPSHOT 2) au.prowse.cory.seammavenexample:seamMavenExampleEjbs:ejb-client:client:1.0-SNAPSHOT ---------- 1 required artifact is missing. for artifact: au.prowse.cory.seammavenexample:seamMavenExampleWar:war:1.0-SNAPSHOT from the specified remote repositories: snapshots.jboss.org (http://snapshots.jboss.org/maven2), central (http://repo1.maven.org/maven2), repository.jboss.org (http://repository.jboss.org/maven2)
-
9. Re: Maven2 example application for Seam2
cory_prowse Jan 3, 2008 6:15 AM (in response to cory_prowse)This is just a cut down version of a much larger project of which I use Postgres with Glassfish for deployment testing (as Derby database doesn't work with jBPM). So I deliberately force that check that Java 1.6 is not run, meaning the right bracket is correct for a less than and not equal to condition.
Also cos this currently doesn't work, I wanted to ensure people were running Java5 which is more widely supported than Java6 to rule out any issues there.
I could be wrong there though :)
Checkout this link for more info:
http://docs.codehaus.org/display/MAVEN/Dependency+Mediation+and+Conflict+Resolution#DependencyMediationandConflictResolution-DependencyVersionRanges
As for your depenendency error, it's cos the project has not successfully compiled that project and so has not produced that artifact.
You need to first run it without tests:mvn -Dmaven.test.skip=true clean install
That will ensure all projects are built and their artifacts available in your local repository. -
10. Re: Maven2 example application for Seam2
marx3 Jan 3, 2008 7:57 AM (in response to cory_prowse)Java6 can compile bytecode Java5 compatible, so I see no point in discriminating Java6. There should be an option to force that - I do that in Ant with
<property name="target" value="1.6"/> <property name="source" value="1.6"/> ... <javac classpathref="build.classpath" destdir="${jar.dir}" debug="${javac.debug}" deprecation="${javac.deprecation}" source="${source}" target="${target}" nowarn="on" encoding="UTF-8"> ...
Anyway with tests skipped your project has been built ok -
11. Re: Maven2 example application for Seam2
cory_prowse Jan 3, 2008 5:21 PM (in response to cory_prowse)Yup you are correct, and I have enabled the option to create Java5 bytecode in the parent pom.
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <!-- Java5 for portability - also Glassfish works only in Java5 for now --> <source>1.5</source> <target>1.5</target> <maxmem>1024m</maxmem> <optimize>true</optimize> </configuration> </plugin>
It still seems to be at the moment that the problem is those uberjars of "all" dependencies. Having the same class in more than one jar annoys the classloaders (cos they are not the same class then).
I could go through and create exclusions for all jars in those uberjars but then the final EAR for a production (or integration test) deployment would be without them as well. -
12. Re: Maven2 example application for Seam2
pmuir Jan 3, 2008 5:33 PM (in response to cory_prowse)Yes, I don't like the -all.jar s particularly, however I don't see a nice way around it (Seam's deps are different than those in the -all.jar)
However, this will all go away when we can target JBoss AS 5 with Seam (as this is what Embedded is based on, and so we can sync jar versions easily). This should be soon.
I don't know how to order the classpath with Maven (it's easy with ant) but you need to make sure the -all jars come before everything else when running tests. -
13. Re: Maven2 example application for Seam2
cory_prowse Jan 3, 2008 6:05 PM (in response to cory_prowse)"pete.muir@jboss.org" wrote:
I don't know how to order the classpath with Maven (it's easy with ant) but you need to make sure the -all jars come before everything else when running tests.
Pete you are a legend (and not the Will Smith variety, I haven't seen that movie yet).
Maven orders the classpath in the same order as specified in the pom, and with Maven 2.0.8 they have ensured that the test classpath is first as well (the reason I enforce Maven version 2.08+ in the pom).
So I reordered the classpath and voila!
The error I get is now back to the "NoInitialContextException" which I can now work on.
Are there any other classpath ordering things that I should be aware of? -
14. UPDATED Maven2 example application for Seam2
cory_prowse Jan 3, 2008 9:31 PM (in response to cory_prowse)Alrighty I have made good progress!
It works!
Sorta...
There seems to be a problem with either Embedded JBoss or Maven (most likely Maven).
As an aside, I had to roll back to Embedded JBoss beta2 as beta3 was failing with JMS related stuff.
The example application will fail to build, complaining about no default persistence unit in the deployment, which is due to the test classpath not including thesrc/test/resources/META-INF/persistence.xml
To make it work copy or move this file tosrc/main/resources/META-INF/persistence.xml
I'm confused why it isn't working as the META-INF directory in the test resources does contain another file that is picked up during the test by JBoss Embedded.
So it appears that Maven (or Embedded JBoss) is ignoring the persistence.xml file in the test resources!??
This is using Maven 2.0.8 which explicitly states in its release notes:MNG-3118 - Test-classes should come before classes in the classpath. This may slightly alter behavior of tests. The test-classes is now included first in the classpath to allow test resources to override normal runtime ones.
I do not want to use filters in Maven as this file should only be used in unit tests and not included in any packaged artifacts.
The updated example can be downloaded from here:
http://www.users.on.net/~cory_prowse/seamMavenExample-20080104.zip
I'm going to post the example app to the Maven users mailing list and see if anyone there knows what is going on.