deploying myfaces-example-simple20-1.1.11.war in a JBoss 5.1.0 - EL issue
by Érico
Hi
I am trying to run myfaces-example-simple20-1.1.
11 in a JBoss 5.1.0 and I am getting the following error :
Error:
javax.faces.application.Application.createComponent(Ljavax/faces/context/FacesContext;Ljava/lang/String;Ljava/lang/String;)Ljavax/faces/component/UIComponent;
I have tried several changes in the deployment descriptor and removing
myfaces and el jar files from the project but none worked
my web.xml is as follows :
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="
http://java.sun.com/xml/ns/javaee" xmlns:web="
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<description>debug web.xml</description>
<context-param>
<description>Comma separated list of URIs of (additional) faces config
files.
(e.g. /WEB-INF/my-config.xml)
See JSF 1.0 PRD2, 10.3.2
Attention: You do not need to put /WEB-INF/faces-config.xml in
here.
</description>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/examples-config.xml,/WEB-INF/testSuite-config.xml</param-value>
</context-param>
<context-param>
<description>State saving method: "client" or "server" (= default)
See JSF Specification 2.5.3</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<description>Only applicable if state saving method is "server" (=
default).
Defines the amount (default = 20) of the latest views are
stored in session.</description>
<param-name>org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION</param-name>
<param-value>20</param-value>
</context-param>
<context-param>
<description>Only applicable if state saving method is "server" (=
default).
If true (default) the state will be serialized to a byte stream
before it
is written to the session.
If false the state will not be serialized to a byte
stream.</description>
<param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>Only applicable if state saving method is "server" (=
default) and if
org.apache.myfaces.SERIALIZE_STATE_IN_SESSION is true (=
default)
If true (default) the serialized state will be compressed
before it
is written to the session. If false the state will not be
compressed.</description>
<param-name>org.apache.myfaces.COMPRESS_STATE_IN_SESSION</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>This parameter tells MyFaces if javascript code should be
allowed in the
rendered HTML output.
If javascript is allowed, command_link anchors will have
javascript code
that submits the corresponding form.
If javascript is not allowed, the state saving info and nested
parameters
will be added as url parameters.
Default: "true"</description>
<param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<description>If true, rendered HTML code will be formatted, so that it
is "human readable".
i.e. additional line separators and whitespace will be written,
that do not
influence the HTML code.
Default: "true"</description>
<param-name>org.apache.myfaces.PRETTY_HTML</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>If true, a javascript function will be rendered that is
able to restore the
former vertical scroll on every request. Convenient feature if
you have pages
with long lists and you do not want the browser page to always
jump to the top
if you trigger a link or button action that stays on the same
page.
Default: "false"</description>
<param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>
Validate managed beans, navigation rules and ensure that
forms are not nested.
</description>
<param-name>org.apache.myfaces.VALIDATE</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>A class implementing the
org.apache.myfaces.shared.renderkit.html.util.AddResource
interface. It is responsible to
place scripts and css on the right position in your HTML
document.
Default:
"org.apache.myfaces.shared.renderkit.html.util.DefaultAddResource"
Follow the description on the MyFaces-Wiki-Performance page to
enable
StreamingAddResource instead of DefaultAddResource if you want
to
gain performance.
</description>
<param-name>org.apache.myfaces.ADD_RESOURCE_CLASS</param-name>
<!--
param-value>org.apache.myfaces.renderkit.html.util.DefaultAddResource</param-value
-->
<param-value>org.apache.myfaces.renderkit.html.util.NonBufferingAddResource</param-value>
<!--param-value>org.apache.myfaces.component.html.util.StreamingAddResource</param-value
-->
</context-param>
<context-param>
<param-name>org.apache.myfaces.DISABLE_TOMAHAWK_FACES_CONTEXT_WRAPPER</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<description>
A very common problem in configuring MyFaces-web-applications
is that the Extensions-Filter is not configured at all
or improperly configured. This parameter will check for a properly
configured Extensions-Filter if it is needed by the web-app.
In most cases this check will work just fine, there might be cases
where an internal forward will bypass the Extensions-Filter and the
check
will not work. If this is the case, you can disable the check by
setting
this parameter to false.
</description>
<param-name>org.apache.myfaces.CHECK_EXTENSIONS_FILTER</param-name>
<param-value>true</param-value>
</context-param>
<!-- JBossEL -->
<context-param>
<param-name>org.apache.myfaces.EXPRESSION_FACTORY</param-name>
<param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.USE_MULTIPLE_JS_FILES_FOR_JSF_UNCOMPRESSED_JS</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<filter>
<filter-name>extensionsFilter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
<init-param>
<description>Set the size limit for uploaded files.
Format: 10 - 10 bytes
10k - 10 KB
10m - 10 MB
1g - 1 GB</description>
<param-name>uploadMaxFileSize</param-name>
<param-value>100m</param-value>
</init-param>
<init-param>
<description>Set the threshold size - files
below this limit are stored in memory, files above
this limit are stored on disk.
Format: 10 - 10 bytes
10k - 10 KB
10m - 10 MB
1g - 1 GB</description>
<param-name>uploadThresholdSize</param-name>
<param-value>100k</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>*.jsf</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>/faces/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>SourceCodeServlet</servlet-name>
<servlet-class>org.apache.myfaces.examples.webapp.SourceCodeServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SourceCodeServlet</servlet-name>
<url-pattern>*.source</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
I have also created a jboss-classloading.xml in WEB-INF directory in my war
file with the following content :
<classloading xmlns="urn:jboss:classloading:1.0"
name="myfaces-example-simple20-1.1.11.war"
domain="localhost">
parent-domain="Ignored"
export-all="NON_EMPTY"
import-all="true">
</classloading>
Can you guys help us out on this ? I can not change the JBoss version ...
Thks
Érico
13 years
[Javassist] - Problems with the tomcat classloader
by Roland Käser
Roland Käser [http://community.jboss.org/people/roli82001] created the discussion
"Problems with the tomcat classloader"
To view the discussion, visit: http://community.jboss.org/message/639418#639418
--------------------------------------------------------------
Hello
While developing a very small and lightweight j2ee linke server, I try to extend a abstract class at runtime using:
ClassPool pool = ClassPool.getDefault();
pool.insertClassPath(new ClassClassPath(this.getClass()));
CtClass cc = pool.makeClass("HelloWorldClientBean");
cc.setSuperclass(pool.get("ch.isn.dante.comserver.test.HelloWorldSessionBean"));
Class beanClass = cc.toClass();
cc.defrost();
Constructor constructor = beanClass.getConstructor(argsClass);
Object[] params = new Object[]{new ComServerSession(),null};
HelloWorldSessionBean sessionBean = (HelloWorldSessionBean)constructor.newInstance(params);
System.out.println("Hello World Output: " + sessionBean.getHelloWorld());
This works fine on the client side (regular java vm).
On the server side I get first a very strange exception which was stangely related to the tomcats classloader.
javassist.CannotCompileException: by java.lang.LinkageError: loader (instance of org/apache/catalina/loader/WebappClassLoader): attempted duplicate class definition for name: "ch/isn/dante/comserver/test/HelloWorldSessionBeanExecutable"
javassist.CannotCompileException: by java.lang.LinkageError: loader (instance of org/apache/catalina/loader/WebappClassLoader): attempted duplicate class definition for name: "ch/isn/dante/comserver/test/HelloWorldSessionBeanExecutable"
at javassist.ClassPool.toClass(ClassPool.java:1089)
at javassist.ClassPool.toClass(ClassPool.java:1032)
at javassist.ClassPool.toClass(ClassPool.java:990)
at javassist.CtClass.toClass(CtClass.java:1125)
...
Caused by: java.lang.LinkageError: loader (instance of org/apache/catalina/loader/WebappClassLoader): attempted duplicate class definition for name: "ch/isn/dante/comserver/test/HelloWorldSessionBeanExecutable"
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.lang.ClassLoader.defineClass(ClassLoader.java:465)
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:597)
at javassist.ClassPool.toClass2(ClassPool.java:1102)
at javassist.ClassPool.toClass(ClassPool.java:1083)
To prevent this I wrote a very ugly hack to use the system class loader and add the classpath in which this superclass:
|
|
|
| URL url = new File(serverServlet.getInstallDir() + "WEB-INF/classes/").toURL(); |
|
|
|
| URLClassLoader sysloader = (URLClassLoader) ClassLoader.getSystemClassLoader(); |
|
|
|
| Class sysclass = URLClassLoader.class; |
|
|
|
|
|
|
|
|
| Method method = sysclass.getDeclaredMethod("addURL", parameters); |
|
|
|
| method.setAccessible(true); |
|
|
|
| method.invoke(sysloader, new Object[]{url}); |
and created the class using this modified classloader:
|
|
| Class beanClass = cc.toClass(sysloader); |
|
|
|
|
|
| cc.defrost(); |
Now I get a NoSuchMethodException:
java.lang.NoSuchMethodException: HelloWorldServerBean.<init>(ch.isn.dante.comserver.server.ComServerSession, ch.isn.dante.comserver.server.ServerApplication)
at java.lang.Class.getConstructor0(Class.java:2706)
at java.lang.Class.getConstructor(Class.java:1657)
at ch.isn.dante.comserver.server.ComServerSession.loadClass(ComServerSession.java:239)
at ch.isn.dante.comserver.server.ComServer.doGet(ComServer.java:286)
at ch.isn.dante.comserver.server.ComServer.doPost(ComServer.java:417)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
I can't see from which this error comes. When I inspect the newly created class I get one constructor:
public HelloWorldClientBean(ch.isn.dante.comserver.server.ComServerSession,ch.isn.dante.comserver.server.ServerApplication)
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/639418#639418]
Start a new discussion in Javassist at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
13 years