EJB 3.0 client side dependency injection
Hi,
I develop an EJB 3.0 based enterprise application using Sun Java System Application Server. The application includes a Swing based client to be launched via Java WebStart. The client has to access some of the EJBs. Is it possible to use dependency injection on client side (see the @EJB annotation) and if yes how do I set the properties for this?
The following snipped hopefully explains what I mean. The class FastEntry is a class of the Swing client. My question is how can I get the deviceSessionBean initialized?
public class FastEntry extends javax.swing.JFrame {
@EJB
private static DeviceSessionRemote deviceSessionBean;Kind regards,
Matthias
Hi,
For callbacks and interceptors, you can look at this page : http://today.java.net/pub/a/today/2005/08/18/ejb3.html
For sending messages, I'd recommend to use JMS (if in clientSide), or EJB3 Message beans if in server side.
Hope that helps :)
Similar Messages
-
Client side dependant session tracking
Hi,
does Cookies, URL Rewriting and Httpsession depend on the client side settings?
Thanks.That will happen automatically if the cookies are disabled on the client side. No worries about it.
-
Dependency Injection Problem in EJB 3.0
Hello.
I've been trying to get an example of java dependency injection working in JBoss 4.0.5.GA. I've installed it with EJB 3.0 support.
The problem is that if I try to use the injected resource, I get a null pointer exception.
The example I'm trying is a very short and simple one. Shouldn't be hard to figure out what is going wrong. Here it goes:
[root]\src\hello\MessageServlet.java:
package hello;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.List;
import java.util.ListIterator;
import javax.naming.InitialContext;
import javax.annotation.*;
public class MessageServlet extends HttpServlet {
@Resource (mappedName="java:/DefaultDS")
javax.sql.DataSource ejb30DB;
public void init () throws ServletException {
public void service(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
boolean injectedLookingGood = false;
boolean notInjectedLookingGood = false;
try {
java.sql.Connection conn = ejb30DB.getConnection();
conn.close();
injectedLookingGood = true;
} catch(Exception e) {
e.printStackTrace();
try {
InitialContext ic = new InitialContext();
javax.sql.DataSource ds = (javax.sql.DataSource)ic.lookup("java:/DefaultDS");
java.sql.Connection conn = ds.getConnection();
conn.close();
notInjectedLookingGood = true;
} catch(Exception e) {
e.printStackTrace();
response.setContentType("text/html");
ServletOutputStream out = response.getOutputStream();
out.println("<html>");
out.println("<head><title>Hello World</title></head>");
out.println("<body>");
out.println("<h1>Hello World</h1>");
out.println("<form action=\"HelloWorld\" method=\"get\">");
out.print("Injected DataSource is looking ");
if(injectedLookingGood) {
out.println("good <br>");
else {
out.println("bad <br>");
out.print("Not-Injected DataSource is looking ");
if(notInjectedLookingGood) {
out.println("good <br/>");
else {
out.println("bad <br/>");
out.println("<input type=\"submit\" value=\"Test Some More\">");
out.println("</form>");
out.println("</body>");
out.println("</html>");
[root]\etc\META-INF\web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<display-name>HelloWorldWAR</display-name>
<servlet>
<display-name>HelloWorld</display-name>
<servlet-name>HelloWorldServlet</servlet-name>
<servlet-class>hello.MessageServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorldServlet</servlet-name>
<url-pattern>/servlet/HelloWorld</url-pattern>
</servlet-mapping>
</web-app>
[root]\etc\META-INF\application.xml:
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
<display-name>HelloWorld</display-name>
<description>Application description</description>
<module>
<web>
<web-uri>web-ejb3.war</web-uri>
<context-root>HelloWorld</context-root>
</web>
</module>
</application>
[root]\build.xml:
<project name="HelloWorld" default="all" basedir=".">
<!-- Name of project and version -->
<property name="proj.name" value="HelloWorld"/>
<property name="proj.version" value="1.0"/>
<!-- Global properties for thid build -->
<property name="src.dir" value="${basedir}/src"/>
<property name="build.dir" value="${basedir}/bin"/>
<property name="lib.dir" value="${basedir}/lib"/>
<property name="build.classes.dir" value="${build.dir}/classes"/>
<property name="build.jar.dir" value="${build.dir}/jar"/>
<property name="src.etc.dir" value="${basedir}/etc"/>
<property name="meta-inf.dir" value="${src.etc.dir}/META-INF"/>
<!-- The build classpath -->
<path id="build.classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
<include name="**/*.zip"/>
</fileset>
</path>
<!-- Useful shortcuts -->
<patternset id="meta.files">
<include name="**/*.xml" />
<include name="**/*.properties"/>
</patternset>
<target name="prepare">
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.classes.dir}"/>
<mkdir dir="${build.jar.dir}"/>
</target>
<target name="compile" depends="prepare">
<javac destdir="${build.classes.dir}"
classpathref="build.classpath"
debug="on">
<src path="${src.dir}"/>
</javac>
</target>
<target name="package-web" depends="compile">
<war warfile="${build.dir}/jar/web-ejb3.war"
webxml="${meta-inf.dir}/web.xml">
<classes dir="${build.dir}/classes">
<include name="**/*Servlet.class"/>
</classes>
</war>
</target>
<!-- Creates an ear file containing the web client war. -->
<target name="assemble-app">
<ear destfile="${build.jar.dir}/HelloWorld.ear" appxml="${meta-inf.dir}/application.xml">
<fileset dir="${build.dir}/jar"
includes="*.war"/>
</ear>
</target>
<target name="clean">
<delete dir="${build.dir}" />
</target>
<target name="all">
<antcall target="clean" />
<antcall target="package-web" />
<antcall target="assemble-app" />
</target>
</project>
Any help would be apreciated.
Thanks in advance,
Hugo Oliveira
[email protected]Hello Ken.
I gess dependency injection is unnavailable in servlets as of this moment. I conducted another test using a session bean that injects and tests the DataSource and a servlet calling the session bean via a refference obtained from InitialContext. It worked OK.
Here's the code:
[root]/src/hello/MessageHandler.java:
package hello;
public interface MessageHandler {
public boolean testInjection();
[root]/src/hello/MessageHandlerBean.java:
package hello;
import javax.ejb.Stateless;
import javax.persistence.*;
import java.util.List;
import javax.annotation.*;
@Stateless
public class MessageHandlerBean implements MessageHandler {
@Resource (mappedName="java:/DefaultDS")
private javax.sql.DataSource ds;
public boolean testInjection() {
try {
java.sql.Connection conn = ds.getConnection();
conn.close();
return true;
} catch(Exception e) {
e.printStackTrace();
return false;
[root]/src/hello/MessageServlet.java:
package hello;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.List;
import java.util.ListIterator;
import javax.naming.InitialContext;
import javax.annotation.*;
public class MessageServlet extends HttpServlet {
public void init () throws ServletException {
public void service(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
boolean injectedLookingGood = false;
try {
InitialContext ic = new InitialContext();
MessageHandler mh = (MessageHandler)ic.lookup("HelloWorld/MessageHandlerBean/local");
injectedLookingGood = mh.testInjection();
} catch(Exception e) {
e.printStackTrace();
response.setContentType("text/html");
ServletOutputStream out = response.getOutputStream();
out.println("<html>");
out.println("<head><title>Hello World</title></head>");
out.println("<body>");
out.println("<h1>Hello World</h1>");
out.println("<form action=\"HelloWorld\" method=\"get\">");
out.print("Injected DataSource is looking ");
if(injectedLookingGood) {
out.println("good <br>");
else {
out.println("bad <br>");
out.println("<input type=\"submit\" value=\"Test Some More\">");
out.println("</form>");
out.println("</body>");
out.println("</html>");
[root]/etc/META-INF/application.xml:
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
<display-name>HelloWorld</display-name>
<description>Application description</description>
<module>
<ejb>HelloWorld.ejb3</ejb>
</module>
<module>
<web>
<web-uri>web-ejb3.war</web-uri>
<context-root>HelloWorld</context-root>
</web>
</module>
</application>
[root]/etc/META-INF/web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>HelloWorldWAR</display-name>
<servlet>
<display-name>HelloWorld</display-name>
<servlet-name>HelloWorldServlet</servlet-name>
<servlet-class>hello.MessageServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorldServlet</servlet-name>
<url-pattern>/servlet/HelloWorld</url-pattern>
</servlet-mapping>
</web-app>
[root]/build.xml:
<project name="HelloWorld" default="all" basedir=".">
<!-- Name of project and version -->
<property name="proj.name" value="HelloWorld"/>
<property name="proj.version" value="1.0"/>
<!-- Global properties for thid build -->
<property name="src.dir" value="${basedir}/src"/>
<property name="build.dir" value="${basedir}/bin"/>
<property name="lib.dir" value="${basedir}/lib"/>
<property name="build.classes.dir" value="${build.dir}/classes"/>
<property name="build.jar.dir" value="${build.dir}/jar"/>
<property name="src.etc.dir" value="${basedir}/etc"/>
<property name="meta-inf.dir" value="${src.etc.dir}/META-INF"/>
<!-- The build classpath -->
<path id="build.classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
<include name="**/*.zip"/>
</fileset>
</path>
<!-- Useful shortcuts -->
<patternset id="meta.files">
<include name="**/*.xml" />
<include name="**/*.properties"/>
</patternset>
<target name="prepare">
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.classes.dir}"/>
<mkdir dir="${build.jar.dir}"/>
</target>
<target name="compile" depends="prepare">
<javac destdir="${build.classes.dir}"
classpathref="build.classpath"
debug="on">
<src path="${src.dir}"/>
</javac>
</target>
<target name="package-ejb" depends="compile">
<jar jarfile="${build.jar.dir}/HelloWorld.ejb3">
<fileset dir="${build.classes.dir}">
<include name="**/*.class"/>
</fileset>
<!--
<metainf dir="${meta-inf.dir}">
<include name="persistence.xml"/>
</metainf>
-->
</jar>
</target>
<target name="package-web" depends="compile">
<war warfile="${build.dir}/jar/web-ejb3.war"
webxml="${meta-inf.dir}/web.xml">
<!--
<fileset dir="web">
<include name="**/*"/>
</fileset>
-->
<!--
<webinf dir="dd/web">
<include name="jboss-web.xml"/>
</webinf>
-->
<classes dir="${build.dir}/classes">
<include name="**/*Servlet.class"/>
</classes>
</war>
</target>
<!-- Creates an ear file containing the ejb jars and the web client war. -->
<target name="assemble-app">
<ear destfile="${build.jar.dir}/HelloWorld.ear" appxml="${meta-inf.dir}/application.xml">
<fileset dir="${build.dir}/jar"
includes="*.ejb3,*.war"/>
</ear>
<!-- <delete file="${build.dir}/jar/web-ejb3.war"/>
<delete dir="${build.dir}/classes"/> -->
</target>
<target name="clean">
<delete dir="${build.dir}" />
</target>
<target name="all">
<antcall target="clean" />
<antcall target="package-ejb" />
<antcall target="package-web" />
<antcall target="assemble-app" />
</target>
</project>
Thanks,
Hugo Oliveira
[email protected] -
EJB 3.0 Why Dependency Injection doesn't work?
Hello Every body,
i have a serious problem with dependency injection with EJB 3.0. I have tried so many time to get the simple sun delivered samples ejb-Applications working in NetBeans IDE, but they don't. After importing in building the projects in NetBeans, i get a NullPointerException while trying to run them. Is there any body who have experience with this? What am i making wrong?
I searched for an answer since several days in google without any success. I have not found a single satisfactory explanation. I can't explain why even the examples in the java ee tutorials don't work.
Please, can somebody help? I would very greatful.
Cheers
flips
Here is an example of application (that don't work because the injection failed):
* This is the business interface for Confirmer enterprise bean.
@Remote
public interface Confirmer {
void sendNotice(String recipient);
@Stateless
public class ConfirmerBean implements Confirmer {
private static final String mailer = "JavaMailer";
private static Logger logger = Logger.getLogger(
"confirmer.ejb.ConfirmerBean");
@Resource(name = "mail/myMailSession")
private Session session;
/** Creates a new instance of ConfirmerBean */
public ConfirmerBean() {
public void sendNotice(String recipient) {
try {
Message message = new MimeMessage(session);
message.setFrom();
message.setRecipients(
Message.RecipientType.TO,
InternetAddress.parse(recipient, false));
message.setSubject("Test Message from ConfirmerBean");
DateFormat dateFormatter = DateFormat.getDateTimeInstance(
DateFormat.LONG,
DateFormat.SHORT);
Date timeStamp = new Date();
String messageText = "Thank you for your order." + '\n'
+ "We received your order on "
+ dateFormatter.format(timeStamp) + ".";
message.setText(messageText);
message.setHeader("X-Mailer", mailer);
message.setSentDate(timeStamp);
// Send message
Transport.send(message);
logger.info("Mail sent to " + recipient + ".");
} catch (MessagingException ex) {
ex.printStackTrace();
logger.info("Error in ConfirmerBean for " + recipient);
* @author ie139813
public class ConfirmerClient {
@EJB
private static Confirmer confirmer;
/** Creates a new instance of ConfirmerClient */
public ConfirmerClient() {
* @param args the command line arguments
public static void main(String[] args) {
String recipient = null;
if (args.length == 1) {
recipient = args[0];
} else {
recipient = "[email protected]";
try {
confirmer.sendNotice(recipient);
System.out.println("Message sent to " + recipient + ".");
System.exit(0);
} catch (Exception ex) {
ex.printStackTrace();
}Try rebooting your computer. I had something similar. I rebooted my computer and it finished the update. Good luck!
-
EJB 3.0 Dependency Injection and reentrant Calls on SFSB
Hi there
I have a SFSB (Bean A) that injects another SFSB (Bean B) with the @EJB annotation. Now Bean A does reentrant-calls on Bean B, which is ok, because it just asks for the current state.
This results in a "javax.ejb.EJBTransactionRolledbackException: Illegal attempt to make a reentrant call to a stateful session bean from home: .....; nested exception is: javax.ejb.ConcurrentAccessException: Illegal attempt to make a reentrant call to a stateful session bean: ....."
Now I added a weblogic-ejb-jar.xml with the section:
<stateful-session-descriptor>
<allow-concurrent-calls>true</allow-concurrent-calls>
</stateful-session-descriptor>to enable reentrant calls on my SFSB. Unfortunatly this leads to problems with the DI, it simply doesnt work anymore!!! The message now is " java.lang.IllegalStateException: Cannot find object BeanBInterface with java:comp/env/ejb/BeanBInterface". Obviously the DI didn't work, the local variable isn't filled anmyore.
Is this a bug of WLS 10.0 MP1 or a feature? Should I open a bug report? Any tips a welcome!
StephanThere is currently no possiblity in Weblogic 10 server web layer to use Dependency Injection on any other component than the ones defined in web.xml s.a.:
- servlets
- listeners
- filters
See here:
http://e-docs.bea.com/wls/docs100/webapp/annotateservlet.html
A simple POJO class part of the web application (such as a Backing Bean in JSF or an Action in Struts for example) is not benefiting from DI.
Doesn't this make Weblogic 10 a NON JEE 5 compliant server?
Why was this restriction imposed?
And how is one supposed to use DI with a simple POJO class? Why this huge inconvenience? -
EJB 3.0 Dependency Injection in JSF ?
Hi,
I have a question about ejb 3.0 dependency injection in a JSF WebApp:
I Build successfully a Web Module (version 2.5) an EJB Module (version 3.0) and an EAR Module (Version 5.0). The EAR App can be deployed without errors on a Bea WebLogic Server 10.1. All modules are successfully deployed.
Inside the Web Module there is a Servlet which uses dependency injection to access the session EJB form the EJB Module. This works perfect.
Next I try to use the same EJB with dependency injection from the JSF Page via a backing bean. But when I try to access my JSP Page I got a Nullpointer Exception.
It seems that the Dependency Injection in the JSP App did not work?
Can anybody give me a hint what could be wrong?
Thanks
RalphThere is currently no possiblity in Weblogic 10 server web layer to use Dependency Injection on any other component than the ones defined in web.xml s.a.:
- servlets
- listeners
- filters
See here:
http://e-docs.bea.com/wls/docs100/webapp/annotateservlet.html
A simple POJO class part of the web application (such as a Backing Bean in JSF or an Action in Struts for example) is not benefiting from DI.
Doesn't this make Weblogic 10 a NON JEE 5 compliant server?
Why was this restriction imposed?
And how is one supposed to use DI with a simple POJO class? Why this huge inconvenience? -
How can i look up a EJB residing in different machine from client side?
hai ,
How can i look up a EJB residing in different machine from client side?
this is my code...........i don't know what should i use as Initial Context Factory...................i am using a sun appserver 8............
package com.parx.lms.lmsdelegate;
import com.parx.lms.exception.LMSException;
import javax.naming.Context;
import javax .ejb.CreateException;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
import java.rmi.RemoteException;
import com.parx.lms.controller.*;
import com.parx.lms.vo.UserVo;
import com.parx.lms.exception.BusinessException;
import java.util.Hashtable;
import java.lang.*;
public class LmsDelegate{
private final static String JNDI_NAME="LmsBean";
private static String url="http://localhost:4848";
public static Lms lms = null;
public void getController() throws CreateException,
NamingException,RemoteException{
if(lms == null){
Hashtable h=new Hashtable();
h.put(Context.INITIAL_CONTEXT_FACTORY," ********what should i use here???????*************************");
h.put(Context.PROVIDER_URL,url);
System.out.println("Before Loading Context in Delegate");
Context ctx=new InitialContext(h);
System.out.println("Loaded Context in Delegate");
Object obj=ctx.lookup(JNDI_NAME);
System.out.println("Loaded Object in Delegate");
System.out.println("Before Loading Home in Delegate");
LmsHome home = (LmsHome )PortableRemoteObject.narrow(obj,com.parx.lms.controller.LmsHome.class);
System.out.println("Loaded Home in Delegate");
lms = home.create();
System.out.println("Loaded remote in Delegate");
public void addUserDelegate(UserVo vo) throws BusinessException{
try{
getController();
System.out.println("Before calling the addUser of Session");
lms.addUser(vo);
}catch(CreateException e){
System.out.println("Create Exception in Delegate due to--->"+e);
e.printStackTrace();
throw new BusinessException(e);
}catch(NamingException e){
System.out.println("Naming Exception in Delegate due to--->"+e);
e.printStackTrace();
throw new BusinessException(e);
catch(RemoteException e){
System.out.println("Remote Exception in Delegate due to--->"+e);
e.printStackTrace();
throw new BusinessException(e);
}catch(LMSException e){
System.out.println("duplicate user name--->"+e);
e.printStackTrace();
throw new BusinessException(e);
pls help me..........h.put(Context.INITIAL_CONTEXT_FACTORY," ********what should i use here???????*************************")
Each app server provides their own jndi factory class. For ex for weblogic it is weblogic.jndi.WLInitialContextFactory. SInce you are using sun app server, check if there are any examples to find out or the docs.
private static String url="http://localhost:4848
Since the client is in a different machine the localhost is not going to work here. provide the url or the machine name of the system in which ur sunapp server is running. In addition u will need to have the stubs of the remote interfaces in ur client machine. -
ADFc 11g: EJB Dependency injection
Hello everyone,
I'm using a managed bean which references a stateless session EJB 3.0:
public class MyManagedBean {
@EJB
private SessionEJB ejb;
}If the bean is managed by JSF (ie. is registered in faces-config) then the EJB is injected correctly, but if the EJB is managed by ADF (ie. is registered in adfc-config) then there is no dependency injection. Does anybody know why this is so, and if there is a clean solution to the problem?
Searching the forum, Duncan Mills recommends a bean managed with faces-config in which the EJBs are injected, and then use managed properties to inject those EJBs in the ADF-managed beans.
Re: Accessing session beans from a managed bean
Is there a better/simpler solution?
Thanks!
Juan ManuelThank you.
The link helped.
The one thing i did was created a remote interface for the ejb, which showed up in jndi and then used spring DI to inject a reference to the EJB from jndi.
Will using a remote interface (instead of a local interface) cause performance issues? -
When to use @Resource and when to use @EJB for dependency injection
Hi,
When do you use
@Resource and when do you use @EJB for dependency injection?
ThanksCaptain obvious: Use @EJB for injection of EJBs, and @Resource for everything else.
There was a discussion about this very topic quite recently, perhaps you can find it through the search. -
Dependency inject a EJB 2.x bean with EJB3
Hi there
I have an old EJB3 2.x bean deployed on my server, that is registered in JNDI with the name "abc/xyz/ItemLookup_v35".
Now I wrote a EJB3 SFSB bean and I want to access the old bean using dependency injection. I tried it with the annotation
@EJB(mappedName = "abc/xyz/ItemLookup_v35")
private ItemLookupRemote itemRemote;but it wasn't working. How can I explicitly set the JNDI name of an old bean, that I want to lookup for?
Any help is appreciated!
Regards,
Stephan
Edited by: MasterRefactorer on Jun 27, 2008 7:31 AMYou can use @EJB to access 2.x Remote views, but the field type has to be the Home interface.
@EJB(mappedName = "abc/xyz/ItemLookup_v35")
private ItemLookupHome itemHome; -
Dependency injection and inheritance
Given:
class abstract AbstractFoo
MyObject obj;
class ConcreteFoo extends AbstractFoo
Now, I'd like to declare @EJB on "MyObject obj" but AbstractFoo is extended by other subclasses on the client end (outside the container) and so I don't want them to have any EJB3 dependencies. Is there a way for me to declare, inside ConcreteFoo, that "MyObject obj" should have @EJB associated with it?
Thanks,
GiliHi Janeth,
As you can see, Web Dynpro is not a standar JEE container so itu2019s not possible to use dependency injection from a Web Dynpro layer. You have to use JNDI lookups as usually.
Perhaps the following link may help you: https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/605ff5f2-e589-2910-3ead-e558376e6f3d
You can use EJB Web Dynpro models as an alternative.
Edited by: Sergi Arrufat on Jun 3, 2008 12:27 PM -
<p>Hi, I'm developing JSF with ADF and MyFaces. I want to minimise the load on my Server, e.g. by minimising use of session beans and other types of session storage. So I use the <t:saveState> from MyFaces instead. In web.xml I set the parameter:</p>
<p>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
</p>
<p>This makes all the MyFaces components store state on the client. However, this still doesn't force the ADF components to use client-side state saving(!). As described here, the default behaviour in ADF is to use a session token to store page state in HttpSession. In my project I've seen all sorts of strange behaviour when the session token exceeds the number of CLIENT_STATE_MAX_TOKENS. Of course I can try to increase this value, but this will lead to even more sesison usage. </p>
<p>So, I tried setting another parameter in web.xml:</p>
<p>
<context-param>
<param-name>oracle.adf.view.faces.CLIENT_STATE_METHOD</param-name>
<param-value>all</param-value>
</context-param>
<p>
<p>This should force all state to be moved to the client in a hidden form field. But when I do this I get this type of error:</p>
<p>
2006-10-25 13:21:30,854 ERROR (taglib.core.ViewTag:181) - Error writing body content
java.io.NotSerializableException: oracle.adf.view.faces.component.core.input.CoreSelectOneChoice
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1341)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1245)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1069)
at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1245)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1069)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:291)
at java.util.ArrayList.writeObject(ArrayList.java:569)
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:585)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:890)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1333)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1245)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1069)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:291)
at oracle.adfinternal.view.faces.renderkit.core.CoreResponseStateManager.writeState(CoreResponseStateManager.java:82)
at org.apache.myfaces.application.jsp.JspStateManagerImpl.writeState(JspStateManagerImpl.java:430)
at oracle.adfinternal.view.faces.application.StateManagerImpl.writeState(StateManagerImpl.java:241)
at org.apache.myfaces.taglib.core.ViewTag.doAfterBody(ViewTag.java:145)
at org.apache.jsp.pages.innkurv.innkurvMain_jsp._jspx_meth_f_view_0(innkurvMain_jsp.java:152)
at org.apache.jsp.pages.innkurv.innkurvMain_jsp._jspService(innkurvMain_jsp.java:91)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:416)
at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:234)
at oracle.adfinternal.view.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:157)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._invokeDoFilter(AdfFacesFilterImpl.java:367)
at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._doFilterImpl(AdfFacesFilterImpl.java:336)
at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl.doFilter(AdfFacesFilterImpl.java:196)
at oracle.adf.view.faces.webapp.AdfFacesFilter.doFilter(AdfFacesFilter.java:87)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at no.justisdepartementet.etterlysning.web.util.ContextResourceFilter.doFilter(ContextResourceFilter.java:69)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at no.justisdepartementet.etterlysning.web.util.RedirectFilter.doFilter(RedirectFilter.java:59)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
</p><p>Thanks guys. I did indeed try to use <t:saveState> to save the CoreSelectOneChoice. More specifically, I tried to use <t:saveState> on a backing bean where one of its properties were a CoreSelectOneChoice. The backing bean itself needs to be serializable as well as all of its properties, so the solution is to set the local variable transient.</p>
<p>After overcoming this problem, however, I found that some of my managed beans still had serialization problems because they had references to "service managers" that were dependency injected via JSF's managed means facility. See this blog for a discussion about serialization and MyFaces.
</p> -
Problem in dependency injection with Jboss4.2.1
Hi,
I have an application that uses an EJB named -JBejbBean(SLSB)
which implements a remote interface JBejb.
I have used JDeveloper 10.1.3 IDE for developing it.
JBejbBean contains a method
public String show()
return "hello";
Now at the viewController side
I have a JSF page whose backing bean ---view.backing.Start--- that looks up the above EJB using dependency injection as follows
@EJB(mappedName="current-ejb-ear/JBejb/remote")
private JBejb obj;
this returns an exception that says .....
Injection on Backing bean failed .
javax.naming.NameNotFoundException:view.backing.Start not bound.Hi All,
I just got an e-mail from Zinio:
Hello,
Thanks for contacting Zinio Customer Support.
We have fixed the problem that was causing your magazine to appear blue in areas that should not have been blue. We’re very sorry for the inconvenience.
Thank you,
Emilia
Zinio Customer Support
After removing the bad issues and downloading them again, the problem was fixed, everything looks fine now! Unfortunatly it is not clear how this was fixed, there has been an update of the Zinio app (1.9.3) but the list of updates and fixes did not mention this problem.
I'm very happy this has been addressed in relatively short time and that this problem in particular didn't need an update of the iOS.
Hopefully the same will be true for all other apps having this PDF rendering issue. -
How can i lookup a session bean from the client side
how can i lookup a session bean from the client side...........i am using sun appserver..............
this is my code.................[B]
private final static String JNDI_NAME="ejb/LmsBean";
private static String url="ldap://localhost:4848";
Hashtable h=new Hashtable();
h.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
h.put(Context.PROVIDER_URL,url);
System.out.println("Before Loading Context in Delegate");
Context ctx=new InitialContext(h);
System.out.println("Loaded Context in Delegate");
Object obj=ctx.lookup(JNDI_NAME);
System.out.println("Loaded Object in Delegate");
System.out.println("Before Loading Home in Delegate");
LmsHome home = (LmsHome )PortableRemoteObject.narrow(obj,com.parx.lms.controller.LmsHome.class);
System.out.println("Loaded Home in Delegate");
lms = home.create();
System.out.println("Loaded remote in Delegate");
[B]and i got the exception........
Inside Client before calling delegate
Before Loading Context in Delegate
javax.naming.CommunicationException: Request: 1 cancelled
javax.naming.CommunicationException: Request: 1 cancelled
at com.sun.jndi.ldap.LdapRequest.getReplyBer(LdapRequest.java:60)
at com.sun.jndi.ldap.Connection.readReply(Connection.java:405)
at com.sun.jndi.ldap.LdapClient.ldapBind(LdapClient.java:340)
at com.sun.jndi.ldap.LdapClient.authenticate(LdapClient.java:171)
at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2640)
at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:290)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:175)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:193
at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.ja
va:136)
at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.jav
a:66)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
62)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.<init>(InitialContext.java:195)
at com.parx.lms.lmsdelegate.LmsDelegate.getController(LmsDelegate.java:3
0)
at com.parx.lms.lmsdelegate.LmsDelegate.addUserDelegate(LmsDelegate.java
:50)
at com.parx.lms.client.consoleClient.Client.main(Unknown Source)
pls go tru the exception and pls help.........That url string should be having the server name or ip instead of localhost.
-
How to pass a string from a servlet to client side
hi,
i would like to generate a string from a servlet and pass it to the client side. the client will receive the string by using request.getParameter(). How should i implement this system? Could anybody give me some hint?
Best Regards,
HenryGreetings,
hi,
i would like to generate a string from a servlet and
pass it to the client side. the client will receive
the string by using request.getParameter(). HowAre you referring to the instance of (Http)ServletRequest the 'request' object being passed to the "client"? What is the "client" in this case? If you mean a "traditional" client communicating over (or by tunneling through...) HTTP then no can do. The (Http)ServletRequest object is generated by the web container (a.k.a. "servlet engine"), not by the client, and it is not serializable so there is no way to pass it back to the client...
should i implement this system? Could anybody give me
some hint?It depends again on "what is the 'client' in this case?"
Best Regards,
HenryRegards,
Tony "Vee Schade" Cook
Maybe you are looking for
-
Where can I download Adobe RoboHelp 9?
Dear community, I just changed laptop and need to re-install Adobe RoboHelp 9. However, Adobe has just released Adobe RoboHelp 10, which makes finding Adobe RoboHelp 9 for download quite difficult! I will try RH 10 later, but for now I would like to
-
How to restore an application from a computer to a iPod?
How do I restore an application from itunes on my PC to my iPod?
-
vadio won't play in landscape on iphon5 ios7
-
Had to re-install CS6, - cannot open RAW files in CS6 now?
-
My wordpress site won't load anymore (safari 6 to blame?)
After upgrading to Mountain Lion, I just tried to do a post on my wordpress site last night. The post showed up on my computer, but didn't show up on anyone else's. Now today, I can't get my wordpress site to load at all on my computer - even with ot