-
1. Re: Hey I want simple steps to run an ejb sample application?
jaikiran Aug 13, 2010 6:47 AM (in response to swaroopp)See the tutorials here http://www.jboss.org/ejb3/docs
-
2. Re: Hey I want simple steps to run an ejb sample application?
swaroopp Aug 16, 2010 2:38 AM (in response to jaikiran)Hi jaikiran
Regarding the post u replied ..... I tried with a sample ejb application... I deployed the jar file in appln server and i tried to make lookup for the jndi but it is not able to lookup..... My Appln server is jboss
-
3. Re: Hey I want simple steps to run an ejb sample application?
jaikiran Aug 16, 2010 3:28 AM (in response to swaroopp)swaroop kumar wrote:
I deployed the jar file in appln server and i tried to make lookup for the jndi but it is not able to lookup.....You'll have to post more details including any relevant exception stacktraces. How are you running the tutorials? Did you do any changes?
-
4. Re: Hey I want simple steps to run an ejb sample application?
swaroopp Aug 16, 2010 8:38 AM (in response to jaikiran)Hi
I made a jar file and deployed in the container
The Exception I am getting is ClassCastException..I tried configuring environment variables of jndi using jndi.properties also .. but still getting the same
I attached my code please go through it....
-
ejbdoubt.doc 32.5 KB
-
-
5. Re: Hey I want simple steps to run an ejb sample application?
wolfgangknauf Aug 16, 2010 11:45 AM (in response to swaroopp)Hi,
I think you need different "java.naming.factory.url.pkgs":
env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming.client
If this does not help: please check the JNDI names by using "JNDIView" ( http://localhost:8080/jmx-console/HtmlAdaptor?action=inspectMBean&name=jboss%3Aservice%3DJNDIView ) - search the method "list" and click "Invoke" here.
Hope this helps
Wolfgang
-
6. Re: Hey I want simple steps to run an ejb sample application?
swaroopp Aug 17, 2010 2:17 AM (in response to wolfgangknauf)I checked with the jmx-console and jboss-web console and the i checked the JNDI names by using "JNDIView"
package
com.myeclipse.ejb3;
import
javax.naming.Context;
import
javax.naming.InitialContext;
import
javax.naming.NamingEnumeration;
import
javax.naming.NamingException;
import
java.util.*;
public
class MyBeanClient {
public static void main(String[] args) {
try {
Hashtable env =
new Hashtable();
env.put(
"java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
//env.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces"); //not required
env.put(
"java.naming.provider.url","localhost:1099");
final String jndiName = "MyBean/remote";
Context context =
new InitialContext(env);
System.
out.println("about to look up jndi name " + jndiName);
MyBeanRemote beanRemote = (com.myeclipse.ejb3.MyBeanRemote) context.lookup(jndiName);
beanRemote.doSomething();
System.
out.println("finished lookup");
}
catch (NamingException e) {
e.printStackTrace();
}
}
}
REMOTE CLASS
package
com.myeclipse.ejb3;
import
javax.ejb.Remote;
@Remote
public
MyBeanRemote {
doSomething() ;
-
7. Re: Hey I want simple steps to run an ejb sample application?
swaroopp Aug 17, 2010 7:07 AM (in response to jaikiran)Hi Jaikiran
Now I am not getting any exception but when i am calling my beans method it is not invoking that method ....
about to look up jndi name MyBean/remote
log4j:WARN No appenders could be found for logger (org.jnp.interfaces.TimedSocketFactory).
log4j:WARN Please initialize the log4j system properly.
finished lookup
-
ejbdoubt.doc 32.5 KB
-
-
8. Re: Hey I want simple steps to run an ejb sample application?
swaroopp Aug 17, 2010 7:11 AM (in response to wolfgangknauf)Not getting any exception but not able to invoke bean's method
about to look up jndi name MyBean/remote
log4j:WARN No appenders could be found for logger (org.jnp.interfaces.TimedSocketFactory).
log4j:WARN Please initialize the log4j system properly.
finished lookup
-
9. Re: Hey I want simple steps to run an ejb sample application?
swaroopp Aug 17, 2010 7:16 AM (in response to wolfgangknauf)about to look up jndi name MyBean/remote
log4j:WARN No appenders could be found for logger (org.jnp.interfaces.TimedSocketFactory).
log4j:WARN Please initialize the log4j system properly.
finished lookup
I am not getting any exception but bean's method is not invoked
-
ejbdoubt.doc 32.5 KB
-
-
10. Re: Hey I want simple steps to run an ejb sample application?
wolfgangknauf Aug 17, 2010 7:25 AM (in response to swaroopp)Hi,
as it seems to be a small sample app: could you post the JAR file including the source code?
Does your client app contain any JBoss specific JAR files, maybe from a different JBoss version? Does it reference outdated versions of your EJB classes?
By the way: you have an EJB jar file and an application client? Do you bundle the application client in a separate JAR file, or is it part of the EJB jar?
Normally, you would create an EAR file containing both an EJB jar and a client JAR.
Best regards
Wolfgang
-
11. Re: Hey I want simple steps to run an ejb sample application?
wolfgangknauf Aug 17, 2010 7:33 AM (in response to wolfgangknauf)Hi,
the warning can be ignored. You might fix it by adding a file "log4j.properties" to your client with this content (I hope the forum does not break formatting):
log4j.rootLogger=DEBUG, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%t][%c] - <%m>%nThe other problem of not showing the Ejb output is strange. Here, we might need the full app, see above.
By the way: you never posted "MyBeanLocal". Maybe there is something "special" inside, which breaks the sample?
Best regards
Wolfgang
-
12. Re: Hey I want simple steps to run an ejb sample application?
swaroopp Aug 17, 2010 7:37 AM (in response to wolfgangknauf)Hi
Previously i used different version jar file and i got some exception but now i am using the jar file from the same version...so i am not getting the exception...I am sending the jar file and source which i sent to you already as the doc file
-
Copy of SampleEJBProject.zip 9.0 KB
-
newejb.jar 3.7 KB
-
-
13. Re: Hey I want simple steps to run an ejb sample application?
swaroopp Aug 17, 2010 7:57 AM (in response to wolfgangknauf)Hi
I sent u the source code...
there is log4j.properties in the jar file in the classpath...
should i remove the MyBeanLocal
Thanks for discussion
-
14. Re: Hey I want simple steps to run an ejb sample application?
wolfgangknauf Aug 17, 2010 8:31 AM (in response to swaroopp)Hi,
I gave your app a try, and for me it worked perfectly (using Eclipse + WebToolsPlatform plugin). I had to add the JNDI properties which you seem to have removed:
Hashtable env =new Hashtable();
env.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming.client");
env.put("java.naming.provider.url","localhost:1099");
Context context = new InitialContext(env);But beware: the console output of your EJB will not be in the client console but in the server console!
If it does not work for you, I assume a problem with the way you run the client. How do you do it?
Best regards
Wolfgang