Re: How to embed a server into openejb standard alone server
On Jun 10, 2008, at 8:50 PM, xianzheng wrote: Hi all, I'm new to J2EE and OpenEJB. Just wondering, is there a way to embed an application server which is written in JAVA in openejb? I guess, I'll have to write a container to wrap it around? If so, is there a guide to write such thing? As my understanding, JCA can only allows ejbs to connect to other servers rather than listening connections? I have a very old server application i wrote, which complies a non- standard communication protocol. So i'm thinking whether i could embed it into openejb to listening to "old" request and benefit openejb's other cool features. Hi Joe, Depending on what you want to do exactly there are likely many ways to do it. It is possible to plug in new protocols into a standard OpenEJB install and support custom clients. It's very easy to drop something in that listens on a socket and does "stuff". OpenEJB will find it on startup and hook it up as it does the other protocols. The "stuff" is where all the detail lies. Reflectively invoking proxies on the server side by looking them up from the local global JNDI (LocalInitialContextFactory) is easy, whereas sending invocations directly into the EJB Containers like the EJBd protocol does is harder. Can show you how to do that if it sounds like a route you might want to take. (you basically implement a specific interface then include a special properties file in your jar and drop it into openejb, pretty easy) If you have your own "component container" it is possible to add new custom containers to a standard OpenEJB install. This is a bit more involved but not completely impossible. The advantage here is that any container can be invoked by any of the protocols plugged into OpenEJB. Sounds like you want more the first option where you can add a new protocol. There are definitely options. Couple rounds of "mutual data exchange" (aka discussion) and I'm sure we can find a good game plan :) -David
How to embed a server into openejb standard alone server
Hi all, I'm new to J2EE and OpenEJB. Just wondering, is there a way to embed an application server which is written in JAVA in openejb? I guess, I'll have to write a container to wrap it around? If so, is there a guide to write such thing? As my understanding, JCA can only allows ejbs to connect to other servers rather than listening connections? I have a very old server application i wrote, which complies a non-standard communication protocol. So i'm thinking whether i could embed it into openejb to listening to "old" request and benefit openejb's other cool features. Thanks a lok, Joe -- View this message in context: http://www.nabble.com/How-to-embed-a-server-into-openejb-standard-alone-server-tp17769556p17769556.html Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: OpenEJB.war outside webapps
The exception is caused when the listener fails to find the openejb.war file. I think the code is only scanning the webapps directory, but there may even be a bug in that for Tomcat 6. In the mean time, I added a System property "openejb.war" which we will use to locate the openejb.war file. You can find a build of the openejb.war, which contains this patch here: http://people.apache.org/~dain/openejb.war I also create issue OPENEJB-819 to track this bug. -dain On Jun 10, 2008, at 12:27 AM, uglything wrote: Hello Dain, Don't worry for the late reply, I'm not in a hurry :-) I hope that your client has come to better feelings now ;-) I get things to work by declaring the contexts in the Catalina/ localhost repository in the tomcat conf dir. My layout is as follow : MyProject/ +-- src/ |+-- main/ ||+-- java/ ||+-- resources/ ||+-- webapps/ ||+-- WEB-INF/ ||+-- web.xml |+-- test/ |+-- java/ |+-- resources/ +-- target/ |+-- MyProject-0.0.1-SNAPSHOT/ ||+-- META-INF/ (empty) ||+-- WEB-INF/ ||+-- classes/ ||+-- lib/ (No OpenEJB jars in here) ||+-- web.xml |+-- classes/ |+-- test-classes/ |+-- war/ |+-- MyProject.war +-- target-eclipse/ (Compilation directory for Eclipse) +-- runtime/ (directory that acts as catalina.base and openejb.base) +-- conf/ |+-- Catalina/ ||+-- localhost/ ||+-- openejb.xml ||+-- MyProject.xml |+-- context.xml |+-- logging.properties |+-- openejb.xml |+-- server.xml |+-- web.xml +-- logs/ (logs) +-- temp/ (acts as java.io.tmpdir) +-- txlog/ (logs) +-- webapps/ (empty, serves as appBase for the localhost host in server.xml) +-- work/ Here above, the contents of some important files: # Server.xml: I took the one in the tomcat install. I just added the OpenEJB listener and trimmed the comments. className="org.apache.openejb.tomcat.loader.OpenEJBListener" /> className="org.apache.catalina.mbeans.ServerLifecycleListener" /> className ="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> # # openejb.xml: well, nothing special. I copied the one created by a default installation # # MyProject.xml: Here again, nothing sexy. # # openejb.xml: I removed defaults and inserted a database for my project JdbcDriver : com.mysql.jdbc.Driver JdbcUrl : jdbc:mysql://localhost:3306/ccv?useUnicode=true UserName : ccvusr Password : ccvpwd JdbcDriver : com.mysql.jdbc.Driver JdbcUrl : jdbc:mysql://localhost:3306/ccv?useUnicode=true UserName : ccvusr Password : ccvpwd JtaManaged : false # # context.xml: Again, this is the original file took from a clean install of Tomcat 6 whith comments trimmed. WEB-INF/web.xml # This is the configuration I use to start the server in Eclipse : VM args: -Dcatalina.home="C:\apache-tomcat-6.0.14" -Dcatalina.base="." -Dopenejb.home="C:\apache-tomcat-6.0.14" -Dopenejb.base="." -Djava.io.tmpdir="temp" -Xmx128M -javaagent:"C:\apache-tomcat-6.0.14\lib\openejb-javaagent.jar" Main class: org.apache.catalina.startup.Bootstrap Program arguments: start Classpath: C:\apache-tomcat-6.0.14\bin\bootstrap.jar Working directory: MyProject/runtime/ When I start the server, I get the following exception : java.la
Re: Eclipse Multiple Projects and Missing persistence.xml
David Blevins wrote: > > > On Mar 30, 2008, at 8:29 PM, Chad and Doria Skinner wrote: >> I have a project I am working on and we have separated our business >> model from our business logic by placing them into different >> projects in eclipse. These projects are both jars that are placed in >> our ear file. When I try to run a test on one of our session beans >> in the EJB project I keep getting errors that it is missing the >> persistence.xml file that is in our BusinessLogic project. The code >> is compiling properly, but the tests will not run until I copy the >> persistence.xml into the EJB project. Does anyone know if having >> separate jars for the SessionBeans and entities is supported? > > I think there might be an issue with the module getting picked up if > it only contains a peristence.xml and nothing else. An alternate > technique to moving the persistence.xml into the BusinessLogic project > is to add an empty ejb-jar.xml file to the BusinessModel project > containing only "" > > That should tide you over till we can get this fixed. > > -David > > I am getting back to working on this and still have the same problem. My projects are configured as: websiteBusinessLogic - contains Entity Beans websiteEJB - contains my EJBs I have ejb-jar.xml files in the META-INF directories of both projects and my my persistence.xml file contains the following: 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";> jdbc/websitedb jdbc/unmanagedWebsitedb us.ks.k12.topeka.website.model.Alert us.ks.k12.topeka.website.model.Announcement us.ks.k12.topeka.website.model.Entry us.ks.k12.topeka.website.model.Job us.ks.k12.topeka.website.model.Location us.ks.k12.topeka.website.model.NewsEntry us.ks.k12.topeka.website.model.Preference us.ks.k12.topeka.website.model.Profile us.ks.k12.topeka.website.model.Tag us.ks.k12.topeka.website.model.TagGroup us.ks.k12.topeka.website.model.TagSearch my jUnit test: @Before public void setup() { try { Logger.getRootLogger().setLevel(Level.DEBUG); Properties p = new Properties(); p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory"); p.put("openejb.deployments.classpath.include", ".*seamTest/WebsiteBusinessModel/.*"); p.put("jdbc/websitedb", "new://Resource?type=DataSource"); p.put("jdbc/websitedb.JdbcUrl", "jdbc:mysql://localhost:3306/website"); p.put("jdbc/websitedb.JdbcDriver", "com.mysql.jdbc.Driver"); p.put("jdbc/websitedb.UserName","webuser"); p.put("jdbc/websitedb.Password","webpass"); p.put("jdbc/unmanagedWebsitedb", "new://Resource?type=DataSource"); p.put("jdbc/unmanagedWebsitedb.JdbcUrl", "jdbc:mysql://localhost:3306/website"); p.put("jdbc/unmanagedWebsitedb.JdbcDriver", "com.mysql.jdbc.Driver"); p.put("jdbc/unmanagedWebsitedb.UserName","webuser"); p.put("jdbc/unmanagedWebsitedb.Password","webpass"); p.put("jdbc/unmanagedWebsitedb.JtaManaged", "false"); p.put("jdbc/profileDB", "new://Resource?type=DataSource"); p.put("jdbc/profileDB.JdbcUrl", "jdbc:mysql://localhost:3306/website"); p.put("jdbc/profileDB.JdbcDriver", "com.mysql.jdbc.Driver"); p.put("jdbc/profileDB.UserName","webuser"); p.put("jdbc/profileDB.Password","webpass"); p.put("jdbc/profileDB.JtaManaged", "false"); p.put("myStatefulContainer", "new://Container?type=STATEFUL"); p.put("myStatefulContainer.PoolSize", "5"); p.put("myStatefulContainer.BulkPassivate", "1"); p.put("myStatelessContainer", "new://Container?type=STATELESS"); p.put("myStatelessContainer.PoolSize", "5"); p.put("myStatelessContainer.BulkPassivate", "1"); context = new InitialContext(p); } catch(NamingException e) { e.printStackTrace(); Assert.fail(e.getMessage()); } } @Test public void testProfileSynchronizer() throws Exception { ProfileSynchronizer lProfileSynchro
Re: Antwort: Re: Antwort: Re: Re: maven build of openEJB3 [Virus checked]
Excellent. I applied the patch and published a new snapshot. Let me know if you have any more problems, and thank you for the patch. -dain On Jun 10, 2008, at 12:44 AM, [EMAIL PROTECTED] wrote: Here is the source with my tiny change in bold face: -- package com.envoisolutions.sxc.jaxb.maven; import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.Arrays; import java.util.Map; import javax.xml.bind.JAXBException; import com.envoisolutions.sxc.jaxb.JAXBGenerator; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; /** * @goal generate * @description Generates SXC JaxB implementation * @phase process-classes * @requiresDependencyResolution runtime */ public class SxcJaxbPlugin extends AbstractMojo { /** * @parameter expression="${project}" * @required */ private MavenProject project; /** * Directory source files will be written. * * @parameter expression="${project.build.directory}/sxc" * @required */ private File sourceOutputDirectory; /** * Directory class files will be written. * * @parameter expression="${project.build.directory}/classes" * @required */ private File classesOutputDirectory; /** * @parameter * @required */ private String[] classes; /** * @parameter */ private Map properties; public void execute() throws MojoExecutionException { try { JAXBGenerator jaxbGenerator = new JAXBGenerator(); jaxbGenerator .setSourceOutputDirectory(sourceOutputDirectory.getAbsolutePath()); jaxbGenerator .setClassesOutputDirectory(classesOutputDirectory.getAbsolutePath()); jaxbGenerator.getClasses().addAll(Arrays.asList(classes)); if (properties != null) { jaxbGenerator.getProperties().putAll(properties); } // need to manually create the classloader since maven won't give me one String directory = project.getBuild().getOutputDirectory(); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); if (classLoader == null) classLoader = getClass().getClassLoader(); classLoader = new URLClassLoader(new URL[] {(new File(directory)).toURI().toURL()}, classLoader); jaxbGenerator.setClassLoader(classLoader); jaxbGenerator.generate(); } catch (JAXBException e) { throw new MojoExecutionException("Error generating JaxB parser: " + e.getMessage(), e); } catch (MalformedURLException e) { throw new MojoExecutionException("Invalid build outputDirectory " + project.getBuild().getOutputDirectory()); } } public File getSourceOutputDirectory() { return sourceOutputDirectory; } public void setSourceOutputDirectory(File sourceOutputDirectory) { this.sourceOutputDirectory = sourceOutputDirectory; } public File getClassesOutputDirectory() { return classesOutputDirectory; } public void setClassesOutputDirectory(File classesOutputDirectory) { this.classesOutputDirectory = classesOutputDirectory; } public String[] getClasses() { return classes; } public void setClasses(String[] classes) { this.classes = classes; } public Map getProperties() { return properties; } public void setProperties(Map properties) { this.properties = properties; } } -- The idea is that URI and URL are so close, but NOT identical. The difference is the characters allowed: toURI converts what is permissible in file names, to what is permissible in URL (e.g. converts blanks to %20..) mit freundlichen Grüßen/best regards Wolfgang Schrecker "Der Inhalt eines Begriffs nimmt ab, wenn sein Umfang zunimmt; wird dieser allumfassend, so muß der Inhalt ganz verloren gehen." from G. Frege: Die Grundlagen der Arithmetik S. 40 -- -- Atos Worldline Processing GmbH Hahnstrasse 25 60528 Frankfurt/Main Germany Phone: +49 69/6657-1176 mailto:[EMAIL PROTECTED] http://www.atosworldline.com Geschäftsführer: Erik Munk Koefoed Aufsichtsratsvorsitzender: Didier Dhennin Sitz der Gesellschaft: Frankfurt/Main Handelsregister: Frankfurt/Main HRB 40 417 Dain Sundstrom <[EMAIL PROTECTED]> An 09.06.2008 21:43 users@openejb.apache.org Kopie Bitte antworten Thema an
Re: DataSource configuration for production
We've spent some time today investigating what actually happens in the DataSource ... Not so easy since DBCP code is a little tricky ! We've observed that JDBC connections which are realeased from the pool by the Evictor are not physically closed : 1/ from the DataSource standpoint : the maximum size of the pool is never exceeded (numActive is always inferior to maxActive), 2/ but from the dataserver standpoint : the number of connections is always increasing (up to the maximum allowed by the server). We haven't identified the exact cause of this issue : for some unknown reason the DelegatingConnection.close() method consider the JDBC connection as already closed which is wrong. Next step tomorrow ... -- View this message in context: http://www.nabble.com/DataSource-configuration-for-production-tp17695975p17760106.html Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: DataSource configuration for production
On Jun 10, 2008, at 12:49 AM, jfjames wrote: Sorry David, but the MAVEN source jar is empty ... Looks like the maven-shade-plugin needs some bug fixing :) Oh well. The two svn commands I post should give all the required source. -David
Re: DataSource configuration for production
Sorry David, but the MAVEN source jar is empty ... -- View this message in context: http://www.nabble.com/DataSource-configuration-for-production-tp17695975p17749654.html Sent from the OpenEJB User mailing list archive at Nabble.com.
Antwort: Re: Antwort: Re: Re: maven build of openEJB3 [Virus checked]
Here is the source with my tiny change in bold face: -- package com.envoisolutions.sxc.jaxb.maven; import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.Arrays; import java.util.Map; import javax.xml.bind.JAXBException; import com.envoisolutions.sxc.jaxb.JAXBGenerator; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; /** * @goal generate * @description Generates SXC JaxB implementation * @phase process-classes * @requiresDependencyResolution runtime */ public class SxcJaxbPlugin extends AbstractMojo { /** * @parameter expression="${project}" * @required */ private MavenProject project; /** * Directory source files will be written. * * @parameter expression="${project.build.directory}/sxc" * @required */ private File sourceOutputDirectory; /** * Directory class files will be written. * * @parameter expression="${project.build.directory}/classes" * @required */ private File classesOutputDirectory; /** * @parameter * @required */ private String[] classes; /** * @parameter */ private Map properties; public void execute() throws MojoExecutionException { try { JAXBGenerator jaxbGenerator = new JAXBGenerator(); jaxbGenerator.setSourceOutputDirectory(sourceOutputDirectory.getAbsolutePath()); jaxbGenerator.setClassesOutputDirectory(classesOutputDirectory.getAbsolutePath()); jaxbGenerator.getClasses().addAll(Arrays.asList(classes)); if (properties != null) { jaxbGenerator.getProperties().putAll(properties); } // need to manually create the classloader since maven won't give me one String directory = project.getBuild().getOutputDirectory(); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); if (classLoader == null) classLoader = getClass().getClassLoader(); classLoader = new URLClassLoader(new URL[] {(new File(directory)).toURI().toURL()}, classLoader); jaxbGenerator.setClassLoader(classLoader); jaxbGenerator.generate(); } catch (JAXBException e) { throw new MojoExecutionException("Error generating JaxB parser: " + e.getMessage(), e); } catch (MalformedURLException e) { throw new MojoExecutionException("Invalid build outputDirectory " + project.getBuild().getOutputDirectory()); } } public File getSourceOutputDirectory() { return sourceOutputDirectory; } public void setSourceOutputDirectory(File sourceOutputDirectory) { this.sourceOutputDirectory = sourceOutputDirectory; } public File getClassesOutputDirectory() { return classesOutputDirectory; } public void setClassesOutputDirectory(File classesOutputDirectory) { this.classesOutputDirectory = classesOutputDirectory; } public String[] getClasses() { return classes; } public void setClasses(String[] classes) { this.classes = classes; } public Map getProperties() { return properties; } public void setProperties(Map properties) { this.properties = properties; } } -- The idea is that URI and URL are so close, but NOT identical. The difference is the characters allowed: toURI converts what is permissible in file names, to what is permissible in URL (e.g. converts blanks to %20..) mit freundlichen Grüßen/best regards Wolfgang Schrecker "Der Inhalt eines Begriffs nimmt ab, wenn sein Umfang zunimmt; wird dieser allumfassend, so muß der Inhalt ganz verloren gehen." from G. Frege: Die Grundlagen der Arithmetik S. 40 -- -- Atos Worldline Processing GmbH Hahnstrasse 25 60528 Frankfurt/Main Germany Phone: +49 69/6657-1176 mailto:[EMAIL PROTECTED] http://www.atosworldline.com Geschäftsführer: Erik Munk Koefoed Aufsichtsratsvorsitzender: Didier Dhennin Sitz der Gesellschaft: Frankfurt/Main Handelsregister: Frankfurt/Main HRB 40 417 Dain Sundstrom <[EMAIL PROTECTED]> An 09.06.2008 21:43 users@openejb.apache.org Kopie
Re: OpenEJB.war outside webapps
Hello Dain, Don't worry for the late reply, I'm not in a hurry :-) I hope that your client has come to better feelings now ;-) I get things to work by declaring the contexts in the Catalina/localhost repository in the tomcat conf dir. My layout is as follow : MyProject/ +-- src/ |+-- main/ ||+-- java/ ||+-- resources/ ||+-- webapps/ ||+-- WEB-INF/ ||+-- web.xml |+-- test/ |+-- java/ |+-- resources/ +-- target/ |+-- MyProject-0.0.1-SNAPSHOT/ ||+-- META-INF/ (empty) ||+-- WEB-INF/ ||+-- classes/ ||+-- lib/ (No OpenEJB jars in here) ||+-- web.xml |+-- classes/ |+-- test-classes/ |+-- war/ |+-- MyProject.war +-- target-eclipse/ (Compilation directory for Eclipse) +-- runtime/ (directory that acts as catalina.base and openejb.base) +-- conf/ |+-- Catalina/ ||+-- localhost/ ||+-- openejb.xml ||+-- MyProject.xml |+-- context.xml |+-- logging.properties |+-- openejb.xml |+-- server.xml |+-- web.xml +-- logs/ (logs) +-- temp/ (acts as java.io.tmpdir) +-- txlog/ (logs) +-- webapps/ (empty, serves as appBase for the localhost host in server.xml) +-- work/ Here above, the contents of some important files: # Server.xml: I took the one in the tomcat install. I just added the OpenEJB listener and trimmed the comments. # # openejb.xml: well, nothing special. I copied the one created by a default installation # # MyProject.xml: Here again, nothing sexy. # # openejb.xml: I removed defaults and inserted a database for my project JdbcDriver : com.mysql.jdbc.Driver JdbcUrl : jdbc:mysql://localhost:3306/ccv?useUnicode=true UserName : ccvusr Password : ccvpwd JdbcDriver : com.mysql.jdbc.Driver JdbcUrl : jdbc:mysql://localhost:3306/ccv?useUnicode=true UserName : ccvusr Password : ccvpwd JtaManaged : false # # context.xml: Again, this is the original file took from a clean install of Tomcat 6 whith comments trimmed. WEB-INF/web.xml # This is the configuration I use to start the server in Eclipse : VM args: -Dcatalina.home="C:\apache-tomcat-6.0.14" -Dcatalina.base="." -Dopenejb.home="C:\apache-tomcat-6.0.14" -Dopenejb.base="." -Djava.io.tmpdir="temp" -Xmx128M -javaagent:"C:\apache-tomcat-6.0.14\lib\openejb-javaagent.jar" Main class: org.apache.catalina.startup.Bootstrap Program arguments: start Classpath: C:\apache-tomcat-6.0.14\bin\bootstrap.jar Working directory: MyProject/runtime/ When I start the server, I get the following exception : java.lang.NullPointerException at org.apache.openejb.tomcat.loader.OpenEJBListener.lifecycleEvent(OpenEJBListener.java:46) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) at org.apache.catalina.core.StandardServer.initialize(StandardServer.java:767) at org.apache.catalina.startup.Catalina.load(Catalina.java:518) at org.apache.catalina.startup.Catalina.load(Catalina.java:538) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces