Showing posts with label maven. Show all posts
Showing posts with label maven. Show all posts

Tuesday, 29 April 2014

Netbeans: There and back again - a tale of frustration, anger and returning to grace

(previously titled: Bye Eclipse the preventor of development, hello Netbeans...)

As always this is mainly for my future self as reference, as I don't seemed to have learned from the same experience that I had previously:(

Don't try to manually add dependencies to the tomcat classpath.

I lost the battle against eclipse + tomcat/tomee + maven

The fact that it works to add your main war dependency to the classpath with the maven library this time, does not mean it will work if you add more. I found that eclipse get's completely confused and this causes problems for things that insist that you may only have one copy of any class in your classpath, eg. slf4j, openejb's faces implementation etc.


Anyways, I'm fed up, fueclipse ┌∩┐(◣_◢)┌∩┐  

Until now I didn't really want to switch to netbeans because it doesn't support my favourite version control system (bazaar) and limited lombok support and I didn't really want to re-learn things/qwirks I spent years learning in eclipse like keyboard shortcuts, configuration, classpath settings etc.
Anyways eclipse makes me so mad sometimes and I think the camel's back has finally been broken. I tried to switch previously but had trouble getting my stuff to work quickly, I think I'm more patient/desperate this time..

Some stuff I've figured out with Netbeans so far - i.e a cryptic Netbeans guide for ex-Eclipse-users (please vote on the bugs I link to!):

  • you can use a use the eclipse keyboard shortcut profile, so for now I don't have to re-learn shortcuts and keep some productivity.
  • maven multi module support works beautifully
  • mvn install happens when you do a netbeans build!
  • Reload POM, seems to be needed sometimes like the "Maven -> update project"
  • adding a tomee server is simple http://tomee.apache.org/tomee-and-netbeans.html
  • you can collapse all, by right-clicking in the white space next to  the file tree (eclipse has a handy everpresent button for that)
  • Netbeans seem a lot snappier than eclipse!
  • Committing with Git works better in Netbeans, because it allows you to modify the files while you are typing your commit message (eg. for fixing typos). I would have like to not manually click to see every file, maybe a open all button would help. I still love the qbazaar/bazaar-explorer's commit gui which give you the whole list of changes in one huge scrollable panel - saves a lot of clicks and navigations. For now I just look at the colordiff in the commandline to approximate that behaviour :(
    • One thing I miss with the Git commit ui in Netbeans, is to be able to push at the same time - Eclipse has a button `Commit and Push`. 
    • It would also have been nice to get some floating/fading notification if the commit/push went well. If you don't watch the statusbar and spot the progressbar disappear you have no indication if it worked..
  • Console scrolling works more intuitively and seemlessly: if you scrolled to the bottom it will keep on scrolling as more output comes out, but if you scroll up it stops auto-scrolling. In eclipse you have to click a checkbox to make the choice between auto-scrolling and not.
  • Project groups seems to work nicely and you can use the Cool Editor Actions plugin to quickly switch between them.
  • Dragging panels around seems to work a bit better than in Eclipse. Eg. sticking an editor in the console tabsheet.
  • It does have bazaar plugin ?! It looks similar to the eclipse qbazaar plugin - it is a thin wrapper around qt frontends for the bazaar commands - very nice!
  • Running more than one instance. I figured out you have to specify a --userdir for the second one and that it can't be the same as your main user dir. I tried to symlink it but that didn't work, so I made a little script that copies it:
    VERSION=8.0
    A=$HOME/.netbeans/${VERSION}
    B=${A}_B
    rm -rf ${B}
    cp -a ${A} ${B}
    /opt/netbeans-${VERSION}/bin/netbeans --userdir ${B} &
    
  • ALT+3 to copy project or file path
Things I miss so far (maybe I'm missing something):
  • Control clicking on a maven artifact reference in a pom file would jump to the relevant pom file.
  • File manager doesn't remember recent locations :( so every time I look for my tomee server, or projects I need to navigate from home :( It would have been better to use the native linux file chooser. My current workaround is the Quick File Chooser - plugin : "file chooser optimized for keyboard-only users. Performs GNU Readline-style filename completion when you press Tab. Shows available completions in a list for quick reference, similar to Emacs. Also includes a persistent list of recently used directories for extra speed." (it works in Netbeans8 if you download v7.4 manually and install it)
  • After installing some plugins and making some configurations it refused start up again. Then I accidentally purged ~/.netbeans :( and it worked again. This happend again so I logged a bug and figured out what triggers it. Back to work now finally, damnit!
  • Searching in the output console is a bit frustrating but CTRL+F and the CTRL+N seems to work ok now.
  • There is no auto-closing of editors. In eclipse you can tell it to close old editors after you have a certain amount open. It gets messy if netbeans keeps like every single file you clicked open - I go through hundreds. I found sort of a workaround in Window->Documents where you can order by last used, then select the bottom bunch and then close them in one go..
  • mylyn is also missed - it helps you focus by hiding some of the project clutter a bit from you while you are working.. Project groups seem to be the closest workable alternative.
  • I like eclipse's run infrastructure better. eg. you can easily run whatever you ran previously (but there are some run shortcuts, so I may get used to it) Found it : ALT+r p
  • Junit test compare in eclipse you can show you a nice diff when assertEquals(String,String) fails..
  • In eclipse you can click on stack trace elements in the console and it would open the file, in netbeans it seems to be a manual proccess :(
  • Test Runner chops off exceptions :(
  • Java Stack Trace console (where you can past any stacktrace and get links)
  • Efficient dependency hierarchy to figure out maven dependency hell

http://www.wikivs.com/wiki/Eclipse_vs_Netbeans

I've been with eclipse since at least 2006.
Living with eclipse is like living with an abusive husband, sure you get a black eye from time to time, but you are so dependant that you end up staying. It caused me numerous sleepless nights and missed deadlines :( not to mention it literally driving me insane. t(-.-)

Back to Eclipse!

After that whole laborious move the development cycle in netbeans was just insanely long for my project setup (a couple of layers of war dependenices/overlays which each need to be built for deploying every small change). I bit the bullet and figured out how to do proper OpenEJB and TomEE embedding so I don't need WTP anymore with its' nasty classpath idiosyncrasies.

Saturday, 1 September 2012

fun with self-signed certs and java and maven again :S

I've been deploying maven artifacts all day and suddenly it stopped working (later I realized that I happen to apt-get update java in between).

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project browser-cookies: Failed to deploy artifacts/metadata: No connector available to access repository xxx.xxx of type default using the available factories WagonRepositoryConnectorFactory -> [Help 1]

[ERROR] For more information about the errors and possible solutions, please read the following articles:

[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

So after googling a bit I though wagon might be the problem again so I added the following to my pom:


...


org.apache.maven.wagon
wagon-ssh
2.2

...


But my problems didn't go away:(
Then I realized that since I just upgraded my java, that my company maven repo's certificate may not be installed anymore..

I tried to install it with the normal way:
java -jar import-ssl.jar server [https://YOURSERVERURL] 

java -jar import-ssl.jar server maven.example.com $JAVA_HOME/jre/lib/security/cacerts

But this resulted in the following error:

Loading KeyStore /usr/lib/jvm/java-7-oracle/jre/lib/security/cacerts...
Setting up SSL...
Opening connection to https://maven.example.com:443...
java.net.UnknownHostException: https://maven.example.com

at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
at java.net.Socket.connect(Socket.java:579)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:618)
at sun.security.ssl.SSLSocketImpl.(SSLSocketImpl.java:407)
at sun.security.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:88)
at com.sonatype.component.ssl.imprt.ImportServerCertificates.doImport(ImportServerCertificates.java:154)
at com.sonatype.component.ssl.imprt.ImportServerCertificates.run(ImportServerCertificates.java:66)
at com.sonatype.component.ssl.imprt.Main.main(Main.java:51)

I was puzzled because this worked fine with java-6-openjdk-amd64,  but not with java-7-oracle. For kicks I tried the IP address and guess what it worked!!!!

java -jar import-ssl.jar server 192.0.2.1 $JAVA_HOME/jre/lib/security/cacerts 

Loading KeyStore /usr/lib/jvm/java-7-oracle/jre/lib/security/cacerts...
Setting up SSL...
Opening connection to 192.0.2.1:443...
Starting SSL handshake...

Some SSL certificates appear to be missing. Adding missing certificates...

Server sent 1 certificate(s):
 1 Subject CN=maven.example.com, O=MyCompany, L=Johannesburg, ST=Gauteng, C=ZA
   Issuer  CN=maven.example.com, O=MyCompany, L=Johannesburg, ST=Gauteng, C=ZA

Added certificate to keystore using alias: '192.0.2.1'


But alas I could still not deploy :'(
I threw my toys out of my cot, took a deep breath, bathed my 19 month old son, came back and realized what my problem was:

I put a nasty safety mechanism into my corporate poms to prevent us from deploying stuff to the wrong repository (eg. deploying private source files to a public repository!). Anyways I now added a BIG glaring message for myself for when this happens again:

 NB!


 NB! REMEMBER TO SPECIFY -Dew.deploy-public TO DEPLOY THIS PUBLICLY OR -Dew.deploy-private TO DEPLOY THIS PRIVATELY


Don't say I didn't try to tell you!!!!?! 

Tuesday, 15 March 2011

maven 3 - its time

After getting some weird issues with my builds I tried out maven 3 again to see if it magically fixed things. It didn't fix that issue, but I'm quite impressed with maven 3 so far:
  • It can build subprojects in parallel which gives me quite a performance boost.
  • The other big thing for me is that "lots of bugs are fixed now", which is a bit hard to measure right away but will probably ensure a more enjoyable experience.
Richard Kolb asked for some benchmarks so here they are. It is probably a lot more beneficial for my 17 module project to build it in parallel.
  • It was done on my Intel i7 Q749 @ 1.73GHz with SSD
  • The second run of each hopefully avoids delays while "checking for updates" 
  • Java version: 1.6.0_24
  • OS name: "linux" version: "2.6.35-27-generic" arch: "amd64" Family: "unix"
  • It includes a GWT widget compile 
  • Ran mvn clean install in the maven reactor with 17 subprojects
== Apache Maven 2.2.1 (rdebian-4) ==
4 minutes 15 seconds
3 minutes 18 seconds
3 minutes 22 seconds

== Apache Maven 3.0.3 (r1075438; 2011-02-28 19:31:09+0200) (serial) ==
3:34.911s
3:14.637s

=== apache-maven-3.0.3/bin/mvn -T6 clean install (using 6 threads) ===
2:23.427s
2:23.224s

=== apache-maven-3.0.3/bin/mvn -T6 clean install (using 8 threads) ===
2:22.137s
2:19.600s

so I save about a minute (or 28%) when runing thing in parallel

I had to upgrade some maven plugins to allow things to be treadsafe with the help of this page:
https://cwiki.apache.org/MAVEN/parallel-builds-in-maven-3.html

Saturday, 2 October 2010

eclipse + tomcat + maven pain again

Banging my head against the wall again today
because my app just does not want to start up :'(
Between eclipse, tomcat and maven my classpath was messed up, getting all sorts of exceptions like NoClassDefFoundError etc.

Finally I figured out again that for each project involved you have to check "Maven Dependencies"
in the "Order and Export" tab of the Java build path settings.
Then when you tell tomcat to include these projects,
it will actually include it and its dependencies.

I'm not sure how this got lost because my app used to work. Maybe when I imported the same project in
another workspace that got reset :(

Monday, 23 August 2010

Archiva gives the maven site plugin an invalid site_en.xml

I got the following nasty error since friday:

$ mvn -U -e -X clean site
...
[DEBUG] Reading site descriptor from /home/amanica/.m2/repository/za/co/my_company/super-pom/1.0.3/super-pom-1.0.3-site_en.xml
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] SiteToolException: Error parsing site descriptor

Expected root element 'project' but found 'html' (position: START_TAG seen ... Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\r\n<html>... @8:7)
[INFO] ------------------------------------------------------------------------
[DEBUG] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: SiteToolException: Error parsing site descriptor
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
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:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: SiteToolException: Error parsing site descriptor
at org.apache.maven.plugins.site.AbstractSiteRenderingMojo.createSiteRenderingContext(AbstractSiteRenderingMojo.java:232)
at org.apache.maven.plugins.site.SiteMojo.renderLocale(SiteMojo.java:137)
at org.apache.maven.plugins.site.SiteMojo.execute(SiteMojo.java:120)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
Caused by: org.apache.maven.doxia.tools.SiteToolException: Error parsing site descriptor
at org.apache.maven.doxia.tools.DefaultSiteTool.readDecorationModel(DefaultSiteTool.java:1298)
at org.apache.maven.doxia.tools.DefaultSiteTool.getDecorationModel(DefaultSiteTool.java:1252)
at org.apache.maven.doxia.tools.DefaultSiteTool.getDecorationModel(DefaultSiteTool.java:1260)
at org.apache.maven.doxia.tools.DefaultSiteTool.getDecorationModel(DefaultSiteTool.java:511)
at org.apache.maven.plugins.site.AbstractSiteRenderingMojo.createSiteRenderingContext(AbstractSiteRenderingMojo.java:225)
... 21 more
Caused by: org.codehaus.plexus.util.xml.pull.XmlPullParserException: Expected root element 'project' but found 'html' (position: START_TAG seen ... Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\r\n<html>... @8:7)
at org.apache.maven.doxia.site.decoration.io.xpp3.DecorationXpp3Reader.parseDecorationModel(DecorationXpp3Reader.java:619)
at org.apache.maven.doxia.site.decoration.io.xpp3.DecorationXpp3Reader.read(DecorationXpp3Reader.java:1387)
at org.apache.maven.doxia.site.decoration.io.xpp3.DecorationXpp3Reader.read(DecorationXpp3Reader.java:1401)
at org.apache.maven.doxia.tools.DefaultSiteTool.readDecorationModel(DefaultSiteTool.java:1294)

It turns out that maven looks for a site_en.xml for my parent project on archiva and archiva seems to generate a return file which is actually an error message.
The maven site plugin then tries to parse it and fails horribly :(
I worked around this by just adding the following content to src/site/site_en.xml in my parent project and everything was well!

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/DECORATION/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd">
<body>
</body>
</project>


I got really frustrated by this cryptic error message. I wanted to bash my head against the table and throw my laptop against the wall. Instead I cried out to God and not long after that I figured it out. Some would say thats just coincidence, I say: "Thank God", "Praise God" and "Why didn't I ask You sooner?".

Wednesday, 7 April 2010

Vaadin addons and maven and eclipse.

Afters struggling for almost 3 days, I finally got some vaadin add-ons working for me.
No matter what I did, I could not get maven to compile the custom widget sets :'-(

Wanting to do it with maven I started off with the instructions at http://dev.vaadin.com/wiki/Articles/MavenIntegration.

I got error messages like:
Failed to load the widgetset: 
/my-project/VAADIN/widgetsets/my.company.my.project.widgetset.My_ProjectWidgetset/
my.company.my.project.widgetset.My_ProjectWidgetset.nocache.js?1270654337749

Building it with the eclipse plugin said:
Compiling widgetset my.company.my.project.widgetset.My_ProjectWidgetset
Updating GWT module description file...
07 Apr 2010 5:46:09 PM com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer getAvailableWidgetSets
INFO: Widgetsets found from classpath:
com.vaadin.terminal.gwt.DefaultWidgetSet in jar:file:/stf/opt/maven/repository/com/vaadin/vaadin/6.2.6/vaadin-6.2.6.jar!/
my.company.my.project.widgetset.My_ProjectWidgetset in file:/stf/prj/My_Project/src/main/resources

Done.
Starting GWT compiler
Widgetset compilation completed

But when running the webapp, I got:
Widgetset does not contain implementation for org.vaadin.browsercookies.BrowserCookies. Check its @ClientWidget mapping, widgetsets GWT module descrioption file and re-compile your widgetset. Unrendered UIDL:

org.vaadin.browsercookies.BrowserCookies(NO CLIENT IMPLEMENTATION FOUND) id=PID7

variables
Widgetset does not contain implementation for com.github.wolfie.meteorcursor.MeteorCursor. Check its @ClientWidget mapping, widgetsets GWT module descrioption file and re-compile your widgetset. Unrendered UIDL:

com.github.wolfie.meteorcursor.MeteorCursor(NO CLIENT IMPLEMENTATION FOUND) id=PID8 gr=75 th=10 pl=1000 di=2 im=theme://images/logo.png fr=0 disabled=false

I thought that it was building, since the addons that I wanted to use got detected.
Little did I know that it was not actually building!
Building with maven said:
[INFO] Updating widgetset my.company.my.project.widgetset.My_ProjectWidgetset
[INFO] establishing classpath list (scope = compile)
[ERROR] 07 Apr 2010 5:38:31 PM com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer getAvailableWidgetSets
[ERROR] INFO: Widgetsets found from classpath:
[ERROR] com.github.wolfie.meteorcursor.MeteorcursorWidgetset in jar:file:/stf/opt/maven/repository/com/github/wolfie/meteorcursor/1.0.0/meteorcursor-1.0.0.jar!/
[ERROR] org.vaadin.browsercookies.widgetset.BrowserCookiesApplicationWidgetset in jar:file:/stf/opt/maven/repository/com/vaadin/sami/browsercookies/1.0.2/browsercookies-1.0.2.jar!/
[ERROR] com.vaadin.terminal.gwt.DefaultWidgetSet in jar:file:/stf/opt/maven/repository/com/vaadin/vaadin/6.2.6/vaadin-6.2.6.jar!/
[ERROR] my.company.my.project.widgetset.My_ProjectWidgetset in file:/stf/prj/My_Project/src/main/resources
[ERROR]


The reason it was not building was because I was trying to use the stable version of the gwt-maven-plugin: 1.2
After reading this forum post again, I tried 1.3-SNAPSHOT of this plugin; and all my troubles went away.


So now I build it with maven, and it should give output like this:
[INFO] [gwt:compile {execution: default}]                                                                                                                    
[INFO] using GWT jars from project dependencies : 1.7.1
[INFO] auto discovered modules [za.co.enerweb.ebr.gui.vaadin.widgetset.Ebr_vaadin_webWidgetset]
[INFO] establishing classpath list (scope = compile)
[INFO] establishing classpath list (scope = compile)
[INFO] establishing classpath list (scope = compile)
[INFO] establishing classpath list (scope = compile)
[INFO] establishing classpath list (scope = compile)
[INFO] establishing classpath list (scope = compile)
[INFO] Compiling module my.company.my.project.widgetset.My_ProjectWidgetset
[INFO] Scanning for additional dependencies: jar:file:/stf/opt/maven/repository/com/vaadin/vaadin/6.2.6/vaadin-6.2.6.jar!/com/vaadin/terminal/gwt/client/DefaultWidgetSet.java
[INFO] Computing all possible rebind results for 'com.vaadin.terminal.gwt.client.WidgetMap'
[INFO] Rebinding com.vaadin.terminal.gwt.client.WidgetMap
[INFO] Invoking
[INFO] Detecting Vaadin components in classpath to generate WidgetMapImpl.java ...
[INFO] Widget set will contain implementations for following components:
[INFO] com.github.wolfie.meteorcursor.MeteorCursor
[INFO] com.vaadin.ui.AbsoluteLayout
[INFO] com.vaadin.ui.Accordion
[INFO] com.vaadin.ui.Button
[INFO] com.vaadin.ui.CheckBox
[INFO] com.vaadin.ui.ComboBox
[INFO] com.vaadin.ui.CssLayout
[INFO] com.vaadin.ui.CustomComponent
[INFO] com.vaadin.ui.CustomLayout
[INFO] com.vaadin.ui.DateField
[INFO] com.vaadin.ui.Embedded
[INFO] com.vaadin.ui.Form
[INFO] com.vaadin.ui.FormLayout
[INFO] com.vaadin.ui.GridLayout
[INFO] com.vaadin.ui.HorizontalLayout
[INFO] com.vaadin.ui.Label
[INFO] com.vaadin.ui.Link
[INFO] com.vaadin.ui.ListSelect
[INFO] com.vaadin.ui.MenuBar
[INFO] com.vaadin.ui.NativeButton
[INFO] com.vaadin.ui.NativeSelect
[INFO] com.vaadin.ui.OptionGroup
[INFO] com.vaadin.ui.OrderedLayout
[INFO] com.vaadin.ui.Panel
[INFO] com.vaadin.ui.PopupView
[INFO] com.vaadin.ui.ProgressIndicator
[INFO] com.vaadin.ui.RichTextArea
[INFO] com.vaadin.ui.Select
[INFO] com.vaadin.ui.Slider
[INFO] com.vaadin.ui.SplitPanel
[INFO] com.vaadin.ui.TabSheet
[INFO] com.vaadin.ui.Table
[INFO] com.vaadin.ui.TextField
[INFO] com.vaadin.ui.Tree
[INFO] com.vaadin.ui.TwinColSelect
[INFO] com.vaadin.ui.Upload
[INFO] com.vaadin.ui.UriFragmentUtility
[INFO] com.vaadin.ui.VerticalLayout
[INFO] com.vaadin.ui.Window
[INFO] org.vaadin.browsercookies.BrowserCookies
[INFO] Done. (2seconds)
[INFO] Compiling 1 permutations
[INFO] Permutation compile succeeded
[INFO] Linking into /stf/prj/My_Project/src/main/webapp/VAADIN/widgetsets
[INFO] Link succeeded
[INFO] Compilation succeeded -- 40.785s


To be able to serve my webapp using tomcat launched from eclipse I need to compile the GWT stuff into src/main/webapp . So unlike the instructions I mention at the top of this post, some key parts of my pom is as follows:
  <properties>
<vaadin-widgets-dir>src/main/webapp/VAADIN/widgetsets</vaadin-widgets-dir>
</properties>
<build>
<plugins>
<!-- Compiles your custom GWT components with the GWT compiler -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.3-SNAPSHOT</version>
<executions>
<execution>
<configuration>
<webappDirectory>${vaadin-widgets-dir}</webappDirectory>
<extraJvmArgs> -Dgwt.style=PRETTY -Xmx512M -Xss1024k</extraJvmArgs>
</configuration>
<goals>
<goal>resources</goal>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Updates Vaadin 6.2 widgetset definitions based on project dependencies -->
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<goals>
<goal>update-widgetset</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
<fileset>
<!-- also delete the generated vaadin web content -->
<directory>${vaadin-widgets-dir}</directory>
</fileset>
</filesets>
</configuration>
</plugin>
</plugins>
</build>

Tuesday, 29 September 2009

Publish failed using Ant publisher - duplicate entry

I got so frustrated this week with the eclipse + maven + glasfish combo.
It kept on refusing to publish my web project to glassfish with some lame excuse:
Publish failed using Ant publisher
unable to assemble module
duplicate entry: some.file

In any case I figured out a workaround (lucky guess):
Right-click on your project -> Maven -> Disable Workspace Resolution

Voi la. I can work again and debug my web apps.

Thursday, 23 July 2009

get rid of glassfish master password

I've set up a webapp to be able to create-domain, deploy, test and delete-domain using the maven-glassfish-plugin.
The problem is that it insists on setting the master password.
Now its not possible to set the master password being used by the eclipse JavaEE glassfish plugin.
So when you try to start it from eclipse it asks for the master
password in the background:
Please enter the master password
After a while it times out and it says:
Server GlassFish at localhost failed to start.

I found out that you can tell glassfish to not ask the password anymore by doing:
asadmin change-master-password --savemasterpassword domain1
http://forums.java.net/jive/message.jspa?messageID=341172

However, I changed my admin password maven uses,
to be the real defaut master password: "changeit",
and now eclipse can start maven-created domains without me
having to --savemasterpassword
http://blogs.sun.com/alexismp/entry/what_is_a_glassfish_master

Monday, 29 June 2009

eclipse galileo maven plugin

I tried to install the maven plugin from http://m2eclipse.sonatype.org/update/ on the new eclipse today, but I got the following error:

Error unzipping org.maven.ide.components.maven_embedder Unexpected end of ZLIB input stream

Then I tried the dev version from http://m2eclipse.sonatype.org/update-dev/ and that seemed to work fine.

[edit 2009-07-15] Since then the dev version started spewing out null pointer exceptions when using the maven-assembly-plugin,
so I reverted back to the stable version and that seems to work now... Early adopters burn their fingers...

Friday, 13 February 2009

Eclipse Dynamic Web Project + Maven2 = initial pain

Eclipse 3.4 ganymede gave me a VERY frustrated day yet again :(
I spent most of the day convincing it to to install the m2eclipse plugin.
It kept on telling me:
No repository found containing: org.maven.ide.components.dependency_tree/osgi.bundle
So after updating all my eclipse plugins and also using the Maven Integration for Eclipse Dev Update Site and restarting Eclipse, it finally decided it will install.
(You almost want to swear at it and call it M$ Eclipse. Ok it wasn't that bad.)

Next I came to a painful catch 22: I want a Dynamic Web Project so that my code can be automatically deployed on my Glassfish server. But I also want it to be a Maven project for all the maven goodness, without changing the standard maven code layout.

I googled for hours but I only found my worst fear to be true: The only way to do it is to make it a web project, changing its structure to be in the maven layout and then activate it as a maven project. I improved on this site's methods a bit by doing some configs up front and thus avoiding to mess with them later. Here are my steps as good as I remembered:
  1. (I created a reference maven web project in eclipse, but it turned out that I didn't actually need it)
  2. Create a new Eclipse Dynamic Web Project. Don't click finish, click [next].
  3. Set the 'Content Directory' to 'src/main/webapp' and the 'Java Source Directory' to 'src/main/java'. Now you can click [finish].
  4. Right click on the project -> Maven -> Enable Dependancy Management.
  5. Set the packaging to war, [finish].
  6. You can delete the build folder now since maven already started to use the target folder.
  7. If you need the other standard maven source and target folers, you can add them manually or directly in .classpath:
    <classpathentry kind="src" path="src/main/resources">
    <classpathentry kind="src" output="target/test-classes"
    path="src/test/java">
    <classpathentry kind="src" output="target/test-classes"
    path="src/test/resources">



  8. From there I just had to set maven to use Java6 in pom.xml:
    <build>
    <pluginmanagement>
    <plugins>
    <plugin>
    <groupid>org.apache.maven.plugins</groupid>
    <artifactid>maven-compiler-plugin</artifactid>
    <configuration>
    <source>1.6</source>
    <target>1.6</target>
    </configuration>
    </plugin>
    </plugins>
    </pluginmanagement>
    </build>

  9. Right click on the project -> Maven -> Update Dependancies.
  10. I removed the following from .settings/org.eclipse.wst.common.component:
    <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/>
    <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/resources"/>
  11. Then I could run maven tasks and also deploy it to my glassfish server (already set up to be managed by eclipse the normal JavaEE way (run as -> run on server))
sweetness! I love Eclipse+JavaEE+maven again.
I think the WTP or whatever does the new 'Dynamic Web Project' wizard would do well to have a checkbox which can setup the web project in the maven sturcture for you.
tomorrow (aka later today) I have to do the real work of actually putting an application into this empty shell.

goodnight

Friday, 1 August 2008

maven repository manager

After struggling for a couple of days, I finally managed to set up a local maven repository behind a proxy.
  • I first tried nexus, but it's configuration is very buggy and despite the fact that it don't work for me, it keeps on forgetting my settings if I open on it again.
  • Then I tried artifactory, ant it too looked promising, but for some reason I could not get it to download stuff through a proxy either. To be fair after I figured out that my real problem as that my maven clean plugin was broken, I managed to get artifactory working through a proxy (but I think I like archiva the most at the moment).
  • Then I tried apache archiva, which looked even more promising since it actually had the concept of a network proxy on its configuration screen. After a lot of googling, I found out that its a known (and fixed but un-released) bug in archiva 1.1. (http://jira.codehaus.org/browse/MRM-884). So I installed version 1.0.2 and my downloads began to work!!
The only problem was that as part of testing if this works, I deleted the org directory in my maven repository (as described in the nexus section of the maven difinitve guide).
This caused my `mvn clean` to stop working:
"org.apache.maven.plugin.version.PluginVersionNotFoundException: The plugin 'org.apache.maven.plugins:maven-clean-plugin' does not exist or no valid version could be found"
After a bit of googling I found out that deleting my repository (~/.m2/repository) fixes this problem!
(http://www.mail-archive.com/users@maven.apache.org/msg68288.html)

A last note is that the different repository mangers are surprisingly similar as to how they work and configured. It must be something to with where they all come from.