ejb client

2008-12-28 Thread axiez

I want to run sample code to understand ejb 3.0 basics. I am new to ejb. I
have the following java files: ShoppingCartBean.java, ShoppingCart.java and
Client.java. The Client.java file has the following code:
import javax.naming.InitialContext;
public class Client {
public static void main(String[] args) throws Exception {
InitialContext ctx = new InitialContext();
ShoppingCart cart = (ShoppingCart)
ctx.lookup(ShoppingCartBean/remote);
...
}
My plan is to have client on a different JVM than ejb container. I
wonder how the client can execute bean method without even knowing IP
address etc of the JVM that has the other code on ejb container.
-- 
View this message in context: 
http://www.nabble.com/ejb-client-tp21193112s134p21193112.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.



Re: ejb client

2008-12-28 Thread Shawn Jiang
With some search, it seems that you do need to provide the ejb
container info by


1, providing a jndi.properties in your client classpath with following content:

java.naming.factory.initial=org.openejb.client.RemoteInitialContextFactory
java.naming.provider.url=ejb_container_ip:4201
java.naming.security.principal=system
java.naming.security.credentials=manager


or

2, using following code to create the initial context in your client code.

Properties env = new Properties();

env.put(java.naming.factory.initial,org.apache.openejb.client.RemoteInitialContextFactory);
env.put(java.naming.factory.host, ejb_container_ip);
env.put(java.naming.factory.port, 4201);
env.put(java.naming.security.principal, system);
env.put(java.naming.security.credentials, manager);
ctx = new InitialContext(env);

hope it helps.

2008/12/28 axiez lesai...@gmail.com:

 I want to run sample code to understand ejb 3.0 basics. I am new to ejb. I
 have the following java files: ShoppingCartBean.java, ShoppingCart.java and
 Client.java. The Client.java file has the following code:
 import javax.naming.InitialContext;
 public class Client {
public static void main(String[] args) throws Exception {
InitialContext ctx = new InitialContext();
ShoppingCart cart = (ShoppingCart)
 ctx.lookup(ShoppingCartBean/remote);
...
}
My plan is to have client on a different JVM than ejb container. I
 wonder how the client can execute bean method without even knowing IP
 address etc of the JVM that has the other code on ejb container.
 --
 View this message in context: 
 http://www.nabble.com/ejb-client-tp21193112s134p21193112.html
 Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.





-- 
Shawn


Re: [geronimo] Re: Out of memory during second publish - reproduced

2008-12-28 Thread Steve H.

Hi Tim,

Thanks for responding so promptly.

I have followed your advice although I set MaxPermSize to 512m for eclipse
and Geronimo. These settings can be seen in the ps output I posted.

The artifact I am developing is an experimental EAR. It includes 3 jsp's but
it includes Hibernate POJO's, EJB3 session beans and a Struts presentation
layer.

The EAR deploys and runs fine under Eclipse. However it generally fails with
a PermGen Space error on the 2nd deployment. Not so good for development. I
am running on a laptop however it has 2 GB RAM.

Please email me your address and I will send you the EAR. However this might
not be for a couple of weeks. as I'm just going on holiday. I will send you
my email address separately.

Many thanks for your help,

Steve


Tim McConnell wrote:
 
 Hi Steve, I assume you've gone through the 5 steps I outlined previously
 for 
 Dale. You might try increasing you MaxPermsize to 768mb but I doubt
 that'll make 
 much difference. Are you able to deploy the artifact to Geronimo outside
 of 
 Eclipse (e.g., using the Admin console) ?? Finally, would you be able to
 send me 
 the artifact that you're deploying ?? If it's proprietary and you cannot I
 fully 
 understand. If not, could you briefly describe the artifact that you are 
 deploying (i.e., EAR, WAR, EJB, etc.) ??
 
 Steve H. wrote:
 I'm getting this error consistently after increasing the memory
 allocation
 for Eclipse and Geronimo.
 
 I'm running on OpenSUSE 10.3 x64 with Geronimo 2.1.3 on a machine with
 2GB
 RAM.
 
 Output from 'ps aux | grep java' and Eclipse error trace shown below: -
 
 Output of 'ps aux | grep java' following PermGen crash in Geronimo.
 
 steve 4325 17.9 18.6 1474804 383908 ?  Sl   23:43   1:38
 /usr/lib64/jvm/java-1.6.0.u7-sun-1.6.0.u7/jre/bin/java -Xmx512m
 -XX:MaxPermSize=512m -jar
 /usr/share/eclipse/plugins/org.eclipse.equinox.launcher_1.0.101.R34x_v20080819.jar
 -os linux -ws gtk -arch x86_64 -showsplash -launcher
 /usr/share/eclipse/eclipse -name Eclipse --launcher.library
 /usr/share/eclipse/plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.0.101.R34x_v20080731/eclipse_1115.so
 -startup
 /usr/share/eclipse/plugins/org.eclipse.equinox.launcher_1.0.101.R34x_v20080819.jar
 -exitdata 160002 -vm /usr/bin/java -vmargs -Xmx512m -XX:MaxPermSize=512m
 -jar
 /usr/share/eclipse/plugins/org.eclipse.equinox.launcher_1.0.101.R34x_v20080819.jar
 steve 4835 27.1 14.8 518960 305744 ?   Sl   23:44   2:13
 /usr/lib64/jvm/java-1.6.0.u7-sun-1.6.0.u7/bin/java
 -javaagent:/usr/local/geronimo-tomcat6-javaee5-2.1.3/bin/jpa.jar
 -Djava.ext.dirs=/usr/local/geronimo-tomcat6-javaee5-2.1.3/lib/ext:/usr/lib64/jvm/java-1.6.0.u7-sun-1.6.0.u7/jre/lib/ext
 -Djava.endorsed.dirs=/usr/local/geronimo-tomcat6-javaee5-2.1.3/lib/endorsed:/usr/lib64/jvm/java-1.6.0.u7-sun-1.6.0.u7/jre/lib/endorsed
 -Xmx512m -XX:MaxPermSize=512m -Dfile.encoding=UTF-8 -classpath
 /usr/local/geronimo-tomcat6-javaee5-2.1.3/bin/server.jar
 org.apache.geronimo.cli.daemon.DaemonCLI --long
 steve10155  0.0  0.0   5120   788 pts/1R+   23:52   0:00 grep
 java
 
 Trace from Eclipse
 
 23:51:10,653 WARN  [Settings] Settings: Could not parse struts.locale
 setting, substituting default VM locale
 23:51:31,757 ERROR [[jsp]] Servlet.service() for servlet jsp threw
 exception
 java.lang.OutOfMemoryError: PermGen space
  at java.lang.ClassLoader.defineClass1(Native Method)
  at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
  at
 java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
  at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
 etc...
 
 Output show below: -
 
 Tim McConnell wrote:

 That's wonderful Dale !! Please let me know if you have any other
 problems. BTW, 
 I've open the following JIRA to fix similar problems.

 - https://issues.apache.org/jira/browse/GERONIMODEVTOOLS-543

 DRS2 Usenet wrote:
 Tim McConnell wrote:

 (snip)
 4.  Page down in that section and append your VM arguments at the end 
 -- don't delete those that are already there. I used the same ones 
 that Kevan used, but I'm using Java 1.5 and I see that you're using 
 Java 1.6:

 -Xmx512m -XX:MaxPermSize=256m
 (snip)
 Please try this and let me know what happens. I think you'll have 
 better results now. Meanwhile, I'm going to open a GEP JIRA to 
 investigate if we can programmatically determine and set the Geronimo 
 server VM arguments using those already established for Eclipse since 
 obviously the default values for the server are not always sufficient. 
 Thanks much.
 Thanks Tim, That worked great.  I'd been using run configurations to 
 make the Geronimo JVM settings... never tried double clicking on the 
 server.  I've been able to republish many times without error AND 
 without restarting the server (this is really a NICE feature!).

 Tim McConnell wrote:
 Hi Dale, just a quick note to tell you that I can now reproduce your 
 failure. Looking for a resolution, and will let 

Re: ejb client

2008-12-28 Thread axiez

I added jndi.properties. Modified code is given below:
Properties p = new Properties();
p.load(new FileInputStream(jndi.properties));
InitialContext ctx = new InitialContext(p);
ShoppingCart cart = (ShoppingCart) ctx.lookup(ShoppingCartBean/remote);
I compiled the java files and am planning to create a jar file a.jar and
deploy it. In the lookup method given above, I simply mentioned the bean
class name. Nowhere did I mention jar file/module name. Is this correct?

axiez wrote:
 
 I want to run sample code to understand ejb 3.0 basics. I am new to ejb. I
 have the following java files: ShoppingCartBean.java, ShoppingCart.java
 and Client.java. The Client.java file has the following code:
 import javax.naming.InitialContext;
 public class Client {
 public static void main(String[] args) throws Exception {
 InitialContext ctx = new InitialContext();
 ShoppingCart cart = (ShoppingCart)
 ctx.lookup(ShoppingCartBean/remote);
 ...
 }
 My plan is to have client on a different JVM than ejb container. I
 wonder how the client can execute bean method without even knowing IP
 address etc of the JVM that has the other code on ejb container.
 

-- 
View this message in context: 
http://www.nabble.com/ejb-client-tp21193112s134p21199643.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.