[EJB/JBoss] - EJB lookup after deploying to Jboss
by Richard.luo
Hi everybody,
I'm deploying a simple HelloWorld(Bean) to the jboss as following steps:
1)Declare Remote statless session bean interface HelloWorld
2)Construct a implementation class named HelloWorldBean to implement the Remote interface with annotation @Stateless, and there is a method sayHello
3)Compile and make it jar files and then deploy it to jboss server
4)Start jboss server
5)Code the client class named TestHelloWorld
A error occurred when I used following code:
| InitialContext ic = new InitialContext();
| HelloWorldBean hwBean = (HelloWorldBean) ic.lookup("HelloWorldBean/remote");
| ...
|
But, if I used the following code it do not occur again:
| Hashtable ht = new Hashtable();
| ht.put(Context.PROVIDER_URL, "jnp://localhost:1099");
| ht.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
| InitialContext ic = new InitialContext(ht);
| HelloWorldBean hwBean = (HelloWorldBean) ic.lookup("HelloWorldBean/remote");
|
Would somebody help me? It confused me several days. In one word, I want to use Annotation but it seems not working correctly.
Thanks in advance.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4002242#4002242
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4002242
19 years, 3 months
[JBoss Messaging] - Re: JMS Exceptions / Mismatch of JBossSerialization version
by rtm333
Hi,
After some further experimentation I think I finally found the critical part.
I can reproduce the misbehaviour by adding a trivial ExceptionListener to the connection of the topic example included with the Messaging distribution (org.jboss.example.jms.topic.TopicExample):
| ...
| connection = cf.createConnection();
| connection.setExceptionListener(new ExceptionListener() {
| public void onException(JMSException jmse) {
| }
| });
| ...
|
You also have to take care that the subscriber is running for some time (e.g. suppress publishing the message it is waiting for and extending the waiting time to, say, a minute).
During this time you can look at DEBUG output and/or repeatedly run netstat to see that a new connection to the messaging port is opened and closed every two seconds:
| ...
| [java] 11:59:37,410 DEBUG @main [MessageIdGeneratorFactory] checked out MessageIdGenerator for server.0, reference count is 1
| [java] 11:59:38,160 DEBUG @main [JBossSession] attempting to create consumer for destination:JBossTopic[testTopic]
| [java] 11:59:39,457 DEBUG @Timer-0 [MicroSocketClientInvoker] Setting ClientSocket class name to: org.jboss.jms.client.remoting.ClientSocketWrapper
| [java] 11:59:39,457 DEBUG @Timer-0 [SocketClientInvoker] Setting SocketClientInvoker::timeout to: 1000
| [java] 11:59:39,457 DEBUG @Timer-0 [MicroSocketClientInvoker] Setting ClientSocket class name to: org.jboss.jms.client.remoting.ClientSocketWrapper
| [java] 11:59:39,457 DEBUG @Timer-0 [SocketClientInvoker] Setting SocketClientInvoker::timeout to: 1000
| [java] 11:59:39,472 DEBUG @Timer-0 [MicroRemoteClientInvoker] connect called for: org.jboss.remoting.transport.socket.SocketClientInvoker@15356d5
| [java] 11:59:39,472 DEBUG @Timer-0 [MicroRemoteClientInvoker] disconnect called for: org.jboss.remoting.transport.socket.SocketClientInvoker@15356d5
| [java] 11:59:41,472 DEBUG @Timer-0 [MicroSocketClientInvoker] Setting ClientSocket class name to: org.jboss.jms.client.remoting.ClientSocketWrapper
| [java] 11:59:41,472 DEBUG @Timer-0 [SocketClientInvoker] Setting SocketClientInvoker::timeout to: 1000
| [java] 11:59:41,472 DEBUG @Timer-0 [MicroSocketClientInvoker] Setting ClientSocket class name to: org.jboss.jms.client.remoting.ClientSocketWrapper
| [java] 11:59:41,472 DEBUG @Timer-0 [SocketClientInvoker] Setting SocketClientInvoker::timeout to: 1000
| [java] 11:59:41,472 DEBUG @Timer-0 [MicroRemoteClientInvoker] connect called for: org.jboss.remoting.transport.socket.SocketClientInvoker@fb6354
| [java] 11:59:41,488 DEBUG @Timer-0 [MicroRemoteClientInvoker] disconnect called for: org.jboss.remoting.transport.socket.SocketClientInvoker@fb6354
| ...
|
This is not the initial problem of this thread (JMS Exceptions / Mismatch of JBossSerialization version), but I'm rather certain that it is related to this issue, as it leads to connection timeouts. Anyway, the frequent connection creation is a problem on it's own right.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4002240#4002240
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4002240
19 years, 3 months
[EJB 3.0] - Asynchronous callbacks
by aleksab
How can i achieve asynchronous callbacks in a stateless/statefull bean?
Scenario: A client send a request to a bean (ie do some processing of some large data). The bean returns a answer immidiately to the client, but wants to be able to tell the client on the progress and the final results. The client has a method which is dedicated to handle these callbacks. How can the bean send asynchronous callbacks to the client?
I've tried by sending the Method as a argument to the bean:
public String getAsynhcString(Method client, String test)
and the client invoke this by:
test.getAsynhcString(this.getClass().getMethod("callmeback", String.class), "hello");
The callmeback method of the client is on this form:
public void callmeback(String res)
However, when trying this, I get a marshalling exception: java.io.NotSerializableException: java.lang.reflect.Method
which is very unfortunately.
wondering if there are any suggestions on how i should accomplish my goal?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4002230#4002230
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4002230
19 years, 3 months