[EJB 3.0] - Stateful Session Beans Interaction
by grdzeli_kaci
hi all .............
here is my small example :
1.Fierst Remote Interface
| import javax.ejb.Remote;
|
| @Remote
| public interface Person {
| public void addPersonName(String a);
| public void printNames();
| }
|
2. And It's Implementation :
| import java.util.ArrayList;
| import javax.ejb.Remote;
| import javax.ejb.Stateful;
| import javax.ejb.TransactionAttribute;
| import javax.ejb.TransactionAttributeType;
|
| @Stateful
| @Remote(Person.class)
| …
[View More]public class PersonBean implements Person
| {
| ArrayList<String> list = new ArrayList<String>();
| @TransactionAttribute(TransactionAttributeType.REQUIRED)
| public void addPersonName(String name)
| {
| list.add(name);
| }
| @TransactionAttribute(TransactionAttributeType.SUPPORTS)
| public void printNames()
| {
| for (int i = 0; i < list.size(); i++)
| {
| System.out.println("Name = "+list.get(i));
| }
| }
| }
|
3. Second Remote Interface :
| import javax.ejb.Remote;
| @Remote
| public interface UsePerson {
| public void callPrint()throws Exception;
| }
|
4. And It's Implementation :
| @Stateful
| @Remote(Fasade.class)
| public class UsePersonBean implements UsePerson
| {
| @EJB
| Person person;
| @TransactionAttribute(TransactionAttributeType.REQUIRED)
| public void callPrint() throws Exception
| {
| try
| {
| test.printNames();
| }
| catch (Exception e)
| {
| e.printStackTrace();
| }
| }
|
| }
|
5. Client code :
| public class TestClient
| {
| public static void main(String[] args)
| {
| try
| {
| Properties jndiProps = new Properties();
| jndiProps.setProperty(Context.INITIAL_CONTEXT_FACTORY,
| "org.jnp.interfaces.NamingContextFactory");
| jndiProps.setProperty(Context.URL_PKG_PREFIXES,
| "org.jboss.naming:org.jnp.interface");
| jndiProps.setProperty(Context.PROVIDER_URL,
| "jnp://127.0.0.1:1099");
| InitialContext ctx = new InitialContext(jndiProps);
|
| UsePerson useperson = (UsePerson) ctx.lookup("UsePersonBean/remote");
| Person person = (Person) ctx.lookup("PersonBean/remote");
| person.addPersonName("Piter");
| person.addPersonName("John");
| person.addPersonName("Miles");
| person.addPersonName("Trubambas"); // :)
| bean.callPrint();
| }
| catch (Exception e)
| {
| e.printStackTrace();
| }
| }
| }
|
my task is that i want to get current Person reference in UsePersonBean which created by client.
i think @EJB annotation alwayes makes new reference.
could anybody tell me how i can get current session objects ??
like HTTPSession in Servlets ....
is it right if i use
| private @Resource SessionContext ctx;
|
but somewhere i found that "private @Resource SessionContext ctx;" and "@EJB annotation" are the same.
thanks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3968555#3968555
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3968555
[View Less]
18 years, 4 months
[Beginners Corner] - JBoss throws UnknownHostException on startup
by matwe
Hi,
I am really new to JBoss but I need it for an application at work. What I've done is downloaded and installed JBoss 4.0.1.sp1 and deployed an EAR-file in the server\default\deploy directory. When I launch JBoss I get the following error:
java.net.UnknownHostException: java.sun.com
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:153)
at java.net.Socket.connect(Socket.java:452)
at java.net.Socket.connect(Socket.java:402)
at sun.net.NetworkClient.…
[View More]doConnect(NetworkClient.java:139)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:402)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:618)
at sun.net.www.http.HttpClient.(HttpClient.java:306)
at sun.net.www.http.HttpClient.(HttpClient.java:267)
at sun.net.www.http.HttpClient.New(HttpClient.java:339)
at sun.net.www.http.HttpClient.New(HttpClient.java:320)
at sun.net.www.http.HttpClient.New(HttpClient.java:315)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:521)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:498)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:626)
at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown Source)
at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at com.teamcenter.mld.jmx.ConfigurationListener.(ConfigurationListener.java:586)
at com.teamcenter.mld.jmx.PlmSimpleMBeanFactory.(PlmSimpleMBeanFactory.java:195)
at com.teamcenter.jeti.resourceadapter.spi.impl.ConnectionFactoryImpl.(ConnectionFactoryImpl.java:86)
at com.teamcenter.jeti.resourceadapter.spi.impl.ManagedConnectionFactoryImpl.createConnectionFactory(ManagedConn
ectionFactoryImpl.java:127)
at org.jboss.resource.connectionmanager.ConnectionFactoryBindingService.createConnectionFactory(ConnectionFactor
yBindingService.java:182)
at org.jboss.resource.connectionmanager.ConnectionFactoryBindingService.startService(ConnectionFactoryBindingSer
vice.java:71)
at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:272)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:222)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:891)
at $Proxy0.start(Unknown Source)
at org.jboss.system.ServiceController.start(ServiceController.java:416)
at org.jboss.system.ServiceController.start(ServiceController.java:438)
at org.jboss.system.ServiceController.start(ServiceController.java:438)
at org.jboss.system.ServiceController.start(ServiceController.java:438)
at org.jboss.system.ServiceController.start(ServiceController.java:438)
at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
at $Proxy31.start(Unknown Source)
at org.jboss.deployment.SimpleSubDeployerSupport.startService(SimpleSubDeployerSupport.java:378)
at org.jboss.deployment.SimpleSubDeployerSupport.start(SimpleSubDeployerSupport.java:141)
at org.jboss.deployment.MainDeployer.start(MainDeployer.java:964)
at org.jboss.deployment.MainDeployer.start(MainDeployer.java:956)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:775)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:738)
at sun.reflect.GeneratedMethodAccessor48.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:122)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:131)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
at $Proxy8.deploy(Unknown Source)
at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:305)
at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:481)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:20
4)
at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:277)
at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:272)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:222)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:891)
at $Proxy0.start(Unknown Source)
at org.jboss.system.ServiceController.start(ServiceController.java:416)
at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
at $Proxy4.start(Unknown Source)
at org.jboss.deployment.SARDeployer.start(SARDeployer.java:261)
at org.jboss.deployment.MainDeployer.start(MainDeployer.java:964)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:775)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:738)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:722)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:122)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:131)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
at $Proxy5.deploy(Unknown Source)
at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:413)
at org.jboss.system.server.ServerImpl.start(ServerImpl.java:310)
at org.jboss.Main.boot(Main.java:162)
at org.jboss.Main$1.run(Main.java:423)
at java.lang.Thread.run(Thread.java:534)
Is this some class in my EAR trying to connect to the internet or is it some DTD validation (although I've turned off all DTD validation in JBoss)?
Please Help!!!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3968553#3968553
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3968553
[View Less]
18 years, 4 months