Tag Archives: jee

Automatically start JavaDB process in Eclipse

In my previous post I’ve mentioned that NetBeans IDE starts a background process with Derby every time when it is required during Glassfish startup. You can have a similar thing in Eclipse. After installing Glassfish AS Adapter for Eclipse, go to Window>Preferences>GlassFish preferences (or type “glass” in filter box), check “Start the JavaDB database process when Starting GlassFish server” and voila!


This is a quite old post, it was not published earlier because I wanted to investigate this topic a bit more. Hope that you will find this useful (and not very misleading).

SEVERE: Exception while deploying the app [arquillian-example] : 
  Sniffers with type [connector] and type [ejb] should not claim the archive at the same time. 
  Please check the packaging of your archive [/..../arquillian-example]

Maybe some of you’ve experienced this kind of error while working with Glassfish. I had this one when started to work with new project (Maven driven, JEE 6 app with Arquillian/JUnit and Glassfish embedded). Project structure was taken from my previous developments, I’ve added literally one class. First deployment and this quite cryptic error message stopped my work.

While looking for some hints, I’ve learned that sniffers are analyzing archive submitted to application server. If you take a look into domain.xml in your Glassfish instance you will find that applications (applications/application) can have various sniffers associated with them e.g.

 <application context-root="/test" location="${com.sun.aas.instanceRootURI}/eclipseApps/test/"
           name="test" directory-deployed="true" object-type="user">
    <property name="appLocation" value="${com.sun.aas.instanceRootURI}/eclipseApps/test/"></property>
    <property name="keepSessions" value="true"></property>
    <property name="defaultAppName" value="test"></property>
    <module name="test">
       <engine sniffer="jpa"></engine>
       <engine sniffer="security"></engine>
       <engine sniffer="web"></engine>
       <engine sniffer="weld"></engine>

This app has JPA/security/web and Weld. From the error message it seems that some sniffers cannot be assigned together with others.

To find out what is going on, I took a look at what is placed in the final WAR. I discovered that Maven is adding glassfish-emb-all.jar to WEB-INF/lib. Quick look at pom.xml and it looks that dependency to glassfish-emb was not properly scoped (lack of <scope>test</scope>). Without glassfish-emb in war everything went smoothly, app was properly deployed.

Oh, well just a stupid mistake in pom. But wait. What is especially interesting in this issue, it seems that sniffers assigment is done only once. This means that if you deploy your app with correct dependencies and afterwards you will accidentaly include glassfish-emb-all into your WAR everything will be fine. At least till the next change of application server which might happen when moving to production web server.

24 easy steps to JEE 6 development with Eclipse

As some of you probably know I have a privilege to teach Java related stuff at Poznań University of Technology. During the lab sessions which I am leading we were going through configuration of Eclipse IDE to work with JEE 6. I am using Eclipse since I started to write in Java, some things are obvious for me. We wanted to work with Glassfish, Apache Maven and Subversion which are quite common tools, so it should be quite simple to force Eclipse to work with this setup. Let’s start.

  1. Download Eclipse IDE for Java EE Developers
  2. Unpack and run
  3. Now, I will have to install m2eclipse, I would like to use Eclipse Marketplace because it does not require knowledge about update sites for plugins. So, I choose “Help” and than “Eclipse Marketplace”.
  4. I am searching for m2eclipse… ok, there is something with Install button here [click].
  5. Accept the license agreement
  6. Confirm that I want to install unsigned jars
  7. Installation was sucessful, Eclipse is asking if I want to restart IDE – “ok, if you have to”.
  8. I know that I need also m2eclipse-extras for integration with Eclipse Web Tools Platform.
  9. I am choosing Eclipse Marketplace and searching for m2eclipse-extras – without luck.
  10. It seems that I need an update site for this. From Help menu I am choosing “Install new software”
  11. Starting to work with new Update Site for m2eclipse-extras
  12. I need to choose out of 4 bundles from that site. I cannot click “select all” because I don’t have Sublipse plugin installed, anyway who is using SVN nowadays? 😉
  13. After choosing right bundles it is time to accept license agreement
  14. Once again I need to confirm that I want to install unsigned jars
  15. Installation was sucessful, Eclipse is asking if I want to restart IDE – “ok, if you have to”.
  16. It is high time to import my project into workspace, choose File>Import>Import existing Maven project (but who knows maybe “Import existing project” would also work ;-))
  17. At this stage m2eclipse shows warning that my Eclipse is running on JRE not JDK and this may cause some problems
  18. To correct this I have to edit eclipse.ini and add “-vm” parameter with path to JDK (in separate lines – but everyone knows how .ini file works)
  19. Ok, now it is time for Glassfish, I choose Window>Preferences>Server Runtime and click on Add button
  20. There is no Glassfish here, so I choose to download additional server adapters.
  21. Ok, now I can choose out of four different Glassfish types (finally I will choose appropriate).
  22. During creation of new server runtime, I have to remember to point to glassfish-3.1/glassfish, (base glassfish-3.1 directory is not enough).
  23. After creation of new adapter, it should be possible to run imported application using Glassfish. It should be but…
  24. Eclipse says that in order to run Glassfish I need JDK – what the heck, I’ve just changed my eclipse.ini. Someone told me that I have to define new “Installed JRE” which is pointing to my JDK installation.

Only 24 easy steps – great!  😉

I’m not a huge fan of NetBeans but please take a look how NetBeans IDE deals with this issue.

  1. Download NetBeans (with Glassfish)
  2. Run NetBeans and Glassfish installer
  3. Run NetBeans IDE
  4. From File menu choose Open project
  5. From Tools menu choose Servers, ensure that Glassfish is in place. (This step is unfortunately necessary :(, without this NetBeans claims that there is no Glassfish defined – you just have to open dialog window, nothing more).
  6. Run Project

NetBeans will even launch Derby network server on its own if you use this DB in your project. I do not have nothing against Eclipse puzzles but it seems that it simply works!

I know why all this have to be done with Eclipse, but the question is who will bother with this if he can just launch Visual Studio 😉. In fact it is just a matter of reasonable defaults, is it really so hard? Maybe JEE is too new to get proper support in Eclipse?