DOM XML Parser in Stateless Session Bean- Not able to generate Container
I am trying to do some XML Parsing using a DOM Parser in a Stateless Session Bean. I am importing org.apache.xerces.parsers.DOMParser and trying the following statement DOMParser parser = new DOMParser();
Even though I am able to compile and generate the initial jar file. When I try to generate the container using the Weblogic Deployer GUI tool, the process keeps on going(I mean that I see the small window saying Container Generating working) and it never stops.
Any suggestions are welcome.
Many thanks ksaks for replying.
Actually day before yesterday we were able to do something like this. But then I kept this thread open only to see if experts have some good way of doing this.
What I mean is if this way is industry standards in terms of design and does it follow the most popular way how experts do it?
I am asking this as WebProjects have webcontent/web-inf directory wherein we put those xsds and property files, but we do not have anything like this in an EJB project. so was just wondering if this is the correct way of doing it or not.
I am still following this approach because I had to proceed further in my development. Confirmation would erase any other doubts on this.
Hope you find time to reply.
Kind Regards,
user2205
Edited by: user2205 on Nov 10, 2008 11:43 PM
Similar Messages
-
EJB 3.1new instance of stateless session bean not created on new invocation
I am using Netbeans 6.8 bundle that comes with JAVA EE 6. I have created a web application then created restful web services and then created few stateless session beans (with local interfaces) that are invoked from restful web services. From the browser, when I call the url with get method, restful web services are being invoked and they in turn calls stateless session beans and does the appropriate business logic. While testing, I observed that for every new url call from the browser, the same bean is being invoked. I tested this by adding a instance variable vector and adding one item ('test") to the vector in bean's method. My understanding is that on every bean's method invocation the vector should have only one item. However, the vector is growing with many "test" items. I am literally confused, not sure this is the way it is supposed to work. I tried to invoke bean's method from restful web service by using both dependency injection and jndi look up, both instances the vector is growing with many "test" items.
I would really appreciate if some body gives me more insight.I appreciate your answers. There is a strong reason for posting this question. Basically, I am using JPA and using stateless session beans to invoke database calls. In the bean I am using the following code for entity manager.
@PersistenceContext(unitName = "AsgProtocolServerPU")
private EntityManager em;
I have noticed very strange scenario while getting records. From the application, I have obtained few records of a table. Then, I manually deleted few records from the table. Very strangely, I have obtained the deleted records during my next call to bean. After 2 hours, I tested the same and did not get those records. This is not consistent.
I am totally confused. I am just wondering this is happening because I made beans local (not remote) and placed them in the web application (Java EE6 allows this). I am not sure whether this is JPA related issue or beans issue. -
Can Entity Bean with Home Business Method replace Stateless Session Bean?
Since Entity Bean can have business methods in the Home Interface, can we use Entity Bean with Home Business Methods to replace Stateless Session Bean?
I am assuming we can get better performance by doing this since the overhead of creating Component Object can be avoided as compared to stateless session beans.Requires-new makes the container start a new transaction. Only use that flag
at the point that you are certain that a NEW transaction should BEGIN. I
suggest you use Required as your default for all methods in the application,
and only change that to anything else when you are certain that you should.
Peace,
Cameron Purdy
Tangosol Inc.
<< Tangosol Server: How Weblogic applications are customized >>
<< Download now from http://www.tangosol.com/download.jsp >>
"A.J,LEE" <[email protected]> wrote in message
news:3ba5adb2$[email protected]..
>
> I find it result in "dead lock"
> when I call RequiresNew attributed CMP method in session Bean.
> Then, Is it possible to use CMP which is set with "RequiresNew"
transaction attribute?
>
> I Wonder why.
>
> Thanx in advance.
-
Stateless session Bean - xml and ejb-jar.xml file ???
Dear Experts,
Stateless-session bean
For Creating an ear file
we need ejb-jar.xml and weblogic-ejb-jar.xml files
Is these files are already available
or we have to type these files ??
Advance Thanks
Rengaraj.RMy best advice: surrender to use an IDE.
You wonder sometimes at how much productivity (read as 'time') could be wasted by doing something that could be done automatically. For a learning experience or a once only exercise is fine but as a routine thing, not worth it.
Cheers -
Not be able to obtain a transacted session within stateless session bean
I need some assistance on creating a transacted session. For some reason while within a stateless session bean, I am unable to create a transacted session even though I'm specifying to create the transacted queue session. Can anyone provide any assistance to me on this? It would be much appreciated.
Here is the code snippets involved with the problem:
Code snipet from ejb-jar.xml:
<session>
<display-name>Initial Request</display-name>
<ejb-name>InitialRequestBean</ejb-name>
<ejb-class>com.raytheon.rds.jms.InitialRequestBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
Code from stateless session bean:
static Logger logger;
private QueueConnectionFactory connectionFactory;
private SessionContext sc;
private Queue requestQueue;
public String processRequest(String msgBody)
logger.log(Level.INFO, "In processRequest(String).", msgBody);
QueueConnection con = null;
QueueSession session = null;
QueueSender sender = null;
TextMessage message = null;
String messageID = null;
QueueReceiver receiver = null;
TemporaryQueue replyQueue = null;
boolean transacted = false;
try
//Create the infrastructure (ie. The connection & the session)
logger.log(Level.FINE, "Creating connection");
con = connectionFactory.createQueueConnection();
logger.log(Level.FINE, "Creating session");
session = con.createQueueSession(true, Session.AUTO_ACKNOWLEDGE);
//Note: This line above was changed in all possible permutation and still didn't work such as using Session.SESSION_TRANSACTED
transacted = session.getTransacted();
logger.log(Level.FINE, "Is session transacted? : " + transacted);
//Note: This line above is constantly saying false
//Now first, setup the temporary reply queue and its listener
replyQueue = session.createTemporaryQueue();
logger.log(Level.FINE, "Creating receiver/consumer");
receiver = session.createReceiver(replyQueue);
con.start();
//Now create the requestor that will make the request message and put it on the request queue
logger.log(Level.FINE, "Creating Requestor/Producer");
sender = session.createSender(requestQueue);
//Now create the message and make sure that you put the "JMSReplyTo" property to the temporary response queue we just created
message = session.createTextMessage();
message.setJMSReplyTo(replyQueue);
logger.log(Level.FINE, "Created message: " + message.getJMSMessageID());
//Now add the actual info you want to send
message.setText(msgBody);
//Now send the message
logger.log(Level.INFO, "Sending message: " + message.getText());
sender.send(message);
//Now wait until we get a response
logger.log(Level.FINE, "Waiting for the response message");
Message responseMsg = receiver.receive(20000); //Toggle the "0" to specify timeout in millisectionds
//Process the message
logger.log(Level.FINE, "Processing the response message");
if(null != responseMsg)
logger.log(Level.FINE, "responseMsg is : " + responseMsg.toString());
messageID = processMessage(responseMsg);
logger.log(Level.FINE, "Response is : " + messageID);
//close the connection
logger.log(Level.FINE, "Stopping the connection");
con.stop();
catch (Throwable t)
// JMSException could be thrown
logger.log(Level.SEVERE, "Exception Thrown in sendRequest: ", t);
sc.setRollbackOnly();
finally
//Close the sender
if (sender != null)
try
logger.log(Level.FINE, "Closing the sender");
sender.close();
catch (JMSException e)
logger.log(Level.WARNING, "JMSException Thrown when trying to close the sender to the request queue: ", e);
else
logger.log(Level.FINE, "Sender is already closed.");
//Close the receiver
if (receiver != null)
try
logger.log(Level.FINE, "Closing the receiver");
receiver.close();
catch (JMSException e)
logger.log(Level.WARNING, "JMSException Thrown when trying to close the receiver to the request queue: ", e);
else
logger.log(Level.FINE, "Receiver is already closed.");
//Close the session
if (session != null)
try
logger.log(Level.FINE, "Closing the session");
session.close();
catch (JMSException e)
logger.log(Level.WARNING, "JMSException Thrown when trying to close the session to the request queue: ", e);
else
logger.log(Level.FINE, "Session is already closed.");
//Close the connection
if (con != null)
try
logger.log(Level.FINE, "Closing the connection");
con.close();
catch (JMSException e)
logger.log(Level.WARNING, "JMSException Thrown when trying to close the connection to the reply queue: ", e);
else
logger.log(Level.FINE, "Connection is already closed.");
return messageID;
}I found the answer through lots of painful searching.
http://blogs.sun.com/fkieviet/entry/request_reply_from_an_ejb
This weblog from Frank Kieviet from a sun blog explains what's happening behind the scenes.
Then I proceeded to create a Bean-Managed Transaction out of my EJB, which is using EJB 3.0. This requires the tag:
@TransactionManagement(value= TransactionManagementType.BEAN)
Note: I got this information from http://download.oracle.com/docs/cd/B31017_01/web.1013/b28221/servtran001.htm#BAJIBAFF
Then I just added the code specified in Frank's blog and everything is working now. The main portion of the code looks like this now:
//begin the user transaction
ctx.getUserTransaction().begin();
//Create the infrastructure (ie. The connection & the session)
logger.log(Level.FINE, "Creating connection");
con = connectionFactory.createQueueConnection();
//Create the session
logger.log(Level.FINE, "Creating session");
session = con.createQueueSession(false, Session.SESSION_TRANSACTED);
transacted = session.getTransacted();
logger.log(Level.FINE, "Is session transacted? : " + transacted);
//Now create the sender that will make the request message and put it on the request queue
logger.log(Level.FINE, "Creating Sender");
sender = session.createSender(requestQueue);
//Now create the message
message = session.createTextMessage();
//Now add the actual info you want to send
message.setText(msgBody);
logger.log(Level.FINE, "Created message: " + message.getJMSMessageID());
//Now first, setup the temporary reply queue and its listener
replyQueue = session.createTemporaryQueue();
if(null != replyQueue)
logger.log(Level.FINE, "Created temporary queue: " + replyQueue.getQueueName());
else
logger.log(Level.FINE, "Temporary Queue could not be created.");
//make sure that you put the "JMSReplyTo" property to the temporary response queue we just created
message.setJMSReplyTo(replyQueue);
//Now send the message
logger.log(Level.INFO, "Sending message: " + message.getText());
sender.send(message);
//Now start the connection
logger.log(Level.FINE, "Starting the connection");
con.start();
//commit the changes
ctx.getUserTransaction().commit();
ctx.getUserTransaction().begin();
//Create the receiver
logger.log(Level.FINE, "Creating Receiver");
receiver = session.createReceiver(replyQueue);
//Now wait until we get a response
logger.log(Level.FINE, "Waiting for the response message");
Message responseMsg = receiver.receive(20000); //Toggle the "0" to specify timeout in millisectionds
//Process the message
logger.log(Level.FINE, "Processing the response message");
if(null != responseMsg)
logger.log(Level.FINE, "responseMsg is : " + responseMsg.toString());
else
logger.log(Level.FINE, "No response came back.");
messageID = processMessage(responseMsg);
logger.log(Level.FINE, "Response is : " + messageID);
logger.log(Level.FINE, "Transaction is complete");
//commit the changes
ctx.getUserTransaction().commit(); -
Transaction is not Rolling Back in Stateless Session Bean
Hi,
I am using UserTransaction in Stateless Session bean .
Transaction is not rolling back.
The following code is writen in stateless session bean. In UserTransaction i am
calling Two methods of another stateless session bean.
The problem is if doJob2() method fails, doJob1() method is rolling back. These
two methods consist of SQL statement with different Connection Object from TXDataSource.And
session bean(TestSession) is set to CMT, attribute as "Required".
try{
Context ictx=new InitialContext();
TestHome home=(TestHome)ictx.lookup("TestSession");
utx = sessionCtx.getUserTransaction();
utx.begin();
TestRemote remote=home.create();
remote.doJob1();
remote.doJob2();
utx.commit();
}catch(Exception e)
try{
utx.rollback();
}catch(Exception ex)
System.out.println("unable to rollback"+ex);
if any SQL Exception as occured in doJob2(), its calling method utx.rollback()
in catch block. but SQL statements executed thru. doJob1() are not rolling back.
what might be the reason?
thanks
Ranganath
Thanx Priscilla ,
Transaction is working.
ranganath
"Priscilla Fung" <[email protected]> wrote:
>
>In your ejb-jar.xml, you should specify <transaction-type> element to
>be "Container"
>for container-managed transaction. If you specified it to be "Bean" for
>bean-managed
>transaction, EJB ontainer will suspend the caller's transaction before
>starting
>a new transaction for your doJobX() methods. Thus, doJob1()nd doJob2()
>will be
>executing in different transactions, and thus rolling back doJob2()'s
>transaction
>will have no effect on work done and committed in doJob1()'s transaction.
>
>Regards,
>
>Priscilla
>
>
>"Ranganath" <[email protected]> wrote:
>>
>>
>>
>>I am sending config.xml,deployment descriptors, code snippet for TestSession.
>>i
>>am using weblogic6.0sp2.
>>if you need any aditional info. please let me know.
>>
>>thanks
>>ranganath
>>
>>EJB-JAR.xml
>>
>><?xml version="1.0"?>
>>
>><!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise
>JavaBeans
>>1.1//EN' 'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>
>>
>><ejb-jar>
>> <enterprise-beans>
>> <session>
>> <ejb-name>TestSession</ejb-name>
>> <home>com.apar.sslbridge.test.TestHome</home>
>> <remote>com.apar.sslbridge.test.TestRemote</remote>
>> <ejb-class>com.apar.sslbridge.test.TestBean</ejb-class>
>> <session-type>Stateless</session-type>
>> <transaction-type>Bean</transaction-type>
>> <resource-ref>
>> <res-ref-name>jdbc/oraclePool</res-ref-name>
>> <res-type>javax.sql.DataSource</res-type>
>> <res-auth>Container</res-auth>
>> </resource-ref>
>> </session>
>> </enterprise-beans>
>> <assembly-descriptor>
>> <container-transaction>
>> <method>
>> <ejb-name>TestSession</ejb-name>
>> <method-intf>Remote</method-intf>
>> <method-name>*</method-name>
>> </method>
>> <trans-attribute>Required</trans-attribute>
>> </container-transaction>
>> </assembly-descriptor>
>></ejb-jar>
>>
>>
>>TestSession CODE:
>>
>>
>> public void doJob1() throws RemoteException
>> {
>> Statement st = null;
>> String query=null;
>> try{
>> con=getConnection();
>> st=con.createStatement();
>> query="insert into x values("+x+++")";
>> System.out.println(query);
>> int rec=st.executeUpdate(query);
>> }catch(SQLException sqle)
>> {
>> System.out.println("SQL Exception "+sqle);
>> throw new RemoteException("RemoteException*****SQLError");
>> } catch (Exception e) {
>> System.out.println("Exception "+e);
>> throw new RemoteException("RemoteException*****GenralError");
>> }
>>}
>>
>>
>> public void doJob2()throws RemoteException
>> {
>> Connection con=null;
>> Statement st = null;
>> String query=null;
>> try{
>> con=getConnection();
>> st=con.createStatement();
>> query="insert into y values("+x+++")";
>> System.out.println(query);
>> int rec=st.executeUpdate(query);
>> }catch(SQLException sqle)
>> {
>> System.out.println("SQL Exception "+sqle);
>> throw new RemoteException("RemoteException*****SQLError");
>> } catch (Exception e) {
>> System.out.println("Exception "+e);
>> throw new RemoteException("RemoteException*****GenralError");
>>}
>>}
>>private Connection getConnection(){
>>try {
>>Connection con = StaticParams.POOL_DATASOURCE.getConnection();
>>return con;
>> } catch(Exception e) {
>> System.out.println("TestBean.getConnection() Unable to get get pool
>>connection
>>" + e);
>> }
>>}
>>
>>
>>
>>
>>"Priscilla Fung" <[email protected]> wrote:
>>>
>>>It should work if you are using TxDataSource. Could you post your
>config.xml,
>>>deployment descriptors, code snippet for TestSession?
>>>
>>>Regards,
>>>
>>>Priscilla
>>>
>>>"Ranganath" <[email protected]> wrote:
>>>>
>>>>Hi,
>>>>
>>>> I am using UserTransaction in Stateless Session bean .
>>>> Transaction is not rolling back.
>>>>
>>>>The following code is writen in stateless session bean. In UserTransaction
>>>>i am
>>>>calling Two methods of another stateless session bean.
>>>> The problem is if doJob2() method fails, doJob1() method is rolling
>>>> back. These
>>>>two methods consist of SQL statement with different Connection Object
>>>>from TXDataSource.And
>>>>session bean(TestSession) is set to CMT, attribute as "Required".
>>>>
>>>> try{
>>>> Context ictx=new InitialContext();
>>>> TestHome home=(TestHome)ictx.lookup("TestSession");
>>>> utx = sessionCtx.getUserTransaction();
>>>> utx.begin();
>>>> TestRemote remote=home.create();
>>>> remote.doJob1();
>>>> remote.doJob2();
>>>> utx.commit();
>>>> }catch(Exception e)
>>>> {
>>>> try{
>>>> utx.rollback();
>>>> }catch(Exception ex)
>>>> {
>>>> System.out.println("unable to rollback"+ex);
>>>> }
>>>> }
>>>>if any SQL Exception as occured in doJob2(), its calling method utx.rollback()
>>>>in catch block. but SQL statements executed thru. doJob1() are not
>>rolling
>>>>back.
>>>>what might be the reason?
>>>>
>>>>thanks
>>>>Ranganath
>>>
>>
>
-
Transaction not rolling back in stateless session bean
Hi,
I am facing a problem...
I have one stateless session bean which does multiple updates in SYBASE database.I
am using non-transactional datasource. Bean calls a method of data access obejct
whcih internally calls more than one one mehtod to update different tables.If
any of update fails then I am explicitly thorwing EJBException. Still it is not
rolling back.
I have one more application where similar situation is there but only difference
is that there we have Entity bean and updates are being done through store method.
In that case with same datasource it is rolling back perfectly.
I have tried with transactional datasource as well but it didn't work.Then I tried
to put setAutoCommit(false) in my connection class which gives me connection.But
then it is not allowing me to enter into my application.
In deployment descriptor for both the beans transaction attribute is required
for all methods.
Regards.
Rahul.
Hi,
I am facing a problem...
I have one stateless session bean which does multiple updates in SYBASE database.I
am using non-transactional datasource. Bean calls a method of data access obejct
whcih internally calls more than one one mehtod to update different tables.If
any of update fails then I am explicitly thorwing EJBException. Still it is not
rolling back.
I have one more application where similar situation is there but only difference
is that there we have Entity bean and updates are being done through store method.
In that case with same datasource it is rolling back perfectly.
I have tried with transactional datasource as well but it didn't work.Then I tried
to put setAutoCommit(false) in my connection class which gives me connection.But
then it is not allowing me to enter into my application.
In deployment descriptor for both the beans transaction attribute is required
for all methods.
Regards.
Rahul.
-
Some methods not working in EJB 3.0 stateless session bean
Hi,
I am trying to build an application with EJB 3.0 stateless session bean in weblogic 10. In that during build (using ant 1.6) it showing error as one of the ejb-class should have anotataion as @stateless, @stateful or @messageDiven
But i have given it corrrectly.
When I comment some of the methods the same bean is working fine. While i have annoatated some of the methods with @transaction attribute annotataion.
So, should i write all those methods there any particular order or what.
Can anybody pls tell me, what can be the problem as weblogic.appc is giving such error?Hi,
I am trying to build an application with EJB 3.0 stateless session bean in weblogic 10. In that during build (using ant 1.6) it showing error as one of the ejb-class should have anotataion as @stateless, @stateful or @messageDiven
But i have given it corrrectly.
When I comment some of the methods the same bean is working fine. While i have annoatated some of the methods with @transaction attribute annotataion.
So, should i write all those methods there any particular order or what.
Can anybody pls tell me, what can be the problem as weblogic.appc is giving such error? -
Hot delpoyment with TopLink and Stateless Session Beans
What is the recommended procedure for making hot deployment of Stateless session beans work with toplink in WLS 7.0sp1 and oc4j (9.0.3)
My current setup is as follows using WLS 7.0sp1:
A stateless session bean is accessing toplink enabled persistent java classes via the SessionManager. I'm currently using the class loader of the stateless session bean:
* Method in stateless session bean
* Return the TopLink Session (based on the wls stateless session bean demo)
public Server getSession() {
return (Server)SessionManager.getManager().getSession("ejb_sessionbean", this.getClass().getClassLoader());
Everything is working as such. My session bean can read and write the persistent java classes. However if I redeploy the stateless session bean jar file the toplink session is not reinitalized. This means that new settings in the session.xml are not used. I addition I get other errors.
I'm having toplink on the server classpath. The toplink enabled persistent classes are in the stateless session bean jar file.
Thanks
HenrikWhat is the recommended procedure for making hot deployment of Stateless session beans work with toplink in WLS 7.0sp1 and oc4j (9.0.3)
Everything is working as such. My session bean can read and write the persistent java classes. However if I redeploy the stateless session bean jar file the toplink session is not reinitalized. This means that new settings in the session.xml are not used. I addition I get other errors.
I'm having toplink on the server classpath. The toplink enabled persistent classes are in the stateless session bean jar file.Henrik,
This is a recent post note I found on the same topic:
It all hinges on whether the TopLink ServerSession class has
been loaded by a classloader which is actually thrown away
during the hot deployment process. If this is the case, then
hot deployment causes the ServerSession to go out of scope
and finalize methods take care of logging it out properly.
If you deploy your TopLink Project on the Sytem class path then
it definately won't work. You'd have to restart the server every time.
But if the TopLink Project is deployed inside of an .ear file
and if you pass the correct ClassLoader to the
SessionManager.getSession( .... ) call then TopLink Session will
be re-started when you hot deploy the .earBased on this, the solution might be to deploy your EJBs in an ear file. Everything else looks OK. Can you try this and let us know?
Thanks,
Pete Farkas -
WLS10 and Stateless Session Bean
I tried to create EJB3 application example.
1. Created Stateless Session Bean that implements Remote and Local interfaces:
Session Bean code:
package com.session;
import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
@Stateless(mappedName="SessionBeanService")
@Remote(ISessionBeanRemote.class)
@Local(ISessionBeanLocal.class)
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class SessionBean implements ISessionBeanLocal,
ISessionBeanRemote
public String reply(){
return "MySessionBean - success !!!";
Remote Interface code :
package com.session;
public interface ISessionBeanRemote
public String reply();
Local Interface code:
package com.session;
public interface ISessionBeanLocal
public String reply();
application.xml:
<?xml version="1.0" encoding="UTF-8"?>
<application 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/application_5.xsd"
version="5">
<display-name>EJB3 Sample Application</display-name>
<module>
<ejb>beans.jar</ejb>
</module>
</application>
weblogic-application.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE weblogic-application PUBLIC
"-//BEA Systems, Inc.//DTD WebLogic Application 8.1.0//EN"
"http://www.bea.com/ns/weblogic/90/weblogic-application.xsd">
<weblogic-application>
<classloader-structure>
<module-ref>
<module-uri>beans.jar</module-uri>
</module-ref>
</classloader-structure>
</weblogic-application>
2. I packaged classes into EAR file and deployed to WLS10.
I didn't include any weblogic specific XML descriptors besides weblogic-application.jar.
My client code lookes as follows:
public void test(){
Context context = getMyServerContext();
// THIS JNDI NAME I SEE ON MY SERVER JNDI TREE
String jndiName = "sessionbeansbeans_jarSessionBean_ISessionBeanRemote";
Object obj;
obj = context.lookup(jndiName);
System.out.println(" obj class : " + obj.getClass().getName());
ISessionBeanRemote remote = (ISessionBeanRemote) PortableRemoteObject.narrow(
obj, ISessionBeanRemote.class );
String res = remote.reply();
System.out.println("res : "+res);
I get an Exception:
Exception occurred!
java.lang.ClassCastException: Cannot narrow remote object to com.session.ISessionBeanRemote
at weblogic.iiop.PortableRemoteObjectDelegateImpl.narrow(PortableRemoteObjectDelegateImpl.java:242)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
at ca.cgi.mvest.test.server.wms.GlFacadeTest.runTest(GlFacadeTest.java:91)
at ca.cgi.mvest.test.server.wms.GlFacadeTest.<init>(GlFacadeTest.java:53)
at ca.cgi.mvest.test.server.wms.GlFacadeTest.main(GlFacadeTest.java:151)
java.lang.ClassCastException: Cannot narrow remote object to com.session.ISessionBeanRemote
My server console have the following output:
Root cause of ServletException.java.lang.NoClassDefFoundError: com/session/SessionBean_7pp7ls_ISessionBeanRemot
eIntf
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
4)
at weblogic.utils.classloaders.GenericClassLoader.defineClass(GenericCla
ssLoader.java:338)
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(Generic
ClassLoader.java:291)
Truncated. see log file for complete stacktrace
Server logs a problem already on the line when I do lookup
on JNDI name even before narrow();
It looks like my EAR was missing something. But server never complained during deployment.
May be someone can direct me to a real sample of Weblogic10-ejb3.0 application, since examples that come with WLS 10 intallation combersome and do not follow
docmentation.
Thanks in advance for any suggestion.Hello Freind
The main different b\w stateful and statless is that stateful maintain state of method conversation means it has record that which method call before this method
but in case of stateless conversation state does not saved second different we can say that create method in stateless having no parameter but statefull having parameter I think u can understand easily
With Best Regards
Rajesh Pandey
email :[email protected]
url :-- http://www.sixthquadrant.com
Mob :-- 9811903737
Delhi India -
How to integrate hibernate with Stateless Session bean in weblogic10.0
Hi,
I need to invoke hibernate(3.x) DAO from EJB Stateless Session bean(EJB2.x). I am using mysql database. Can somebody please post the configuration.
Thanks in advance,
Rushi.Hi 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. -
Stateless Session Bean + EJB Question + Jboss
Hello,
If I have a stateless session bean on a linux machine and it works locally what do i need to do to access a method in the session bean from a remote windows machine.
I would like to be able to execute my client jar file on a windows machine and have it access the jboss server on the linux machine. what do i need to do?
i have the session bean working locally on both windows and linux machine. do i need to to have a JSP/Servlet to access the session bean? can the session bean not be accessed directly? what should my classpath look like? do I need to include extra jar files in my client jar file.?
Thanks,
JoyceThanks guys for the help but I am still a little lost.
My Client windows machine has the client jar file and all the other jar files. This is my client class
package helloworld.client;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.Hashtable;
import java.util.Properties;
import helloworld.interfaces.HelloWorldHome;
import helloworld.interfaces.HelloWorld;
public class HelloClient
public static void main(String[] args)
Hashtable prop = new Hashtable();
prop.put ("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
prop.put ("java.naming.provider.url","jnp://172.16.220.160:1099");
prop.put ("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
try
Context ctx = new InitialContext(prop);
Object obj = ctx.lookup("ejb/helloworld/HelloWorld");
System.out.println(obj);
HelloWorldHome home = (HelloWorldHome)javax.rmi.PortableRemoteObject.narrow(obj, HelloWorldHome.class);
HelloWorld helloWorld = home.create();
String str = helloWorld.sayHelloEJB("JOYCE is COOL");
System.out.println(str);
helloWorld.remove();
catch(Exception e)
e.printStackTrace();
I get a NullPointer ie the home object is null. The IP address is the IP of the Linux machine that has Jboss running on.
Questions are:
1. Do I need to have Tomcat running on my client machine if I am to connect via HTTP? Does this alter my client code.?
2. My JNDI lookup is what is causing the problem. Does my jboss.xml and my ejb-jar.jar look okay to you.
jboss.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS//EN" "http://www.jboss.org/j2ee/dtd/jboss.dtd">
<jboss>
<enterprise-beans>
<session>
<ejb-name>helloworld/HelloWorld</ejb-name>
<jndi-name>ejb/helloworld/HelloWorld</jndi-name>
</session>
</enterprise-beans>
<resource-managers>
</resource-managers>
</jboss>
ejb-jar.jar
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar >
<description>No Description.</description>
<display-name>Generated by XDoclet</display-name>
<enterprise-beans>
<!-- Session Beans -->
<session >
<description><![CDATA[No Description.]]></description>
<ejb-name>helloworld/HelloWorld</ejb-name>
<home>helloworld.interfaces.HelloWorldHome</home>
<remote>helloworld.interfaces.HelloWorld</remote>
<ejb-class>helloworld.session.HelloWorldBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Bean</transaction-type>
</session>
<!--
To add session beans that you have deployment descriptor info for, add
a file to your merge directory called session-beans.xml that contains
the <session></session> markup for those beans.
-->
<!-- Entity Beans -->
<!--
To add entity beans that you have deployment descriptor info for, add
a file to your merge directory called entity-beans.xml that contains
the <entity></entity> markup for those beans.
-->
<!-- Message Driven Beans -->
<!--
To add message driven beans that you have deployment descriptor info for, add
a file to your merge directory called message-driven-beans.xml that contains
the <message-driven></message-driven> markup for those beans.
-->
</enterprise-beans>
<!-- Relationships -->
<!-- Assembly Descriptor -->
<assembly-descriptor >
<!-- finder permissions -->
<!-- transactions -->
<!-- finder transactions -->
</assembly-descriptor>
</ejb-jar>
Do I need RMI ? Do I need to concern myself with CORBA? All Im looking for is a step by step to understanding what I need to configure? Is their some way I can debug?
Thanks alot,
Joyce -
JNDI lookup of a Stateless Session bean from another stateless session bean
Hi,
I am working on SAP Netweaver. We have created a stateless session bean which is finally deployed as a webservice. From this stateless session bean we need to call another stateless session bean as a local reference.
I have done the following.
1. Added JNDI-Name to the ejb-j2ee-engine.xml.
2. My lookup code is as follows
Context context = null;
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");
context = new InitialContext(env);
Object ejbObj = context.lookup("MyBean");
But i get the NamingException .Here MyBean is the jndi-name provided in the ejb-j2ee-engine.xml.
Can somebody tell me what i am doing wrong.
Thanks
PriyaHi,
Thanks for your replies.I did as you had suggested.I added ejb-local-ref to the ejb-jar.xml and i provided ejb-ref as MyBean.
My lookup code uses the string
ctxt.lookup("localejbs\MyBean");
But still i get Naming Exception.
I tried something different yesterday.
I changed the code to use
InitialContext ctxt = new InitialContext();
ctxt.lookup("localejbs/"+ pathfromJNDIRegistry);
and this time i did not get Naming exception but i got RemoteException saying there was error loading the class.
Is there something i need to add somewhere for the classloader to be able to find and load this class in the second scenario.
Please suggest me which method to go for amongst the two and what is the missing information i need to add.
Thanks
Priya -
Looking up of a stateless session bean from an MDB
Hi,
I have been trying to invoke a method on a stateless session bean from an MDB on receipt of a message from a queue. The bean receives the message. Then it gets the initial context, but after this the following message appears:
javax.naming.NamingException: Error instantation environment context for Message DrivenBean MyMDB: No location specified and no suitable instance of the type 'MySessionRemote' found for the ejb-ref <mySessionBean> at com.evermind.server.ejb.MessageDrivenHome.getEnvironmentContext(MessageDrivenHome.java:559)
The session bean is in a seperate ear file. These are the deployment descriptors of the MDB:
ejb-jar:
<ejb-jar>
<description>A Message-Driven Beans</description>
<enterprise-beans>
<message-driven>
<description></description>
<ejb-name>MyMDB</ejb-name>
<ejbclass>MyMDB</ejb-class>
<message-driven-destination>
<jms-destination-type>javax.jms.Queue</jms-destination-type>
</message-driven-destination>
<ejb-ref>
<ejb-ref-name>MySessionEJB</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>MySessionEJBHome</home>
<remote>MySessionRemote</remote>
</ejb-ref>
</message-driven>
</enterprise-beans>
<assembly-descriptor>
</assembly-descriptor>
</ejb-jar>
orion-ejb-jar
<orion-ejb-jar>
<enterprise-beans>
<message-driven-deployment name="QueueProcessor" destination-location="jms/theQueue" connection-factory-location="jms/theQueueConnectionFactory">
</message-driven-deployment>
</enterprise-beans>
<assembly-descriptor>
</assembly-descriptor>
</orion-ejb-jar>
The lookup name which I give in MDB is:
java:comp/env/MySessionEJBHi,
Thanks for your replies.I did as you had suggested.I added ejb-local-ref to the ejb-jar.xml and i provided ejb-ref as MyBean.
My lookup code uses the string
ctxt.lookup("localejbs\MyBean");
But still i get Naming Exception.
I tried something different yesterday.
I changed the code to use
InitialContext ctxt = new InitialContext();
ctxt.lookup("localejbs/"+ pathfromJNDIRegistry);
and this time i did not get Naming exception but i got RemoteException saying there was error loading the class.
Is there something i need to add somewhere for the classloader to be able to find and load this class in the second scenario.
Please suggest me which method to go for amongst the two and what is the missing information i need to add.
Thanks
Priya -
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.
Maybe you are looking for
-
Remote Desktop Connection fails
I have a new Server 2012 R2 essentials install. I have tried connecting with remote desktop connection but have no success. I can connect to the server at the local desktop. From any other computer on the network it fails. I have checked a plethora o
-
How do you get more free effects to use in Final Cut pro x?
I am looking for a safe free place to download more effects that I can use on my videos in Final cut pro x that include effects that aren't just limited to the colors of the video. I also hope that the place will have clear instructions on how to dow
-
Hi, I just got an 100Mbit internet connection. Running the test on: http://www.speedmeter.de/speedtest/ I get 11Mbit/s vor my Linux and 97 Mbit/s with my Windows (same Laptop). So what did I do wrong? I searched the forum for hints, but couldn't find
-
Problem when trying to delete CMP entity bean
Hi, When I try to remove a CMP entity bean, I have this error : re09.projet_ejb.syndic.AdminException: Exception thrown from bean; nested exception is: javax.ejb.EJBException: nested exception is: com.sun.jdo.api.persistence.support.JDOUnsupportedOpt
-
For professionals using Adobe CS3 on Mac Pro about how much RAM is needed to run all 6 programs together efficantly? I'm looking into upgrades and really need some advice- Any out there to give? Thanks, Port