[Management, JMX/JBoss] - Re: How do force the module org.jboss.ejb.EjbModule to be de
by krimsonnitehawk
Hi, thanks for getting back. I've tried putting the following code inside the META-INF/jboss.xml file
| <container-configurations>
|
| <container-configuration>
| <container-name>Schema Update Dependent</container-name>
| <depends>package.myclass:service=servicename</depends>
| </container-configuration>
|
| </container-configurations>
|
Is this the correct place for the depends tag, or should it be within one of the tags as defined in the dtd? In jboss_4_0.dtd it says "The standard configurations will automatically be used if no custom configuration is specified." Do I need to more elements within my custom container-configuration tag so that jboss will pick it up instead of using one of the defaults defined in jboss4/server/default/conf/standardjboss.xml. How do find out which container configuration jboss is using to deploy my ejb module? I think the above code is currently being ignored.
When I deploy my ear the ejb module still seems to deploy even although I have called stop on the service. I am wondering if the stop isn't actually stopping my service. I have the following code in my service class.
First the interface.
| package package.myclass;
|
| public interface ServiceMBean {
|
| public void start() throws Exception;
|
| public void stop() throws Exception;
|
| public void create() throws Exception;
|
| public void destroy() throws Exception;
|
| }
The service class -
package package.myclass;
|
| public class Service implements ServiceMBean{
|
| public void start() throws Exception {
|
| //the important bit
|
| ObjectName ServiceSARClass = new ObjectName("package.myclass:service=servicename");
| // to get a handle on the MBeanServer
| MBeanServer server = MBeanServerLocator.locateJBoss();
| // if an exception occurs within the code
| server.invoke(ServiceSARClass,"stop",null,null);
| }
|
| public void destroy() throws Exception {
| logger.debug("Destroying jboss:service=servicename");
| }
|
| public void stop() throws Exception {
| logger.debug("Stopping jboss:service=servicename");
|
| }
| public void create() throws Exception {
| }
|
Calling server.invoke(ServiceSARClass,"stop",null,null); seems to call the stop method of this class but my debug shows that the start method contiunes to run. All my stop method contains is some debug - do I need more code to get actually get the service to stop? I am aware that stop simply un-registers the MBean from the MBeanServer. Is this enough so that when the ejb module deploys it see that its dependency has failed and in turn stops its deployment?
Again thanks in advance for any help!
Andy
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4015709#4015709
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4015709
19Â years, 2Â months
[EJB/JBoss] - Exception : Throwable while attempt to get a new connection
by murthy_j2ee
Hi All,
Can any body please tell me how to call ejb from a java bean. I have done it it as below.
Here is the client calling an EJB..............
{
Context ctx = new InitialContext();
Object obj = ctx.lookup("UserAuthentication_Session");
UserAuthentication_SessionHome home=(UserAuthentication_SessionHome)javax.rmi.PortableRemoteObject.narrow(obj,UserAuthentication_SessionHome.class);
UserAuthentication_Session rem = home.create();
loginValue=rem.validateLoginDetails(username,password);
}
Here is ejb-jar.xml..............................
UserAuthentication_Session
<ejb-name>UserAuthentication_Session</ejb-name>
com.prospecta.WSOProject.User_Authentication.ejb.UserAuthentication_SessionHome
com.prospecta.WSOProject.User_Authentication.ejb.UserAuthentication_Session
<ejb-class>com.prospecta.WSOProject.User_Authentication.ejb.UserAuthentication_SessionBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
Here is jboss.xml to specify the jndi name for my EJB.......................................
<ejb-name>UserAuthentication_Session</ejb-name>
<jndi-name>UserAuthentication_Session</jndi-name>
Here is the error trace....................................
Throwable while attempt to get a new connection..
please tell me what was the problem, and also please tell me how to configure it in jboss.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4015702#4015702
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4015702
19Â years, 2Â months
[EJB 3.0] - Re: Retrieve retrieve Entity Class mapping from jboss
by florian79
I hava just a bad solution, but it would be greate to find something better:
| public static Class[] getClassesFromPackage(final String strPackageName) throws ClassNotFoundException
| {
| ArrayList<Class> classes = new ArrayList<Class>();
| // Get a File object for the package
| File directory = null;
| String[] files = null;
| try
| {
| ClassLoader cld = Thread.currentThread().getContextClassLoader();
| if (cld == null)
| {
| throw new ClassNotFoundException("Can't get class loader.");
| }
| String path = strPackageName.replace('.', '/');
| //String path = '/' + pckgname.replace('.', '/');
| URL resource = cld.getResource(path);
| if (resource == null)
| {
| throw new ClassNotFoundException("No resource for " + path);
| }
| if(resource.getPath().contains("!"))
| {
| String[] arZipPath = resource.getPath().split("\\!");
| if(arZipPath.length >= 1)
| {
| String strZipPath = arZipPath[0].substring(6);//cut up 'file:/'
| try {
| JarFile jarFile = new JarFile(new File(strZipPath));
| List<String> lClassNames = new ArrayList<String>();
| for ( Enumeration e = jarFile.entries(); e.hasMoreElements(); )
| {
| JarEntry target = (JarEntry) e.nextElement();
| String strTargetName = target.getName();
| if(strTargetName.endsWith(".class") && strTargetName.startsWith(path + "/") && !target.isDirectory())
| {
| String strClassName = strTargetName.substring(path.length()+1);
| if(!strClassName.contains("/"))
| lClassNames.add(strClassName);
| }
|
| }
| files = (String[])lClassNames.toArray(new String[lClassNames.size()]);
| }
| catch (IOException e)
| {
| throw new ClassNotFoundException(strPackageName + " (" + strZipPath + ") does not appear to be a valid (JAR-) package");
| }
| }
| }
| else
| {
| directory = new File(resource.getFile());
| if (directory.exists())
| {
| // Get the list of the files contained in the package
| files = directory.list();
| Arrays.sort(files);
| }
| else
| {
| throw new ClassNotFoundException(strPackageName + " does not appear to be a valid package");
| }
| }
| }
| catch (NullPointerException x)
| {
| throw new ClassNotFoundException(strPackageName + " (" + directory + ") does not appear to be a valid package");
| }
| for (int i = 0; i < files.length; i++)
| {
| // we are only interested in .class files
| if (files.endsWith(".class"))
| {
| // removes the .class extension
| try
| {
| classes.add(Class.forName(strPackageName + '.' + files.substring(0, files.length() - 6)));
| }
| catch (Exception e) {}
| }
| }
|
| Class[] classesA = new Class[classes.size()];
| classes.toArray(classesA);
| return classesA;
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4015698#4015698
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4015698
19Â years, 2Â months