Skip to main content

Posts

Accessing ejb3 session beans from remote java application

LMAppletserver is a great tool for communicating from java-applet to server, but it is also a great tool for remote calls over http to ejb3 session beans in general. Here's an example of using stateful session beans with lmappletserver: https://lmappletserver.svn.sourceforge.net/svnroot/lmappletserver/lmappletserver_core/src_tests/com/lightminds/appletserver/core/tests/SFSBTest.java This is a unit test class, which also contains result verification, but is also a good example of how to use stateful session beans. You can check out the entire project in netbeans from: https://lmappletserver.svn.sourceforge.net/svnroot/lmappletserver/lmappletserver_core In NetBeans 6.5, just right click on the project, and select "Test" to run the tests (including the Stateful session bean test). The test uses Apache OpenEJB and Jetty as http servlet container (running the rpc servlet).

Seam s:convertEntity + glassfish + toplink

.... doesn't go very well together, since Seam wants to access your entityManager, and would want it to be a Hibernate instance... This is a simple workaround, by replacing s:convertEntity with a custom tag that gives the same result. By remembering the entities displayed to the s:selectItems, using the value of entity.toString() (which is className + hashCode() (which should be unique).). You might want to tune it maybe not to use hashcode (in case of non uniqueness), and maybe access your entitymanager (toplink) - instead of storing entities in memory.. But in any case this is a good starting point: package com.petersalomonsen.jsf.persistence.EntityConverter import java.util.HashMap; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.convert.Converter; public class EntityConverter implements Converter { static HashMap<String,Object> entitiesToRemember = new HashMap<String,Object>(); public Object getAsObject(Fa...

entityManager.createQuery("Select e from "+MyEntity.class.getName()+" e") in glassfish

I've been using EJB3 with jboss for a long time - and I've got use to this way of writing my ejb3 persistence queries: entityManager.createQuery("Select e from "+MyEntity.class.getName()+" e") which is also convenient considering refactoring compared to "Select e from MyEntity e". But the EJB3 persistence spec says this: "Entities are designated in query strings by their entity names. The entity name is defined by the name element of the Entity annotation (or the entity-name XML descriptor element), and defaults to the unqualified name of the entity class. Entity names are scoped within the persistence unit and must be unique within the persistence unit." And glassfish complains about the fully qualified classnames - it just want the unqualified classname (without package information). According to the spec - glassfish seems more correct to me - but the hibernate/jboss way of using fqn seems better to me - so I wonder, which one is really...

LMAppletserver in Glassfish - invoking EJB3 session bean methods from your applet

The previous blog entry showed how to use LMAppletserver in a web archive (WAR) without any enterprise beans or enterprise app. It could also have been deployed to e.g. Tomcat where you don't have EJB3 session beans. In this example I'm showing how to call EJB3 session beans from your java applet using LMAppletserver. Download and start netbeans 6.0 (http://netbeans.org) Versioning -> Subversion -> Checkout Checkout the following URL: http://lmappletserver.svn.sourceforge.net/svnroot/lmappletserver/LMAppletServerEJB3 (no username or password) Right click on the newly opened LMAppletServerEJB3 project and select "Undeploy and Deploy" to deploy the project. When the server has started and everything is deployed then open this URL in your browser: http://localhost:8080/LMAppletServerEJB3-war/ The applet shows a message that is obtained by calling an EJB3 session bean method method on the server, using the RPC features of LMAppletserver. This is what happens in the ...

LMAppletserver in Glassfish

LMAppletserver is a toolkit for automatic deployment of java classes (or jars) to your browser, and an rpc library for easily calling methods on the server. The intention is to enable effective code reuse between the client and the server, and not have to repackage the classes for the client. Also a way of calling server methods - that is to give the feeling of coding "directly on the server". Download the example project from sourceforge.net: http://sourceforge.net/project/downloading.php?group_id=142974&use_mirror=osdn&filename=SimplestLMAppletserverProject.zip&2731151 unzip SimplestLMAppletserverProject.zip cd SimplestLMAppletserverProject ant To deploy the application to Glassfish: asadmin deploydir simplelmapp.war Open in your browser: http://localhost:8080/simplelmapp/ And see the hello world applet... The applet shows a message that is obtained by calling a business method on the server, using the RPC features of LMAppletserver. This is what happens in the ...

Notes on Glassfish exploded deploys vs. JBoss

While in Jboss 4.0.x I'm able to mix exploded and packaged modules in my .ear - Glassfish seems to require either fully exploded or fully packaged. E.g. if I have a packaged ejb module together with an exploded web module in an exploded .ear - this doesn't seem to work with Glassfish. Another thing is that when having exploded ejb and web (war) modules in glassfish the extension should be _jar and _war rather than .jar and .war - in JBoss dots or _ is irrelevant. What might be confusing is that the reference in application.xml to these modules is still done using dots. These are my initial experiences from trying to get the lmappletserver-addons-example (http://sourceforge.net/projects/lmappletserver) up and running with Glassfish. I've now managed to deploy it - but still there are to many errors to call it a successful deployment - will be back with more info as I make progress...