[Management, JMX/JBoss] - TimerService in MBean not containing timers
by taprogge
Hi!
In an EJB3 application I have a EJB3-style timer that get's started by a ServletContextListener at deployment time.
In the Listener I call getTimerService() on an injected EJBContext.
On the resulting TimerService I call getTimers() to check whether an instance of that timer already exists and if not I register a new one via createTimer().
That works like a charm. When the timer was created during a previous deployment, it is correctly listed by getTimers() and I can react on that.
Now I was trying to add to the application a standard MBean that could be used to reschedule and/or cancel that timer.
In one of the MBeans business methods I do exactly as before: call getTimerService() on the injected EJBContext.
The problem is that the TimerService thusly returned does not seem to know about the timers registered earlier: it's getTimers() returns an empty Collection even though there are timers registered.
Am I doing something wrong here?
Thanks in advance,
Phil
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4004361#4004361
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4004361
19 years, 3 months
[Installation, Configuration & Deployment] - JNDI over HTTP - getting HTTP Response Code 403 - using jbos
by PatrickMadden
Hello, I'm trying to connect to JNDI over HTTP. Right now I'm on the local lan and actually the same host that is running jboss. My test case works fine if I use the standard JNDI InitialContext for JBoss.
I wrote a relatively simple test case as follows:
| /**
| *
| */
| package com.foo.webservice.client;
|
| import java.io.IOException;
| import java.rmi.RMISecurityManager;
| import java.util.Hashtable;
|
| import javax.naming.Context;
| import javax.naming.InitialContext;
| import javax.naming.NamingException;
| import javax.security.auth.Subject;
| import javax.security.auth.callback.Callback;
| import javax.security.auth.callback.CallbackHandler;
| import javax.security.auth.callback.NameCallback;
| import javax.security.auth.callback.PasswordCallback;
| import javax.security.auth.callback.UnsupportedCallbackException;
| import javax.security.auth.login.LoginContext;
| import javax.security.auth.login.LoginException;
|
| import com.foo.web.services.db.*;
| /**
| * @author pmadden
| *
| */
| public class DBServiceTest
| {
| LoginContext loginContext;
|
| public DBServiceTest()
| {
|
| }
|
| private class ClientCallbackHandler implements CallbackHandler
| {
| String user;
| String pass;
| public ClientCallbackHandler(String user, String pass)
| {
| this.user = user;
| this.pass = pass;
| }
|
| /*
| * (non-Javadoc)
| * @see javax.security.auth.callback.CallbackHandler#handle(javax.security.auth.callback.Callback[])
| */
| public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
| {
| int len = callbacks.length;
| Callback cb;
|
| for (int i = 0; i < len; i++)
| {
| cb = callbacks;
|
| if (cb instanceof NameCallback)
| {
| ((NameCallback) cb).setName(this.user);
| }
| else if (cb instanceof PasswordCallback)
| {
| ((PasswordCallback) cb).setPassword(this.pass.toCharArray());
| }
| else
| {
| throw new UnsupportedCallbackException(cb, "Don't know what to do with this!");
| }
| }
| }
| }
|
| protected Subject login(String user, String pass) throws LoginException
| {
| // reads the jaas.config file - looks for clooster setting.
| loginContext = new LoginContext("clooster",
| new ClientCallbackHandler(user, pass));
|
| loginContext.login();
|
| return loginContext.getSubject();
| }
|
| protected void logout() throws LoginException
| {
| if (this.loginContext != null)
| {
| this.loginContext.logout();
| }
| }
|
| public void testDBService() throws Exception
| {
| if (System.getSecurityManager() == null)
| System.setSecurityManager(new RMISecurityManager());
|
| InitialContext initContext = this.getInitialContext();
| EJB3RemoteDBService dbService = (EJB3RemoteDBService) initContext.lookup("ejb3/EJB3DBService");
| }
|
| @SuppressWarnings("unchecked")
| protected InitialContext getInitialContext() throws NamingException
| {
| Hashtable<String, String> env = new Hashtable<String, String>();
|
| env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.HttpNamingContextFactory");
| env.put(Context.PROVIDER_URL, "http://10.10.10.6:8080/invoker/JNDIFactory");
| env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
|
| InitialContext initContext = new InitialContext(env);
|
| env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming.client");
| env.put("j2ee.clientName", "jbossws-client");
| return initContext;
| }
|
| public static void main(String[] args)
| {
| DBServiceTest test = new DBServiceTest();
|
| try
| {
| Subject subject = test.login("foo","bar");
|
| if (subject != null)
| {
| System.out.println(subject.toString());
|
| test.testDBService();
| }
| }
| catch (Exception e)
| {
| e.printStackTrace(System.err);
| }
| finally
| {
| try
| {
| test.logout();
| }
| catch (LoginException e)
| {
| e.printStackTrace(System.err);
| }
| }
| }
| }
|
I can actually get the LoginContext to login. It fails trying to create the InitialContext with the following output:
| Subject:
| Principal: foo
|
| javax.naming.NamingException: Failed to retrieve Naming interface [Root exception is java.io.IOException: Server returned HTTP response code: 403 for URL: http://10.10.10.6:8080/invoker/JNDIFactory]
| at org.jboss.naming.HttpNamingContextFactory.getInitialContext(HttpNamingContextFactory.java:84)
| at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
| at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
| at javax.naming.InitialContext.init(Unknown Source)
| at javax.naming.InitialContext.<init>(Unknown Source)
| at com.clooster.webservice.client.DBServiceTest.getInitialContext(DBServiceTest.java:112)
| at com.clooster.webservice.client.DBServiceTest.testDBService(DBServiceTest.java:99)
| at com.clooster.webservice.client.DBServiceTest.main(DBServiceTest.java:131)
| Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: http://10.10.10.6:8080/invoker/JNDIFactory
| at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
| at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
| at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
| at java.lang.reflect.Constructor.newInstance(Unknown Source)
| at sun.net.www.protocol.http.HttpURLConnection$6.run(Unknown Source)
| at java.security.AccessController.doPrivileged(Native Method)
| at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown Source)
| at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
| at org.jboss.naming.HttpNamingContextFactory.getNamingServer(HttpNamingContextFactory.java:133)
| at org.jboss.naming.HttpNamingContextFactory.getInitialContext(HttpNamingContextFactory.java:80)
| ... 7 more
| Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: http://10.10.10.6:8080/invoker/JNDIFactory
| at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
| at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(Unknown Source)
| at java.net.URLConnection.getHeaderFieldInt(Unknown Source)
| at java.net.URLConnection.getContentLength(Unknown Source)
| at org.jboss.naming.HttpNamingContextFactory.getNamingServer(HttpNamingContextFactory.java:128)
| ... 8 more
|
I'm running on standard port 8080. I added the username and password to both users.properties and conf\props\jmx-console-users.properties.
Any help would be greatly appreciated.
Thanks,
PVM
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4004358#4004358
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4004358
19 years, 3 months
[EJB 3.0] - EJB3 interfaces questions
by pablojavierpy
Hi all,
I have a Session Bean that looks like this:
public @Stateless class ReverseBean implements Reverse {
|
| public String reverse(String s)
| {
| String ret;
| // code to reverse the string "s" here
| return ret;
| }
|
| }
|
And then, I have its corresponding interface:
@Remote
| @Local
| public interface Reverse {
| public String reverse(String s);
| }
|
I have five small questions:
1) Is it OK to use only ONE class as remote AND local interface?
2) What's the default JNDI name assigned to the Session Bean? That is, how am I suppose to do the lookup for the Session Bean in the Initial Context?
3) Can I use @EJB injection in Servlets or injections are only available to other EJBs?
4) Where should I specify the "client-jar" if I am using EJB3? Do I even need a "client-jar"?
5) Where can I find more documentation about these three previous questions?
I am using JBoss 4.0.5.GA, installed with the installer, and the original EJB3 RC9 that comes with it.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4004339#4004339
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4004339
19 years, 3 months
[EJB 3.0] - EJB3 modules in Web Console
by pablojavierpy
Hi all,
I have a bunch of EJB3 Session and Entity beans working just fine in JBoss 4.0.5.GA.
However, when I look for the module that contains them in the Web Console, they do not appear.
Here is my EAR:
EAR
-> proj-client.jar
-> proj-ejb.jar
-> proj.war
In the Web Console, the EAR is showing correctly but only with the "war" module under it.
Here is my application.xml:
<application>
| <icon>
| <small-icon>icons/main-small.png</small-icon>
| <large-icon>icons/main-large.png</large-icon>
| </icon>
| <display-name>PROJ</display-name>
|
| <module>
| <ejb>proj-ejb.jar</ejb>
| </module>
| <module>
| <web>
| <web-uri>proj.war</web-uri>
| <context-root>theproj</context-root>
| </web>
| </module>
| </application>
|
Any ideas?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4004334#4004334
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4004334
19 years, 3 months
[JBoss Seam] - Re: Conversation and session timeout
by svadu
"gavin.king(a)jboss.com" wrote : oh, I never noticed that one before! Nice.
|
| Anyway, my guess is that normally you want the conversation timeout to be shorter than the session timeout.
Normally I agree. But recently I had to create a page with 4 different forms each of those uses ajax4jsf to operate with lists and images. And then if you leave the ui 'untouched' for 120 seconds (I know I can set it longer) and then trying to do something again I get the conversation timeout message.
Then I though that would it be nice to have the conversation 'mapped' to the session timeout (which is a bit longer anyway) unless a config (which already exists) is provided to override the setting. It might add kinda 'sensible default' (love this expression :) )... What do you think?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4004333#4004333
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4004333
19 years, 3 months