NoClassDefFoundError when i look up EJB from tag handler class

   Tag handler class and jsp is deployed in one of the instance of jboss.using environment properties in the tag handler class i am trying to  look up EJB method(i.e in ear) deployed in another instances of jboss.  i got home interface at the next line i am getting this exception.its telling that not able to find that class .

i am doing remote look up from war to ear;

      java.lang.NoClassDefFoundError: db/DOCModel
      java.lang.ClassLoader.defineClass1(Native Method)
      java.lang.ClassLoader.defineClass(ClassLoader.java:620)
      java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
      org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1629)
      org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:850)
      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1299)
      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1181)
      java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
      java.lang.Class.getDeclaredMethods0(Native Method)
      java.lang.Class.privateGetDeclaredMethods(Class.java:2365)
      


   
    public int doEndTag() throws javax.servlet.jsp.JspTagException
            {


            try  
                  {    

            
                        Hashtable contextProperty            = new java.util.Hashtable();
                        contextProperty.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
                        contextProperty.put(Context.SECURITY_PRINCIPAL, "admin") ;
                        contextProperty.put(Context.SECURITY_CREDENTIALS, "welcome");
                        contextProperty.put(Context.PROVIDER_URL, "jnp://localhost:1099");


                        
                    
                        InitialContext            context          = new InitialContext(contextProperty);
                        DocumentSessionHome home         = (DocumentSessionHome)context.lookup("DocumentSessionBean");

                        System.out.println("home===="+home);*********************** home interface getting here

                        DocumentSession         remote            = (DocumentSession)home.create();
                        System.out.println("remote===="+remote); /////////////////  remote interface not printed

                        ArrayList mainList      = (ArrayList)remote.getDocumentIds();
                  }      
                  catch(java.io.IOException e)  
                  {          
                        throw new JspTagException("IO Error: " + e.getMessage());
                  }
                  catch(Exception e)  
                  {          
                        throw new JspTagException("Error: " + e.getMessage());
                  }
                        return EVAL_PAGE;  
                  
                  }
LVL 20
chaitu chaituAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chaitu chaituAuthor Commented:
Tag handler class and jsp is deployed(in the form of war) in one of the instance of jboss.

from tag handler class i am trying to  look up EJB method(i.e in the form of ear) deployed in another instances of jboss.
DOCModel.class file is there in  ear but still it is throwing java.lang.NoClassDefFoundError.
0
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
if you think all the JNDI names and other stuff are perfect just try

 
 
   InitialContext          context         = new InitialContext(contextProperty);
   Object ref = context.lookup("DocumentSessionBean");
   DocumentSessionHome home         = (DocumentSessionHome)PortableRemoteObject.narrow(ref,DocumentSessionHome.class");
    DocumentSession        remote          = (DocumentSession)home.create();

As such i don't think your JNDI name is correct just verify & continue.
0
chaitu chaituAuthor Commented:
now i am getting this exception

javax.servlet.jsp.JspTagException: Error: Receive timed out
      bus.Paging.doEndTag(Paging.java:94)
      org.apache.jsp.helloWorld_jsp._jspx_meth_mt_paging_0(org.apache.jsp.helloWorld_jsp:115)
      org.apache.jsp.helloWorld_jsp._jspService(org.apache.jsp.helloWorld_jsp:88)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      java.lang.
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
put forward your helloworld.jsp there is some tag error in it.
0
chaitu chaituAuthor Commented:
<%@ page import="java.util.*"  %>
<%@ taglib uri="mytags" prefix="mt" %>
<HTML>    <HEAD>        <TITLE>Hello World!</TITLE>
</HEAD>    <BODY BGCOLOR="#FFFFFF">
<HR>    

<mt:paging/>
<HR>  
</BODY>
</HTML>
0
chaitu chaituAuthor Commented:
sometimes its coming NoClassDefFoundError and sometimes  Receive timed out error
0
borislavmarkovCommented:
Of course, you have to include your custom classes that EJB uses, they are serialized.

so make sure DOCModel is Serializable and include it your WAR where you invoked the EJB,
also change :
contextProperty.put(Context.PROVIDER_URL, "jnp://localhost:1099");
to be
contextProperty.put(Context.PROVIDER_URL, "localhost:1099");
0
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
<%@ taglib uri="mytags" prefix="mt" %>

is that tag library named "mytags" is it there in WEB-INF folder direcly??.
Or is it there in some other folder inside WEB-INF???

and also check this link.

http://www.theserverside.com/discussions/thread.tss?thread_id=30166#147156
0
chaitu chaituAuthor Commented:
i dont understand one thing that i added Home interface and Remote interface classes  in the WAR;

do i addeed custom classes in WAR;those custom classes already there ear .
0
chaitu chaituAuthor Commented:
i already implemented simple example;it worked well now i am implementing remote look up;

problem lies in remote lookup onlyy
0
chaitu chaituAuthor Commented:
14:09:22,518 INFO  [STDOUT] home====DocumentSessionBeanHome
14:09:22,924 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
java.lang.NoClassDefFoundError: bus/DOCModel

          at java.lang.Class.getDeclaredMethods0(Native Method)
  at java.lang.Class.privateGetDeclaredMethods(Class.java:2365)
  at java.lang.Class.privateGetPublicMethods(Class.java:2488)
  at java.lang.Class.getMethods(Class.java:1406)
  at sun.misc.ProxyGenerator.generateClassFile(ProxyGenerator.java:409
  at sun.misc.ProxyGenerator.generateProxyClass(ProxyGenerator.java:30
  at java.lang.reflect.Proxy.getProxyClass(Proxy.java:484)
  at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:64
  at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:58
  at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.ja

  at org.jboss.system.JBossRMIClassLoader.loadProxyClass(JBossRMIClass
a:70)
  at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java

  at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputS
:238)
  at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:14
  at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:14
  at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.ja

  at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299
  at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
  at java.rmi.MarshalledObject.get(MarshalledObject.java:135)
  at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMP
xy.java:119)
  at org.jboss.invocation.InvokerInterceptor.invokeInvoker(InvokerInte
va:227)
  at org.jboss.invocation.MarshallingInvokerInterceptor.invoke(Marshal
rInterceptor.java:37)
  at org.jboss.proxy.TransactionInterceptor.invoke(TransactionIntercep
6)
  at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.ja

  at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:1
  at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:86)
  at $Proxy50.create(Unknown Source)
  at bus.Paging.doEndTag(Paging.java:58)
  at org.apache.jsp.helloWorld_jsp._jspx_meth_mt_paging_0(org.apache.j
rld_jsp:91)
  at org.apache.jsp.helloWorld_jsp._jspService(org.apache.jsp.helloWor

  at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
  at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWra
322)
  at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.ja

  at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorI
9)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodA
l.java:25)
  at java.lang.reflect.Method.invoke(Method.java:585)
  at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java

  at java.security.AccessController.doPrivileged(Native Method)
  at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
  at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.ja

  at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityU
61)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
nFilterChain.java:245)
  at org.apache.catalina.core.ApplicationFilterChain.access$000(Applic
rChain.java:50)
  at org.apache.catalina.core.ApplicationFilterChain$1.run(Application
n.java:156)
  at java.security.AccessController.doPrivileged(Native Method)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(Applicat
hain.java:152)
  at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHead
ava:81)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorI
9)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodA
l.java:25)
  at java.lang.reflect.Method.invoke(Method.java:585)
  at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java

  at java.security.AccessController.doPrivileged(Native Method)
  at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
  at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.ja

  at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityU
17)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
nFilterChain.java:197)
  at org.apache.catalina.core.ApplicationFilterChain.access$000(Applic
rChain.java:50)
  at org.apache.catalina.core.ApplicationFilterChain$1.run(Application
n.java:156)
  at java.security.AccessController.doPrivileged(Native Method)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(Applicat
hain.java:152)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrap
0
chaitu chaituAuthor Commented:
just tell me onething  if i want to acess one method in EJB deployed in another machine(in the form of ear;ejb's and custom classes are there),what classes do i add in my war.
0
sriki77Commented:
The NoClassDefFoundError occurs when the class is linked by the compiler and the class is absent during runtime. I mean, your EJB uses the DOCModel i guess, without which you couldn't haave compiled your EJB. During runtime its not finding the class.

Now, i accept that the classes are in the EAR, if the DOCModel class is part of a jar in the EAR, please put the jar in your WAR manifest - classpath. This is to say that my war uses the class files in the jar.

In the WAR Manifest.MF

Class-path: <jar containing DOCModel class>
or
Class-path: .

In the second case the classpath is set to the ear(. a dot) itself. This useful if your bus/DOCModel is directly in the EAR and not in any jar file.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chaitu chaituAuthor Commented:
"I mean, your EJB uses the DOCModel i guess"
yes.

not only that class so many classes are there in ejb.jar;this jar is part of ear.that application is working fine.

"please put the jar in your WAR manifest - classpath"

how to put??first of all there no manifest file is there in war.
0
chaitu chaituAuthor Commented:
THIS is MY PART OF build.xml file;how to create manifest file and add classpath into it..

<target name="build" description="Compile main source tree java files">  
<mkdir dir="${build.dir}"/>      
<javac destdir="${build.dir}" debug="on">
<src path="${src.dir}"/>
<classpath refid="master-classpath"/>  
</javac>  
</target>  
<target name="deploywar" depends="build" description="Deploy application as a WAR file">
<war destfile="${name}.war"    webxml="${web.dir}/WEB-INF/web.xml">    
<fileset dir="${web.dir}">            
<include name="**/*.*"/>        
</fileset>      
</war>    
<copy todir="${deploy.path}" preservelastmodified="true">  
<fileset dir=".">        
<include name="*.war"/>        
</fileset>      
</copy>
</target>
0
chaitu chaituAuthor Commented:
once again i am explaining ..


war(in this taghandler class i am trying to look up ejb business method in ear deployed in node2 instance) deployed in jboss/node1 instance..

ear deployed in jboss/node2 instance..


in war i added only home and remote of DocumentSession class in WEB/classes .(do i need these classes in war);;anything else do i add in war.
0
borislavmarkovCommented:
for normal lookup you need:

Home interfaces
Remote interfaces
Stubs and skeletons are loaded dynamically so you don't need them.
Anu custom classes that are passed as params to EJB or returned by the EJb are also NEEDED in WAR file.

Check if you didn't made any mess with classlaoders.
Put classes to be visible where your tag class is, same or parent classloader.
0
sriki77Commented:
The manifest file is th MANIFEST.MF in the war file.

I understand you put the home and remote classes.
 But does it have DOCModel class there? Add it if its not there

0
chaitu chaituAuthor Commented:
borislavmarkov ,sriki77

Once custom classes have added its starts working fine. only remote and home interfaces are enough to remote look up I THOUGHT custom classes will load dynamically(i added 5 custom class then its working fine.);

why do i need custom classes ?can't classloader load the classes dynamically?where the classloader reside??


0
borislavmarkovCommented:
I think it can load them dynamically , you can use DynClassLoader but it is much more complex to switch this option.
Why do you need that. Anyway in your code you have to cast them to something usable.

If you want further info on dynamic classloading maybe you should write another question.

COPY FROM JBOSS DOC:

EJB DynClassLoader. The EJB DynClassLoader node is a subclass of URLClassLoader that is used to provide RMI dynamic class loading via the simple HTTP WebService. It specifies an emptyURL[] and delegates to the TCL as its parent class loader. If the WebService is configured to allowsystem level classes to be loaded, all classes in the UnifiedLoaderRepository3 as well asthe system classpath are available via HTTP
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.