A simple problem with sateful Session beans
Hi,
I have a really novice problem with stateful session bean in Java EE 5.
I have written a simple session bean which has a counter inside it and every time a client call this bean it must increment the count value and return it back.
I have also created a simple servlet to call this session bean.
Everything seemed fine I opened a firefox window and tried to load the page, the counter incremented from 1 to 3 for the 3 times that I reloaded the page then I opened an IE window (which I think is actually a new client) but the page counter started from 4 not 1 for the new client and it means that the new client has access to the old client session bean.
Am I missing anything here???
Isn�t it the way that a stateful session bean must react?
This is my stateful session bean source.
package test;
import javax.ejb.Stateful;
@Stateful
public class SecondSessionBean implements SecondSessionRemote
private int cnt;
/** Creates a new instance of SecondSessionBean */
public SecondSessionBean ()
cnt=1;
public int getCnt()
return cnt++;
And this is my simple client site servlet
package rezaServlets;
import java.io.*;
import java.net.*;
import javax.ejb.EJB;
import javax.servlet.*;
import javax.servlet.http.*;
import test.SecondSessionRemote;
public class main extends HttpServlet
@EJB
private SecondSessionRemote secondSessionBean;
protected void processRequest (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
response.setContentType ("text/html;charset=UTF-8");
PrintWriter out = response.getWriter ();
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet main</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Our count is " + Integer.toString (secondSessionBean.getCnt ()) + "</h1>");
out.println("</body>");
out.println("</html>");
out.close ();
protected void doGet (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
processRequest (request, response);
protected void doPost (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
processRequest (request, response);
}
You are injecting a reference to a stateful session bean to an instance variable in the servlet. This bean instance is shared by all servlet request, and that's why you are seeing this odd behavior.
You can use type-leve injection for the stateful bean, and then lookup the bean inside your request-processing method. You may also save this bean ref in HttpSession.
@EJB(name="ejb/foo", beanName="SecondBean", beanInterface="com.foo.foo.SecondBeanRemote")
public MyServlet extends HttpServlet {
ic.lookup("java:comp/env/ejb/foo");
}
Similar Messages
-
I get the following:
error: EB-013: Unable to create timer for homeHi,
This exception indicates that there is some problem in creation of EJBObject or remote object. Can you please increase the debug level of iAS, and provide KJS logs and also some more information about your application. It will be best if you can send me a copy of your application, I can deploy it here and will try to see the exact cause of the exception.
You can mail your application/test case on [email protected] or post it here.
Regards,
Sanjeev. -
I have got problem to create Session Bean
Hi
I am new in j2ee. I have installed the eclipse 3.1, j2sdk1.4.2_07 and tomcat 5.0. I have created a ejb with a session bean and it gives me a error the program doesn't find the class javax.ejb.SessionBean. My question is Can this error happen because I don't have installed J2EE 1.4 SDK and Sun Java System Application Server Platform Edition 8.1?
thank youHi
I have tried to put the classpath with j2ee in eclipse but it happens the same. it doesn't find the package javax.ejb.SessionBean.
I am going to explain i have done from the beginning. Maybe I am wrong in something. I think which is that.
I have create a proyect with Dynamic Web Proyect after i create a proyect with ejbModule. I attempt to create a file with session bean. In last proyect acceded to Run->Run here i select Apache Tomcat and Tomcat v5.0 Server _ localhost and i select the classpath in "bootstrap entries" i insert the file j2ee.jar. And I' ve got the same error.
is it fine? I am bored trying to find the problem.
thanks in advanced -
A problem with a session Access
Hi Olivier,
To connect with Forte while running distributed you must use System DNS
instead of User DNS on the server. The ftexec.exe on your server partition
will be launched by the NodeMgr running as UID SYSTEM. User DNS are not
available to processes running as UID SYSTEM.
Zenon Adamek
Purolator
-----Original Message-----
From: Olivier Andrieux [SMTP:oandrieuxaxialog.fr]
Sent: Tuesday, July 04, 2000 4:59 AM
To: forte-userslists.xpedior.com
Subject: (forte-users) A problem with a session Access
Hi,
We have defined a service object which calls a database Access, when we
use the driver odbc of another station the service object is created and
the application runs. But when we use the driver of the server we have an
exception and this message :
SYSTEM ERROR: Unable to start the partition AxiGecom_CL0_Part1 on any of
the
nodes to which it has been assigned. See the remainder of the error
stack for
more information.
Class: qqsp_ResourceException
Error #: [1602, 593]
Detected at: qqcf_StandardConfig::LoadRemotePartition at 5
Last TOOL statement: method InterfaceManager.PrepareLOM
Error Time: Tue Jul 04 10:50:19
Exception occurred (locally) on partition "Forte_cl0_Client",
(partitionId
= EB3ED870-274C-11D4-8051-304F7116AA77:0x3f9:0x2, taskId =
[EB3ED870-274C-11D4-8051-304F7116AA77:0x3f9:0x2.15]) in application
"FTLaunch_cl0", pid 149 on node STAT10 in environment axialog.
SYSTEM ERROR: Unable to start partition AxiGecom_CL0_Part1 on node
SERVEUR59B.
Class: qqsp_ErrorDescriptor
Error #: [1602, 592]
Detected at: qqcf_StandardConfig::LoadRemotePartition at 3
Error Time: Tue Jul 04 10:50:19
Exception occurred (locally) on partition "Forte_cl0_Client",
(partitionId
= EB3ED870-274C-11D4-8051-304F7116AA77:0x3f9:0x2, taskId =
[EB3ED870-274C-11D4-8051-304F7116AA77:0x3f9:0x2.15]) in application
"FTLaunch_cl0", pid 149 on node STAT10 in environment axialog.
SYSTEM ERROR: Attempt to load partition named AxiGecom_CL0_Part1 failed.
Class: qqsp_ResourceException
Error #: [1001, 4]
Detected at: qqrt_ForteExecAgent::LoadPartition at 1
Error Time: Tue Jul 04 10:49:15
Distributed method called: qqrt_ForteExecAgentProxy.LoadPartition!6
(object name Unnamed) from partition "Forte_cl0_Client",
(partitionId =
EB3ED870-274C-11D4-8051-304F7116AA77:0x3f9:0x2, taskId =
[EB3ED870-274C-11D4-8051-304F7116AA77:0x3f9.4]) in application
"FTLaunch_cl0", pid 149 on node STAT10 in environment axialog
Exception occurred (remotely) on partition "Forte_Executor",
(partitionId
= EB3ED870-274C-11D4-8051-304F7116AA77:0x3de, taskId =
[EB3ED870-274C-11D4-8051-304F7116AA77:0x3de.61]) in application
"AxiGecom_cl0", pid 386 on node SERVEUR59B in environment axialog.
SYSTEM ERROR: Failed to create service object
Axigecom_Serveur.Connection_BD.
Class: qqsp_ResourceException
Last TOOL statement: method qqsp_NameList.
Error Time: Tue Jul 04 10:49:15
Exception occurred (remotely) on partition "Forte_Executor",
(partitionId
= EB3ED870-274C-11D4-8051-304F7116AA77:0x3de, taskId =
[EB3ED870-274C-11D4-8051-304F7116AA77:0x3de.61]) in application
"AxiGecom_cl0", pid 386 on node SERVEUR59B in environment axialog.
USER ERROR: (This error was converted)
Failed to connect to database: Axigecom, username: Administrateur.
[Microsoft][Gestionnaire de pilotes ODBC] Source de données non
trouvée et
nom
de pilote non spécifié
Class: qqdb_RemoteAccessException with ReasonCode:
DB_ER_DBMSCONNECTION
DBMS SQLSTATE: IM002
Class: qqsp_ErrorDescriptor
Detected at: qqdb_OdbcVendorInfo::DoSQLConnect at 10
Last TOOL statement: method qqsp_NameList.
Error Time: Tue Jul 04 10:49:15
Exception occurred (remotely) on partition "Forte_Executor",
(partitionId
= EB3ED870-274C-11D4-8051-304F7116AA77:0x3de, taskId =
[EB3ED870-274C-11D4-8051-304F7116AA77:0x3de.61]) in application
"AxiGecom_cl0", pid 386 on node SERVEUR59B in environment axialog.
for information, we use a server NT and the stations use Nt, the drivers
DNS users are declared.
We use Access2000, and the version M for Forté
Thanks in advance,
Olivier Andrieux
AXIALOG
France -
Problem with getting Entity Beans refreshed within Session bean methods
I hav following code in session and entity beans:
Session bean pseudo code: (PrimaryKey is primary key class for the entity
bean referred here, and MySessionHome is the home interfac class for this
session bean).
public class MySession implements SessionBean {
// This method is present in remote interface class as well.
public void methodA(PrimaryKey pk) {
// code to find entity bean by primary key specified.
update the entity bean, and mark it as isModified.
public void methodB(PrimaryKey pk) {
// code to find entity bean by primary key specified.
do something.
public void methodC() {
MySessionHome sessHome = code to lookup sessionhome from JNDI.
MySessionRI sess = sessHome.create(); // MySessionRI is the remote
interface class for MySession
PrimaryKey pk = new PrimaryKey(params);
sess.methodA(); // LINE ABC1
sess.methodB(); // LINE ABC2
all the entity and session bean methods have required as the TX attribute.
In methodB() on LINE ABC2, the entity bean obtained by findByPrimaryKey does
not reflect the changes made in call to methodA() on LINE ABC1.
Now if I change the LINE ABC1 and LINE ABC2 to
methodA(); // LINE ABC1
methodB(); // LINE ABC2
in this case the entity bean obtained in methodB() has the changes made in
methodA().
Any idea why this is happening?Hi ad13217 and thanks for reply.
I'm sorry but my code is like this:
javax.naming.Context ctx=new javax.naming.InitialContext();
arguments was an error on copy, but it doesn't work.
Thanks
Fil -
Need help with JSP - Session Bean scenario
I have massive problems with a simple JSP <--> Statefull Session Bean scenario with Server Platform Edition 8.2 (build b06-fcs)
What I do is generating a Collection in session bean returning it to JSP
and giving the List back to Session Bean.
A weird exception happens when giving the List back to Session Bean
(see Exception details below)
The same code runs without any trouble on Jboss Application Server 4.0.3
Any help would be great!
Please see code below
Statefull Session Bean
<code>
package ejb;
import data.Produkt;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import javax.ejb.*;
* This is the bean class for the WarenkorbBean enterprise bean.
* Created 17.03.2006 09:53:25
* @author Administrator
public class WarenkorbBean implements SessionBean, WarenkorbRemoteBusiness, WarenkorbLocalBusiness {
private SessionContext context;
// <editor-fold defaultstate="collapsed" desc="EJB infrastructure methods. Click the + sign on the left to edit the code.">
// TODO Add code to acquire and use other enterprise resources (DataSource, JMS, enterprise bean, Web services)
// TODO Add business methods or web service operations
* @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)
public void setSessionContext(SessionContext aContext) {
context = aContext;
* @see javax.ejb.SessionBean#ejbActivate()
public void ejbActivate() {
* @see javax.ejb.SessionBean#ejbPassivate()
public void ejbPassivate() {
* @see javax.ejb.SessionBean#ejbRemove()
public void ejbRemove() {
// </editor-fold>
* See section 7.10.3 of the EJB 2.0 specification
* See section 7.11.3 of the EJB 2.1 specification
public void ejbCreate() {
// TODO implement ejbCreate if necessary, acquire resources
// This method has access to the JNDI context so resource aquisition
// spanning all methods can be performed here such as home interfaces
// and data sources.
// Add business logic below. (Right-click in editor and choose
// "EJB Methods > Add Business Method" or "Web Service > Add Operation")
public Collection erzeugeWarenkorb() {
//TODO implement erzeugeWarenkorb
ArrayList myList = new ArrayList();
for (int i=0;i<10;i++)
Produkt prod = new Produkt();
prod.setID(i);
prod.setName("Produkt"+i);
myList.add(prod);
return myList;
public void leseWarenkorb(Collection Liste) {
//TODO implement leseWarenkorb
Iterator listIt = Liste.iterator();
while(listIt.hasNext())
Produkt p = (Produkt)listIt.next();
System.out.println("Name des Produktes {0} "+p.getName());
</code>
<code>
package data;
import java.io.Serializable;
* @author Administrator
public class Produkt implements Serializable {
private int ID;
private String Name;
/** Creates a new instance of Produkt */
public Produkt() {
public int getID() {
return ID;
public void setID(int ID) {
this.ID = ID;
public String getName() {
return Name;
public void setName(String Name) {
this.Name = Name;
</code>
<code>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import="java.util.*"%>
<%@page import="data.*"%>
<%@page import="javax.naming.*"%>
<%@page import="javax.rmi.PortableRemoteObject"%>
<%@page import="ejb.*"%>
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>
<%--
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
--%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Online Shop Warenkorb Test</h1>
<%--
This example uses JSTL, uncomment the taglib directive above.
To test, display the page like this: index.jsp?sayHello=true&name=Murphy
--%>
<%--
<c:if test="${param.sayHello}">
<!-- Let's welcome the user ${param.name} -->
Hello ${param.name}!
</c:if>
--%>
<%
Context myEnv = null;
WarenkorbRemote wr = null;
// Context initialisation
try
myEnv = (Context)new javax.naming.InitialContext();
/*Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
//env.put(Context.PROVIDER_URL, "jnp://wotan.activenet.at:1099");
env.put(Context.PROVIDER_URL, "jnp://localhost:1099");
env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
myEnv = new InitialContext(env);*/
catch (Exception ex)
System.err.println("Fehler beim initialisieren des Context: " + ex.getMessage());
// now lets work
try
Object ref = myEnv.lookup("ejb/WarenkorbBean");
//Object ref = myEnv.lookup("WarenkorbBean");
WarenkorbRemoteHome warenkorbrhome = (WarenkorbRemoteHome)
PortableRemoteObject.narrow(ref, WarenkorbRemoteHome.class);
wr = warenkorbrhome.create();
ArrayList myList = (ArrayList)wr.erzeugeWarenkorb();
Iterator it = myList.iterator();
while(it.hasNext())
Produkt p = (Produkt)it.next();
%>
ProduktID: <%=p.getID()%><br></br>Produktbezeichnung:
<%=p.getName()%><br></br><%
wr.leseWarenkorb(myList);
catch(Exception ex)
%><p style="color:red">Onlineshop nicht erreichbar</p><%=ex.getMessage()%>
<% }
%>
</body>
</html>
</code>
the exception
CORBA MARSHAL 1398079745 Maybe; nested exception is: org.omg.CORBA.MARSHAL: ----------BEGIN server-side stack trace---------- org.omg.CORBA.MARSHAL: vmcid: SUN minor code: 257 completed: Maybe at com.sun.corba.ee.impl.logging.ORBUtilSystemException.couldNotFindClass(ORBUtilSystemException.java:8101) at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1013) at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:879) at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_abstract_interface(CDRInputStream_1_0.java:873) at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_abstract_interface(CDRInputStream_1_0.java:863) at com.sun.corba.ee.impl.encoding.CDRInputStream.read_abstract_interface(CDRInputStream.java:275) at com.sun.corba.ee.impl.io.IIOPInputStream.readObjectDelegate(IIOPInputStream.java:363) at com.sun.corba.ee.impl.io.IIOPInputStream.readObjectOverride(IIOPInputStream.java:526) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:333) at java.util.ArrayList.readObject(ArrayList.java:591) 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 com.sun.corba.ee.impl.io.IIOPInputStream.invokeObjectReader(IIOPInputStream.java:1694) at com.sun.corba.ee.impl.io.IIOPInputStream.inputObject(IIOPInputStream.java:1212) at com.sun.corba.ee.impl.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:400) at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:330) at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:296) at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1034) at com.sun.corba.ee.impl.encoding.CDRInputStream.read_value(CDRInputStream.java:259) at com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl$14.read(DynamicMethodMarshallerImpl.java:333) at com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl.readArguments(DynamicMethodMarshallerImpl.java:393) at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:121) at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:648) at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:192) at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1709) at com.sun.corba.ee.impl.protocol.SharedCDRClientRequestDispatcherImpl.marshalingComplete(SharedCDRClientRequestDispatcherImpl.java:155) at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.invoke(CorbaClientDelegateImpl.java:184) at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:129) at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:150) at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(Unknown Source) at ejb._WarenkorbRemote_DynamicStub.leseWarenkorb(_WarenkorbRemote_DynamicStub.java) at org.apache.jsp.index_jsp._jspService(index_jsp.java:122) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:105) at javax.servlet.http.HttpServlet.service(HttpServlet.java:860) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:336) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:297) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:247) at javax.servlet.http.HttpServlet.service(HttpServlet.java:860) at sun.reflect.GeneratedMethodAccessor96.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAsPrivileged(Subject.java:517) at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282) at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:257) at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55) at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161) at java.security.AccessController.doPrivileged(Native Method) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:263) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:225) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:132) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:933) at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:189) at com.sun.enterprise.web.connector.grizzly.ProcessorTask.doProcess(ProcessorTask.java:604) at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:475) at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:371) at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:264) at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:281) at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:83) Caused by: java.lang.ClassNotFoundException ... 69 more ----------END server-side stack trace---------- vmcid: SUN minor code: 257 completed: MaybeHi,
I have found a way out by passing the reference of my EJB in the HttpSession object and using it inside the javabean.. -
Serialization error with WS session bean
Hi,
I'm running into a serious problem here at my project and I cannot find out what is going wrong.
I've made a scaled down version of the project I'm working on. This project gives the exact same error as in the main project.
I've created some simple POJO's with the model that should be returned by the session bean.
When I add some random test data and test the webservice I get the following error.
<faultstring>Internal Server Error ( serialization error : no serializer is registered for ( class nl.mk.test.canonicalmodel.ListObject, null )) </faultstring>
The model I use looks like this :
MainObject --> ListArrayObject --> ListObject
The implementation of these files.
package nl.mk.test.canonicalmodel;
import java.io.Serializable;
public class MainObject implements Serializable{
public MainObject() {
public String identification;
public ListArrayObject somelist;
package nl.mk.test.canonicalmodel;
import java.io.Serializable;
import java.util.List;
public class ListArrayObject implements Serializable{
public ListArrayObject() {
public String someId;
public List<ListObject> someList;
package nl.mk.test.canonicalmodel;
import java.io.Serializable;
public class ListObject implements Serializable {
public ListObject() {
public ListObject(String ident, String testfield1,
String testfield2, String testfield3
this.ident = ident;
this.testfield1 = testfield1;
this.testfield2 = testfield2;
this.testfield3 = testfield2;
public String ident;
public String testfield1;
public String testfield2;
public String testfield3;
The testWSBean that I've written looks like this.
package testws;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import nl.mk.test.canonicalmodel.ListArrayObject;
import nl.mk.test.canonicalmodel.ListObject;
import nl.mk.test.canonicalmodel.MainObject;
import org.apache.log4j.Logger;
@Stateless(name="TestWSBean")
public class TestWSBeanBean implements TestWSBean, TestWSBeanLocal,
TestWSBeanWebService {
private EntityManager em;
* Private logging instance
private static final Logger log = Logger.getLogger(TestWSBean.class);
public TestWSBeanBean() {
public MainObject GeefWaarde(String testWaarde) {
MainObject result = new MainObject();
long fStart;
fStart = System.currentTimeMillis();
try {
log.debug("----------------------------");
result.identification = testWaarde;
ListArrayObject listarray = new ListArrayObject();
listarray.someId = "ABCDEF";
List<ListObject> listObj = new ArrayList<ListObject>();
ListObject listType1 = new ListObject();
listType1.testfield1 = "A";
listType1.testfield2 = "B";
listType1.testfield3 = "C";
listObj.add( listType1 );
ListObject listType2 = new ListObject();
listType2.testfield1 = "D";
listType2.testfield2 = "E";
listType2.testfield3 = "F";
listObj.add ( listType2);
listarray.someList = listObj;
result.somelist = listarray;
catch (Exception e) {
log.error(e.getMessage());
e.printStackTrace();
} finally {
log.debug("Ready to return results");
long fEnd;
fEnd = System.currentTimeMillis();
log.debug("time in ms : " + (fEnd - fStart));
return result;
Does anyone know why this testproject gives a Serializable error?
Thanks in advanceIssue with the classes generated on fly for internal use. Make sure all the related files you are using are compiled on the same version of weblogic which you are using(though not mandate).
Compile and bind the application again, and before redeploying the application, clear cache and temp.
Hope this helps.
Jeets. -
JDev 10.1.3: Problem deploying a session bean to embedded OC4J
JDeveloper 10.1.3, TopLink, OC4J, WinXP, java 1.4.2_05.
I used TopLink to create a set of Java objects from a DB Schema, then created a simple Session Bean to read some of the objects. Everything compiles fine.
JAVA_HOME points to the JDK (not JRE) and CLASSPATH is empty (undefined).
When I try to Run my session bean in the jdeveloper embedded oc4j, I get this message. Thanks in advance for your help.
Milind
===============
[Starting OC4J using the following ports: HTTP=8988, RMI=23891, JMS=9227.]
C:\Tools\jdev_10_1_3\jdev\system\oracle.j2ee.10.1.3.3.51\oc4j-config>
C:\Tools\jdev_10_1_3\jdk\bin\javaw.exe -ojvm -classpath C:\Tools\jdev_10_1_3\j2ee\home\oc4j.jar;C:\Tools\jdev_10_1_3\jdev\lib\jdev-oc4j-embedded.jar -Xverify:none -DcheckForUpdates=adminClientOnly -Doracle.j2ee.dont.use.memory.archive=true -Doracle.j2ee.http.socket.timeout=500 -Doracle.dms.sensors=NONE -Doc4j.jms.usePersistenceLockFiles=false oracle.oc4j.loader.boot.BootStrap -config C:\Tools\jdev_10_1_3\jdev\system\oracle.j2ee.10.1.3.3.51\oc4j-config\server.xml
[waiting for the server to complete its initialization...]
05/03/22 14:43:50 Node started with id=127765687050882
05/03/22 14:43:52 Auto-deploying - applications/admin_ejb.jar (orion-ejb-jar.xml had been updated since the previous deployment)...
05/03/22 14:43:52 Error initializing server: Error initializing ejb-module; Exception null
05/03/22 14:43:53 Fatal error: server exiting
Process exited with exit code 1.Error initializing ejb-module;
Is the EJB Jar structured as
META-INF/
ejb-jar.xml
Bean Class
Home interface Class
Remote interface Class
Does the EJBdeploy in some other server? -
Connect Java Application with a Session Bean
Hi,
my Problem is following:
I have session bean (stateless) and i try to write i client for it!
I get always the same error message, when i call the java ClientApplication from the Command line:
java -jar Betting_server.jar BettingServer
StartBetting Server
Part1
Caught an unexpected exception!
javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory. Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:217)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:42)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:649)
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 at.siemens.mma.iap.betting.server.CreateQRunTimer$RemindTask.run(CreateQRunTimer.java:47)
at java.util.TimerThread.mainLoop(Timer.java:432)
at java.util.TimerThread.run(Timer.java:382)
My configuration:
jboss-3.2.1_tomcat-4.1.24
j2sdkee1.3.1
j2sdk1.4.1_02
My Client Class:
package betting.server;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import java.util.*;
import betting.ejb.*;
public class CreateQRunTimer {
Timer timer;
public CreateQRunTimer() {
timer = new Timer();
timer.schedule(new RemindTask(),
0, //initial delay
1*60*1000); //subsequent rate 30 minutes
class RemindTask extends TimerTask {
public void run() {
String logicalBettingBeanName = "MyBetting";
Betting bet;
BettingHome bethome;
try
System.out.println("Part1");
Properties props = new Properties();
props.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
props.put("java.naming.provider.url", "localhost:1099");
InitialContext ic = new InitialContext(props);
System.out.println("Part2");
Object objref = ic.lookup(logicalBettingBeanName);
System.out.println("Part3");
bethome =(BettingHome)PortableRemoteObject.narrow(objref,BettingHome.class);
bet = bethome.create();
long qRunMagicNum = bet.DB_CreateQRun();
if(bet.CreateConfigurationFileQuery(qRunMagicNum) == false)
// failed
System.out.print("CreateConfigFileQuery failed");
else
bet.TransferXMLFiles("tvbetqrun.conf",0);
System.out.print("CreateConfigFileQuery succed");
catch (Exception ex)
System.err.println("Caught an unexpected exception!");
ex.printStackTrace();
System.out.println("Run GG");
//System.exit(0); //Stops the AWT thread (and everything else)Normally, if you are executing the client from the command line, you do not specify the classpath in a XML file (unless you are using ant or something similar). You can specify the classpath by using the -classpath option.
Try something like
java -classpath <path_to_jboss>/client/jbossall-client.jar;Betting_server.jar BettingServer
You can check the classpath in your client with the statement
System.out.print(System.getProperty("java.class.path")); -
TX isolation level with stateless session bean in oc4j
Hi All,
I have a stateless session bean with container managed transaction method. This method is called in a Servlet. This method retrieves data from database using 'ejb-location'connection pool and closes the connection inside. Max-connection setting for connection pool is 50
I am facing a problem running servlet multiple times.
When i have the tx_attribute as Supports, it works fine. I can run the servlet hundreds of times
But when i have the tx_attribute as Required, i am able to run servlet only 50 times and further it says 'Max connection limit exceed..unable to get the connection'.
I assume that with 'Required' attribute, it starts a transaction. Why is the transaction not getting completed at end of method? Is transaction hanging somewhere?
I assume that i am closing the connection properly as it is working fine with supports attribute.
When i monitor database, there are only 20 connections.
Why am i seeing this behaviour?
Thanks
srinathHi Deepak,
Thanks for your reply.
Actually, our stand alone java application already using spring-hibernate feature. Now we are planning divide our application into modules and deploy each module as ejb beans. As it is already integrated with spring-hibernate we are not using entity beans as of now. My understanding is container uses some default transcation management .so, my question is what are all the configurations needs to be done to let weblogic 10.0 server uses org.springframework.orm.hibernate3.HibernateTransactionManager. I mean, is there are any .xml file in weblogic to configure all these? please reply deepak I am struck here..
Regards,
Rushi. -
Process Integrator Problem (use of session bean variable between tasks)
Hello,
I'm having a problem using the Process Integrator. I made a
really simple workflow (Start, Task1, Task2, Done) which uses
the bean given whith the order processing example. Task1 creates
the bean and executes a business operation (check inventory).
Task2 executes another business operation (calculate total
price). The problem is when I try to execute this second b.o I
get an exception saying
Nested exception is: Workflow error:
com.bea.wlpi.common.WorkflowException: Empty instance object for
business operation "Calculate Total Price" in
template "Template3".
Someone could help me and tell me what I am doing wrong.
Thanks in advance,
AlbertIf I understand you correctly, you have 3 business operations, one is "Create a EJB",
one is call "Check Inventory", the other is "Caculate Total Price". I assume you
save the EJB handle to a workflow variable with a type Bean. My speculation is when
you define business operation for "Calculate Total Price", you did not associate
it with the workflow variable that you saved the EJB handle. Just a wild guess.
Jim Zhou.
"Albert Lanchas" <[email protected]> wrote:
>
Hello,
I'm having a problem using the Process Integrator. I made a
really simple workflow (Start, Task1, Task2, Done) which uses
the bean given whith the order processing example. Task1 creates
the bean and executes a business operation (check inventory).
Task2 executes another business operation (calculate total
price). The problem is when I try to execute this second b.o I
get an exception saying
Nested exception is: Workflow error:
com.bea.wlpi.common.WorkflowException: Empty instance object for
business operation "Calculate Total Price" in
template "Template3".
Someone could help me and tell me what I am doing wrong.
Thanks in advance,
Albert -
Problem when running session bean
Hi all,
I am a new comer to jdeveloper11g and weblogic10.In these days i am trying to create session bean in jdeveloper. but i got this error when i am try to run the program using new sample client.
mapped name=New-SessionEJB
package=project1
Remote interface=NewSession
SessionBean=NewSessionBean
javax.naming.NameNotFoundException: While trying to lookup 'New-SessionEJB#project1.NewSession' didn't find subcontext 'New-SessionEJB#project1'. Resolved '' [Root exception is javax.naming.NameNotFoundException: While trying to lookup 'New-SessionEJB#project1.NewSession' didn't find subcontext 'New-SessionEJB#project1'. Resolved '']; remaining name 'New-SessionEJB#project1/NewSession'
at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:234)
at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:348)
at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:259)
at weblogic.jndi.internal.ServerNamingNode_1030_WLStub.lookup(Unknown Source)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:392)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:380)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at project1.NewSessionClient.main(NewSessionClient.java:16)
Caused by: javax.naming.NameNotFoundException: While trying to lookup 'New-SessionEJB#project1.NewSession' didn't find subcontext 'New-SessionEJB#project1'. Resolved ''
at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)
at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:247)
at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:182)
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206)
at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)
at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Process exited with exit code 0.
Here is my client program
public class NewSessionClient {
public static void main(String [] args) {
try {
final Context context = getInitialContext();
NewSession newSession = (NewSession)context.lookup("New-SessionEJB#project1.NewSession");
} catch (Exception ex) {
ex.printStackTrace();
private static Context getInitialContext() throws NamingException {
Hashtable env = new Hashtable();
// WebLogic Server 10.x connection details
env.put( Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory" );
env.put(Context.PROVIDER_URL, "t3://localhost:7101");
return new InitialContext( env );
If anybody know what the problem is please tell me.
thanks.......
(tcr)I ran into the EXACT same problem described by Tracy, and I assembled my .ear file manually.
According the error message, it would appear that the server is looking for the EJB remote interface in the ../temp/__session_bean_rpc directory when it is trying to generate its session bean wrapper class. As Tracy notes, when the file Hello.class is copied into the directory, the problem goes away. Furthermore, once the wrapper class has been generated, Hello.class is no longer needed and can be deleted from the directory.
Better still, I found a way to deploy the web services web module and make the error go away. I created the ejbws.war file with a copy of the remote interface Hello.class in the WEB-INF/classes directory. This makes the class available when the wrapper class is generated.
The WebServicesAssembler tool doesn't copy the EJB remote interfaces into the .war web module, which would appear to be
necessary.
Hope this helps. -
Adding Set of Session Beans generates client with wrong session bean names
Hi,
I am trying to import a set of session beans deployed on Sun Java Sever 8.2 using Netbeans 6.0. on windows XP.
The problem is that the imported set generated by the IDE has wrong session bean names and out of 8 session beans in the client jar only 6 are shown (and different 6 every time). Also the remote methods of one bean are associated with another bean and every time its a different set of bean clients generated.
I am really perplexed with this behavior. Any help on this issue will be highly appreciated.An RMI/IIOP parameter type must meet one of thefollowing criteria:
It must be a primitive type, or it must implementeither java.rmi.Remote or java.io.Serializable,
or it must be an interface for which the runtime typesatisfies the previous criteria,
or it must be an array containing elements thatsatisfy the previous criteria.This tells you exactly what you need to do. -
EJB 3.0 - Communicate an Applet with a Session Bean
Hello
I'm developing an EJB 3.0 app (eclipse and glassfish tools bundle), and I have an applet that has to use remote session beans.
QUESTION: Is it possible for the applet to connect to EJB?
QUESTION: By creating a J2EE application client project, can I use @EJB annotations to inject the session bean directly to the applet, avoiding the JNDI lookup?
(since I imagine that the anwser to the second one is NO, I do the following consideration)
Given an application client project, I imagine that this application can run remotely on a client machine/JRE. Then this application can use Annotations/injection facilities whenever it runs on a J2EE client container (which I assume consists of a set of libraries provided by the application server vendor, Glassfish in that case). Could this application be deployed using Java Web Start? If so, why can't it be deployed as an applet? (both options run in a client JRE, don't they?).
QUESTION: In either case (applet or JWS), how do I have to package the JAR file (using Eclipse) so that it contains the needed libraries for accessing the EJB? Which are those libraries?
At the time being, I'm trying to implement a sample application that follows the "Applet doing JNDI lookup" approach. I have:
- an EAR project
- an EJB project (containing an Entity Bean and a Stateless Session Bean with a @Remote interface)
@Remote
public interface HelloRemote {
public String hello(String name);
@Stateless
public class Hello implements HelloRemote {
@Override
public String hello(String name) {
return "Hello "+name+"!!";
}- an Application Client project (containing the applet code):
public class ClientApplet extends JApplet {
public void init(){
try {
Context jndiContext = getInitialContext( );
HelloRemote server = (HelloRemote) jndiContext.lookup(HelloRemote.class.getName());
setContentPane(new JLabel(server.hello("Gerard")));
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
private Context getInitialContext() throws NamingException{
Properties props = new Properties();
props.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("org.omg.CORBA.ORBInitialHost", "myhost");
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
return new InitialContext(props);
}- a static web project (with a sample web page that contains the applet object the corresponding applet JAR file)
I tried to export the Application Client project as an "application client JAR", in the hope that the java EE libraries bundled with glassfish (listed as libraries of this project) would be packaged too.
No success, so now I'll try to copy all the JAR files (one by one) into the +\WebContent\+ folder of the Web Project, and add references to each of them in the archive="" attribute of the +<applet>+ HTML tag. Although this might work, I suspect that I am missing the good/easy way of doing it. Any suggestions?
Thanks in advance,
Gerard
Edited by: gsoldevila on May 6, 2009 7:09 AMAn Applet can communicate with an EJB via JNDI lookup but I would (personally) use an intermediate Servlet to handle this. Client to Servlet communication is http whereas to ejb is iiop - which might be blocked.
Injection only works in managed classes (EJB, Servlet, Listeners..) and an Application Client main class. So yes you could use an app client for handling resource injection.
m -
Firefox remembers history but doesn't remember closed tabs, sessions.
It happened after updating Fox to v. 19.0.2 on one computer.
In Firefox Options is set Use Custom Settings For History, everything is checked except Always Use Private Browsing Mode. So I am not in private browsing.
When I press on Undo Closed Button nothing happens & in session manager Save Session Button is greyed out. I've tried installing other add-ons that can remember tabs. tried to disable/reinstall these 2 add-ons. Did't help. On my 2nd computer I have same add-ons, same settings and they are working normally. on 3rd computer undo closed tabs works also. How to fix this? I decided to ask before doing Firefox Reset...
Sync is a separate problem. It works, but quite often it logs me out of Sync account. Then I can log in only using long recovery key and password (choosing option I don't have device with me because it does not accept keys for pairing device.)
Thanks for reading.I have exactly the same settings in Options (in both computers)
for history, these 2 add-ons and all other stuff in Options. The only difference is that on 1 pc sessions can be saved and closed tabs can be reopened, on other main pc they stopped to work. + no any other add-on that does similar things works on this pc.
It is also interesting that I can reopen closed visited sites from History Panel, but not by pressing the Button. For now I only manually bookmark links to a temporary folder.
Recently (some 2 month ago) I pressed x and Firefox closed all tabs without saving them without displaying save & quit pop up.
so I changed 4 settings in about.config
browser.tabs.warn on close true
browser.warn on quit true
browser.warn on restart true
browser.show.quit warning true
but the problem with sessions appeared only 1 week ago.
So I guess the problem is not with the History settings or other settings. Seems that something responsible for button or for storing info about tabs/sessions got corrupted. :(
Maybe you are looking for
-
Lightroom won't load catalog, application won't launch
After using my Lightroom catalog and images on an external drive for several years, suddenly the application won''t load either today. Instead, I get this error message: "...Lightroom Catalogs can not be opened on network volumes, removable storage,
-
Hi there, I'm using a PHP send mail script to email the form results over to me. For the message, I want several fields to be in the actual message. I've seen that you simply need to insert the '.' However this simply seems to put the additional fiel
-
hi, create one more module pool program with three > screen fields. > > A B > C > (Candidate) > ields. > > and put authorizations check if u required for above > fields. Hi Lashmi, Can you please elaborate more..Let me tell you that each of three mod
-
Apple .. Please don't cheat me out of ICloud Account
I paid for my ICLOUD account service, but someone's been attempting to hack my Apple ID so I went to change it. After I changed it, my ICLOUD account prompts me for my OLD E-mail address and I cannot access it. I don't want to have to delete the I
-
Creating group is good or stablishing new tuxedo envioring, which is good??
Hi all, i have set up a tuxedo for on server in a branch... now i am going to extend server for other branches.... for each branch's server should i create a group or setup a tuxedo enviornment for each branch's server???? we have around 400 branches