Re: How to use annotation in client application?
Hi Paul, If it is a standalone client application with its own main method, it runs outside the container.So you cannot get beans injected and you will need to always look them up via remote JNDI lookup Regards Manu On Tue, Nov 18, 2008 at 7:14 PM, Paul Spencer <[EMAIL PROTECTED]> wrote: > I have a EJB3 client application that is not getting the the bean via > annotation. Getting the bean via the initial context works. > > *** > * Annotation to get the customerBean > *** > @EJB (name="CustomerBeanRemote) > private CustomerBean customerBean > > > 1) How do I use annotations, like @EJB, in an EJB3 client? > > 2) Is their Maven configuration other then a dependency on > openejb-client that is necessary? > > Paul Spencer > >
EntityManager Propagation Problem under 3.1
Apologies in advance for cross-posting, but my post to OpenJPA ( http://n2.nabble.com/EntityManager-Propagation-with-Extended-PersistenceContext-td1495977.html http://n2.nabble.com/EntityManager-Propagation-with-Extended-PersistenceContext-td1495977.html ) hasn't gotten any hits. To repeat from that post, I have: A) Parent entity with LAZY OneToMany List, cascade: PERSIST,MERGE,REFRESH B) Child entity with EAGER ManyToOne Parent, cascade: PERSIST,MERGE,REFRESH C)Abstract CRUD class with injected Extended PersistenceContext, and requisite CRUD methods D) Parent Stateful bean that extends CRUD E) Child Stateful bean that extends CRUD Classes are enhanced in place via ant prior to junit test run. Under OpenEJB3.0 (OpenJPA 1.0.1), Any/All managed entities show as managed by either bean, but under OpenEJB 3.1 (with deployed OpenJPA 1.1.0 AND 'latest binary' 1.2.0), only the bean responsible for the load/persist/merge of an entity shows the entity as managed. The following snippet works fine under 3.0, but throws an exception under 3.1: Parent p = parentBean.insert(new Parent("Foo")); Child c = childBean.insert(new Child("Bar", p)); WARN org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(Ln 516) - Unexpected exception from beforeCompletion; transaction will roll back org.apache.openjpa.persistence.ArgumentException: The given instance "entity.Parent-6264" is not managed by this context. FailedObject: entity.Parent-6264 Please help Thanks, Jim -- View this message in context: http://www.nabble.com/EntityManager-Propagation-Problem-under-3.1-tp20571571p20571571.html Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: UserTransaction injection
On Nov 11, 2008, at 6:57 PM, Carlos MacLeod wrote: 2008-11-12 00:40:55,155 - ERROR - Error merging OpenEJB JNDI entries in to war /Bunda: Exception: null java.lang.NullPointerException at java.util.Hashtable.put(Hashtable.java:394) at org .apache .catalina .deploy.NamingResources.addResourceEnvRef(NamingResources.java:320) at org .apache .openejb .tomcat.catalina.TomcatJndiBuilder.mergeRef(TomcatJndiBuilder.java: 416) at org .apache .openejb .tomcat.catalina.TomcatJndiBuilder.mergeJndi(TomcatJndiBuilder.java: 140) at org .apache .openejb .tomcat.catalina.TomcatWebAppBuilder.start(TomcatWebAppBuilder.java: 270) at org .apache .openejb .tomcat .catalina .GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:58) This seems to be the heart of the issue. Unfortunately looking at the code here what might be going on is not obvious. Is it possible you could create a small app that reproduces the problem so we can try it on our end? I've created a JIRA here for it: https://issues.apache.org/jira/browse/OPENEJB-960 -David
Re: Global JNDI Destinations with ActiveMQ
On Nov 13, 2008, at 12:23 PM, ebmm_axis wrote: First and foremost, thanks to the openEJB team for all the efforts... I am running openEJB as a stand alone server and haven't dove into it's use with a full application server. My reasoning for this is to keep things simple and just learn the ins and outs of OpenEJB. Using the Default Resource Adapter I am able to use MDBs successfully throughout my application. BUT, if I want to access any destination (queue or topic) GLOBALLY from a 'stand alone' client, I'm not able to. (i.e. I would like to globally resolve via JNDI my JMSConnectionFactory and the queues/topics that I have set up in openejb.xml) I am failing to connect the dots with the configurations required that will provide the global JNDI name resolution. Any comments and direction would be much appreciated. For a standalone client that is running locally (i.e. inside the same vm as the server) you should be able to look things up by constructing an initial context exactly like this: InitialContext context = new InitialContext(); // no params context.lookup("java:openejb/Resource/theResourceName"); Where "theResourceName" is whatever you called it in your openejb.xml. That should give you access to the "java:openejb" global jndi tree. Note that this will not work from an EJB or similar component with a "java:comp/env" namespace. We could make it available there too if you need it. Also note that this will not work from a remote client as pretty much nothing in java:openejb/Resource is serializable. We have some code for allowing users to configure a DataSource or ConnectionFactory on the client via system properties with the ability to then look them up via JNDI. The syntax for that is like this: java - DmyDataSource=datasource:org.hsqldb.jdbcDriver:jdbc:hsqldb:hsql:// localhost/mydb;user=joe;password=cool \ - DmyConnectionFactory =connectionfactory:org.apache.activemq.ActiveMQConnectionFactory:tcp:// localhost:61616 \ org.superbiz.MyClient You can then create an InitialContext via the RemoteInitialContextFactory and lookup "myDataSource" and get a DataSource or lookup "myConnectionFactory" and get a ConnectionFactory. And as always we're open to new features in this regard, so if you have any ideas we'd love to hear them. -David
Re: How to maintain a schema per user?
On Nov 10, 2008, at 2:35 PM, Paul Spencer wrote: Dain, I am using OpenJPA. Do you know if, and how, they support per user connections? OpenJPA will use whatever DataSources we give it. You might be able to use the Commons DBCP PerUserPoolDataSource as Dain suggests but it'll take some patching to get it wired in. This is the class that creates the DataSources inside OpenEJB org.apache.openejb.resource.jdbc.DataSourceFactory http://svn.apache.org/viewvc/openejb/tags/openejb-3.1/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/DataSourceFactory.java?view=markup You might be able to patch it to create PerUserPoolDataSource instead. -David Paul Spencer Dain Sundstrom wrote: Assuming you are using straight JDBC or a persistence framework designed for per-user connections, I believe that the org.apache.commons.dbcp.datasources.PerUserPoolDataSource pool can do what you want, but I've never used per-user pools myself. Also, I bet that c3p0 (http://sourceforge.net/projects/c3p0/) can do it also. -dain On Nov 10, 2008, at 11:55 AM, Paul Spencer wrote: I have an application that requires a logged in user be restricted to a schema within the database. For the sake of illustration, the application is an address book and their is one schema per user. The database structure of the table and views within each schema are exactly same. My questions: 1) How do insure that a logged in user will only access the data in their schema? 2) How can a new schema be automatically created when user is created? Paul Spencer
Re: Global JNDI Destinations with ActiveMQ
On Nov 13, 2008, at 12:23 PM, ebmm_axis wrote: First and foremost, thanks to the openEJB team for all the efforts... I am running openEJB as a stand alone server and haven't dove into it's use with a full application server. My reasoning for this is to keep things simple and just learn the ins and outs of OpenEJB. Using the Default Resource Adapter I am able to use MDBs successfully throughout my application. BUT, if I want to access any destination (queue or topic) GLOBALLY from a 'stand alone' client, I'm not able to. (i.e. I would like to globally resolve via JNDI my JMSConnectionFactory and the queues/topics that I have set up in openejb.xml) I am failing to connect the dots with the configurations required that will provide the global JNDI name resolution. Any comments and direction would be much appreciated.
How to use annotation in client application?
I have a EJB3 client application that is not getting the the bean via annotation. Getting the bean via the initial context works. *** * Annotation to get the customerBean *** @EJB (name="CustomerBeanRemote) private CustomerBean customerBean 1) How do I use annotations, like @EJB, in an EJB3 client? 2) Is their Maven configuration other then a dependency on openejb-client that is necessary? Paul Spencer
Error connecting OpenEJB3.0 client to OpenEJB 3.1 server.
I am getting the following exception when connecting a OpenEJB 3.0 remote client to an OpenEJB 3.1 standalone server. The exception is thrown when the client is getting the IntialContext. *** * Code that does gets the initial context * Note: This was copied from OpenEJB's remote client example *** Properties p = new Properties(); p.put("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory"); p.put("java.naming.provider.url", "ejbd://localhost:4201"); p.put("java.naming.security.principal", ""); p.put("java.naming.security.credentials", ""); InitialContext ctx = new InitialContext(p); *** * Exception on OpenEJB 3.0 remote Client end *** javax.naming.AuthenticationException: Cannot open object output stream to server: ; nested exception is: java.net.SocketException: Broken pipe at org.apache.openejb.client.JNDIContext.authenticate(JNDIContext.java:176) at org.apache.openejb.client.JNDIContext.getInitialContext(JNDIContext.java:129) at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247) at javax.naming.InitialContext.init(InitialContext.java:223) at javax.naming.InitialContext.(InitialContext.java:197) *** * Exception on OpenEJB 3.1 Server End *** java.io.IOException: Unexpected byte 79 at org.apache.openejb.server.ejbd.KeepAliveServer$Session.service(KeepAliveServer.java:221) at org.apache.openejb.server.ejbd.KeepAliveServer.service(KeepAliveServer.java:233) at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:66) at org.apache.openejb.server.ServicePool$2.run(ServicePool.java:91) at org.apache.openejb.server.ServicePool$3.run(ServicePool.java:120) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675) at java.lang.Thread.run(Thread.java:613) When I change openejb-client version from 3.0 to 3.1, the client successfully get the initial context and connects to the server. Is this a bug in 3.1, 3.0, or both? Paul Spencer