Discussions

Web tier: servlets, JSP, Web frameworks: Problem using Struts with Weblogic

  1. Problem using Struts with Weblogic (4 messages)

    Hi,
    I am using Eclipse - Lomboz - Weblogic 8.1 combination for application development. I have a web application developed using the struts framework. When I deploy this web application as a war file, everything works fine. But when I create a EAR package with the web application and a couple of EJB jars and try to deploy the application, I am getting the following error message when the Action Servlet is loaded by the web container:

    07/02/2005 | 14:04:15 | ERROR | Digester | startElement | Begin event threw exception
    java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.java:1789)
    at org.apache.commons.beanutils.PropertyUtils.setNestedProperty(PropertyUtils.java:1684)
    at org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.java:1713)
    at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1019)
    at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
    at org.apache.commons.digester.SetPropertiesRule.begin(SetPropertiesRule.java:259)
    at org.apache.commons.digester.Rule.begin(Rule.java:200)
    at org.apache.commons.digester.Digester.startElement(Digester.java:1273)
    at weblogic.apache.xerces.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:459)
    at weblogic.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:221)
    at weblogic.apache.xerces.impl.xs.XMLSchemaValidator.emptyElement(XMLSchemaValidator.java:618)
    at weblogic.apache.xerces.impl.XMLNamespaceBinder.handleStartElement(XMLNamespaceBinder.java:874)
    at weblogic.apache.xerces.impl.XMLNamespaceBinder.emptyElement(XMLNamespaceBinder.java:591)
    at weblogic.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidator.java:748)
    at weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:747)
    at weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1477)
    at weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:329)
    at weblogic.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:525)
    at weblogic.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:581)
    at weblogic.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
    at weblogic.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1175)
    at weblogic.xml.jaxp.WebLogicXMLReader.parse(WebLogicXMLReader.java:135)
    at weblogic.xml.jaxp.RegistryXMLReader.parse(RegistryXMLReader.java:152)
    at org.apache.commons.digester.Digester.parse(Digester.java:1548)
    at org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionServlet.java:708)
    at org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet.java:670)
    at org.apache.struts.action.ActionServlet.init(ActionServlet.java:329)
    at javax.servlet.GenericServlet.init(GenericServlet.java:258)
    at weblogic.servlet.internal.ServletStubImpl$ServletInitAction.run(ServletStubImpl.java:1018)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
    at weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java:894)
    at weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStubImpl.java:873)
    at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:812)
    at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:3281)
    at weblogic.servlet.internal.WebAppServletContext.preloadServlets(WebAppServletContext.java:3226)
    at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:3207)
    at weblogic.servlet.internal.HttpServer.preloadResources(HttpServer.java:694)
    at weblogic.servlet.internal.WebService.preloadResources(WebService.java:483)
    at weblogic.servlet.internal.ServletInitService.resume(ServletInitService.java:30)
    at weblogic.t3.srvr.SubsystemManager.resume(SubsystemManager.java:131)
    at weblogic.t3.srvr.T3Srvr.resume(T3Srvr.java:966)
    at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:361)
    at weblogic.Server.main(Server.java:32)
    Caused by: java.lang.NoClassDefFoundError: org/apache/struts/validator/ValidatorActionForm
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
    at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:476)
    at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:181)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:282)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
    at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:223)
    at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:41)
    at org.apache.struts.config.FormBeanConfig.formBeanClass(FormBeanConfig.java:360)
    at org.apache.struts.config.FormBeanConfig.setType(FormBeanConfig.java:154)

    The cause for the IncocationTargetException is mentioned as a NoClassDefFoundError on org.apache.struts.validator.ValidatorActionForm. But the struts.jar file is in the WEB-INF\lib directory of the war file. More importantly nothing in the war file is changed when packaged as a EAR file.

    Any suggestions on where to look would be highly appreciated.

    Thanks,
    Balaji.

    Threaded Messages (4)

  2. none[ Go to top ]

    Hi,

    I think long back BEA has acknowledged a bug in that jars residing in the Application ClassLoader (included in the EAR) won't be loaded, not sure if 8.1 still has this issue. They have to be included in the EJB Jars that are placed in the EAR to be loaded and used by both EJB's and web apps. However the Struts classes shouldn't be needed from the EJBs so you could just include them in WEB-INF/lib.

    Ash
  3. Problem using Struts with Weblogic[ Go to top ]

    Hi Ash,
    Thanks for your reply. The struts.jar is already available in the WEB-INF/lib folder and it is not required by any of the EJBs that I have. It is required only by the web application. The following is the dir. structure of the ear file (only the relevant paths).

    .(top level)
    myejb.jar
    utility1.jar
    utility2.jar
    mywebapplication.war
    --->WEB-INF\lib
          struts.jar

    Still I am getting the exception mentioned, when the application is packaged as an EAR file.

    TIA
    Balaji.
  4. none[ Go to top ]

    Set the <prefer-web-inf-classes> element of weblogic.xml to true, this will cause classes located in the WEB-INF directory of a Web application to be loaded in preference to classes loaded in the application or system classloader.

    Ash
  5. Hi Ash,
    Thanks for the solution. The EJB Jar file contained the Action classes of the web application. That caused the problem because when the servlet is loaded, the root class loader loaded the servlet class from the EJB Jar, but it could not find the struts related classes as they are inside web-inf/lib of the web module and hence invisible to the root class loader. When I removed all the web module related classes from the ejb jar, the problem went away. I am sure the solution of using the <prefer-web-inf-classes> would also work.

    Thanks,
    Balaji.