[jboss-user] [JBoss Seam] - Re: Seam EJB Injection Classloading issue
rafaelri
do-not-reply at jboss.com
Mon Oct 8 10:31:17 EDT 2007
Here goes a sample:
for foobean.jar
foo.bar.server.ejb.IFoo
| package foo.bar.server.ejb;
|
| public interface IFoo {
| public void bar();
| }
|
foo.bar.server.ejb.IFooRemote
| package foo.bar.server.ejb;
|
| import javax.ejb.Remote;
|
| @Remote
| public interface IFooRemote extends IFoo {
| }
|
foo.bar.server.ejb.impl.FooBean
| package foo.bar.server.ejb.impl;
|
| import javax.ejb.Stateless;
| import foo.bar.server.ejb.IFooRemote;
|
| @Stateless
| public class FooBean implements IFooRemote {
| public void bar() {
| System.out.println("FOOBAR");
| }
| }
|
and I have an ant target that packs up the contents of the foo.bar.server.ejb package as a jar to be added on WEB-INF/lib folder of the foo.war.
-----------------------------------------------------
for web application
components.xml
| <?xml version="1.0" encoding="UTF-8"?>
| <components xmlns="http://jboss.com/products/seam/components"
| xmlns:core="http://jboss.com/products/seam/core"
| xmlns:persistence="http://jboss.com/products/seam/persistence"
| xmlns:web="http://jboss.com/products/seam/web"
| xmlns:security="http://jboss.com/products/seam/security"
| xmlns:transaction="http://jboss.com/products/seam/transaction"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd
| http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd
| http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
| http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.0.xsd
| http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd">
|
| <core:init debug="true"/>
| <core:manager conversation-timeout="120000"
| concurrent-request-timeout="500" conversation-id-parameter="cid" />
| <component name="fooBean"
| scope="SESSION" jndi-name="FooBean/remote" auto-create="true"
| class="foo.bar.server.ejb.impl.FooBean">
| </component>
| </components>
|
web.xml
| <?xml version="1.0" encoding="UTF-8"?>
| <web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">
|
| <!-- Ajax4jsf filter not needed, Seam Filter installs it for us -->
|
| <context-param>
| <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
| <param-value>com.sun.facelets.FaceletViewHandler</param-value>
| </context-param>
|
| <!-- Seam -->
|
| <listener>
| <listener-class>
| org.jboss.seam.servlet.SeamListener
| </listener-class>
| </listener>
|
| <filter>
| <filter-name>Seam Filter</filter-name>
| <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
| </filter>
|
| <filter-mapping>
| <filter-name>Seam Filter</filter-name>
| <url-pattern>/*</url-pattern>
| </filter-mapping>
|
| <servlet>
| <servlet-name>Seam Resource Servlet</servlet-name>
| <servlet-class>
| org.jboss.seam.servlet.ResourceServlet
| </servlet-class>
| </servlet>
|
| <servlet-mapping>
| <servlet-name>Seam Resource Servlet</servlet-name>
| <url-pattern>/seam/resource/*</url-pattern>
| </servlet-mapping>
|
| <filter>
| <filter-name>Seam Filter</filter-name>
| <filter-class>org.jboss.seam.web.SeamFilter</filter-class>
| </filter>
|
| <filter-mapping>
| <filter-name>Seam Filter</filter-name>
| <url-pattern>/*</url-pattern>
| </filter-mapping>
|
| <!-- Faces Servlet -->
|
| <servlet>
| <servlet-name>Faces Servlet</servlet-name>
| <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
| <load-on-startup>1</load-on-startup>
| </servlet>
|
| <servlet-mapping>
| <servlet-name>Faces Servlet</servlet-name>
| <url-pattern>*.seam</url-pattern>
| </servlet-mapping>
|
|
| <!-- JSF parameters -->
|
| <context-param>
| <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
| <param-value>.xhtml</param-value>
| </context-param>
|
| <context-param>
| <param-name>facelets.DEVELOPMENT</param-name>
| <param-value>true</param-value>
| </context-param>
|
| <session-config>
| <session-timeout>10</session-timeout>
| </session-config>
|
| </web-app>
|
foo.bar.web.business.FooAction
| package foo.bar.web.business;
|
| import java.io.Serializable;
|
| import org.jboss.seam.ScopeType;
| import org.jboss.seam.annotations.In;
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.annotations.Scope;
|
| import foo.bar.server.ejb.IFooRemote;
|
| @Name("foo")
| @Scope(ScopeType.APPLICATION)
| public class FooAction implements Serializable {
|
| @In
| IFooRemote fooBean;
|
| public void bar() {
| fooBean.bar();
| }
|
| }
|
foo.xhtml
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
| "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
| <html xmlns="http://www.w3.org/1999/xhtml"
| xmlns:ui="http://java.sun.com/jsf/facelets"
| xmlns:h="http://java.sun.com/jsf/html"
| xmlns:f="http://java.sun.com/jsf/core"
| xmlns:s="http://jboss.com/products/seam/taglib"
| xmlns:a="https://ajax4jsf.dev.java.net/ajax"
| xmlns:rich="http://richfaces.org/rich">
| <head>
| <title>FooForm</title>
| </head>
| <f:view contentType="text/html" />
| <body>
| <h:form id="fooForm">
| <h:commandButton value="foo" id="foo" action="#{foo.bar}"/>
|
|
| </h:form>
| </body>
| </html>
|
--------------------------------------------
I am not deploying as an EAR since the project is still under development, so I have an ant target that recreates the war and calls the JBoss JMX Bean for deploying the WAR/JAR in my workspace. Anyways, when I deploy it as an EAR I'll setup links for the SessionBeans using jboss.xml file in order to make them have the same JNDI name.
If you prefer that I upload to somewhere the Eclipse projects just post a message and I can upload them (with build scripts and etc).
best regards,
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4092589#4092589
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4092589
More information about the jboss-user
mailing list