EJB and ThreadLocal

Hello,
I have a webapp and an EJB.
In my webapp, I use a ThreadLocal to put an object I want to be accessible from everywhere.
When I call the EJB, this object is no more present in the ThreadLocal to the EJB-side.
How can I pass this object from the ThreadLocal of the servlet to the ThreadLocal of the EJB ? Which object of the EJB can I use ?
Should I impose to give this object in the constructor method of the EJB ?
Should I use the EJBContext ?
Thanks in advance for your help.
bgOnline

Hi bgOnline,
If the EJB container and the webapp are running in two different JVM (i.e. using the remote interface of EJB), then the only possible solution I can think of is to pass it as a paramter of a method BY VALUE.
The reason is that both web container and EJB container maintain a pool of threads and ThreadLocal you use is bound to the threads in the webapp. There is obviously no way to pass threadbound objects between threads (and by value).
However, if you use local interface of EJB, then both webapp and EJB container are running in the same JVM, you can put an object in the ThreadLocal in webapp and retrieve it in EJB container by reference. I have tried it on WSAD 5 and it works. However, I have never put this in WebSphere or other Appservers as I think it depends too much on the behaviour of the appserver. Other appserver may still maintain two pools of threads anyway.
And don't forget the ClassLoader problem.
I hope my reply helps.

Similar Messages

  • Problem with EJB and JMS - Failed to obtain/create connection

    hello ejb and jms programmers,
    My problem is my topic MDB keep on retrieving the same message when there is a database connection failure. Maybe somebody could help me how to prevent to retrieve the same data?
    Given:
    - I purposedly turn off the pointbase database because im testing my error handling.
    - Im using SJSAS 8 as my application server.
    - My message Driven Bean of topic type.
    - Im using CMP for my entity bean
    Here is the scenario of whats happening - step by step:
    1. A separate application publishes a message to JMS queue server
    2. My MDB retrieves this message and do some processing then inserts a record (transaction history) in my database
    3. But my db is turned off or down
    4. My MDB sends a successful processing reply to the JMS queue server
    5. Then i noticed that my server.log keeps on growing so when i opened it, the record was not inserted and printed the stacktrace below "RAR5117 : Failed to obtain/create connection. Reason : javax.transaction.SystemException" (complete stacktrace below)
    6. I understand the cause of the stacktrace is because the DB is turned off. But what i dont understand is that my MDB keeps on reading the same message. Since my MDB is of topic type, isnt a topic MDB supposedly reads a message only once???
    So my questions are:
    1. how do i handle insert database error?
    2. how can i stop my MDB from processing the same message?
    3. any better suggestions?
    Thank you in advance :)
    leigh
    *** more complete stack trace ***
    [#|2005-01-09T15:35:57.097+0800|WARNING|sun-appserver-pe8.0.0_01|javax.enterprise.system.core.transaction|_ThreadID=17;|JTS5041: The resource manager is doing work outside a global transaction
    javax.transaction.xa.XAException
         at com.pointbase.xa.xaException.getXAException(Unknown Source)
         at com.pointbase.xa.xaConnectionResource.start(Unknown Source)
         at com.sun.gjc.spi.XAResourceImpl.start(XAResourceImpl.java:162)
    [#|2005-01-09T15:35:57.167+0800|SEVERE|sun-appserver-pe8.0.0_01|javax.enterprise.resource.resourceadapter|_ThreadID=17;|RAR5027:Unexpected exception in resource pooling
    javax.transaction.SystemException
         at com.sun.jts.jta.TransactionImpl.enlistResource(TransactionImpl.java:185)
         at com.sun.enterprise.distributedtx.J2EETransaction.enlistResource(J2EETransaction.java:360)
         at com.sun.enterprise.distributedtx.J2EETransactionManagerImpl.enlistResource(J2EETransactionManagerImpl.java:303)
         at com.sun.enterprise.distributedtx.J2EETransactionManagerOpt.enlistResource(J2EETransactionManagerOpt.java:115)
    [#|2005-01-09T15:35:57.177+0800|WARNING|sun-appserver-pe8.0.0_01|javax.enterprise.resource.resourceadapter|_ThreadID=17;|RAR5117 : Failed to obtain/create connection. Reason : javax.transaction.SystemException|#]
    [#|2005-01-09T15:35:57.227+0800|WARNING|sun-appserver-pe8.0.0_01|javax.enterprise.resource.resourceadapter|_ThreadID=17;|RAR5114 : Error allocating connection : [Error in allocating a connection. Cause: javax.transaction.SystemException]|#]
    [#|2005-01-09T15:35:57.237+0800|SEVERE|sun-appserver-pe8.0.0_01|javax.enterprise.system.container.ejb|_ThreadID=17;|EJB5071: Some remote or transactional roll back exception occurred
    com.sun.jdo.api.persistence.support.JDODataStoreException: JDO77006: SQL exception: state = null, error code = 0.
    NestedException: java.sql.SQLException: Error in allocating a connection. Cause: javax.transaction.SystemException
    FailedObjectArray: [[email protected]5ac]
         at com.sun.jdo.spi.persistence.support.sqlstore.impl.TransactionImpl.getConnectionInternal(TransactionImpl.java:1444)
         at com.sun.jdo.spi.persistence.support.sqlstore.impl.TransactionImpl.getConnection(TransactionImpl.java:1339)

    Hi annie,
    Wherever you are handling database transactions,
    you'd not be able to create a Connection if database
    is closed (I think you mentioned turning off the
    database) then at this condition, you should
    certainly throw a System level exception and stop all
    processing with some meaningful flow to indicate a
    failure (like display message on UI). Even
    network problems are handled by exceptions... so I
    don't see a reason why you didn't wrap it in the
    first place.
    Anyway, try handling specific exceptions rather than
    the general Exception... this will give you a better
    idea of what to do in case of an exception.Yes i know this. I am practicing this in my non-j2ee server applications. But the j2ee app im making, i just pass the db url in the descriptor and the app server automatically creates the connection for my app. So where would i put exception handling?
    2. how can i stop my MDB from processing the same
    message?Guaranteed delivery is not supposed to stop
    processing. It will continue to process the message
    after certain intervals till the message is
    delivered. You shouldn't deliver it at all, if you
    are able to detect that the database is off
    The problem here is that my MDB automatically retrieves the message from the JMS queue server. Im not the one retrieving the messages manually.
    My assumed behavior of topic MDB is once the a certain MDB retrieves a message it will not retrieve the same message anymore.
    thank you in advance.
    leigh

  • Can EJB and BC exist at the same time in one project?

    having to use ADF's BC and EJB to access data in both way due to the special requirements, but I am always getting the deployment failure.
    can Ejbs and BC components exist at the same time in one project?

    thanks for your reply.
    I considered to separate the BC and EJB as the separate project. I just use the EJB component to implement the dynamic tree menu, whether a little make a mountain out of a molehill if you as a separate project.

  • WLS 8.1 two domains with EJB and webapp deployed has JVM conflicts?

    Test configuration environment:
    Windows 2003 server installed with weblogic 8.1 server and oracle 9i.
    This weblogic server have two domains, one is for EJB deployment, the other is a webapp that implements accessing to oracle through EJB.
    The issue is when we tested a method provided by the EJB that uses double to calculate some total value, the result was correct. But when we tested it using webapp that was deployed on the same server of EJB, it's result was negative or zero.
    I think the reason is that the JVM which both EJB and webapp used for calculation was the same and may made some conflicts when they run at the same time.
    Any suggestion would be greatly appreciated.
    Thank you in advance!
    Shuaibing
    Message was edited by:
    linuxapple

    This morning I deployed that webapp to the Domain that deployed the EJB, The results of calculating in webapp's jsp was correct.
    Any one be kind enough to tell me what the calling JVM differences between single domain(deployed by EJB and webapp) and two domains (deployed EJB and webapp separately)?

  • How to master good design with EJB and JSP?

    I use JSP to calling EJB. But the .jsp file is complex and it's difficult to maintain...I just want to work higher efficent with EJB,JSP and JavaBean. I want to know is there a good design with EJB and JSP? and is there any good material about MVC for EJB,JSP and JavaBean?

    You should read the J2EE blueprint available on this website. Better download the PDF, and print it for yourself so you can read it anytime.

  • How to set classpath to EJB and Servlets

    Hi all,
    How can I add a classpath to EJB and Servlets in Weblogic 6.1, so that that classpath
    can be achieved by both EJB jar and war file? I have deployed a .ear file having
    the jar and war files. Now the EJBs inside the jar file are not reaching the class
    files of the war file and the class files in the war file are not reaching to
    the EJBs. Please let me know at the earliest.
    Atanu

    Hi.
    You might try looking at the petstore example which combines webapps (war files) with
    ejbs in an ear file to see how to do this. It may be a simple config problem.
    Regards,
    Michael
    Atanu Dey wrote:
    Hi all,
    How can I add a classpath to EJB and Servlets in Weblogic 6.1, so that that classpath
    can be achieved by both EJB jar and war file? I have deployed a .ear file having
    the jar and war files. Now the EJBs inside the jar file are not reaching the class
    files of the war file and the class files in the war file are not reaching to
    the EJBs. Please let me know at the earliest.
    Atanu--
    Michael Young
    Developer Relations Engineer
    BEA Support

  • Where do I put classes shared between EJBs and WAR

    I have written some ValueObject classes stored in their own jar, they are used by a number of ejbs and and a Web application WAR. I have packaged the thing up as a single EAR but neither the EJBs or the jsps can see these classes.
    How do I share these classes at each end. is their a general deployment descriptor solution or is it application server specific.
    I am deploying to IBM Websphere 6

    verify .classpath file under your web folder for both options
    Sorry, what do you mean is their a classpath value in the xml descriptors. I put my ValueObject into a jar within the WEB-INF\lib of the WAR but these arent seen by the EJBs which are within the EAR but not the WAR. Im not aware that there is a seperate WEB-INF directory for the EAR.
    Structure as follows
    app.ear
            testejb.jar
            META-INF
            testweb.war
                   test.jsp
                   META-INF
                   WEB_INF
                         classes
                              testui.class
                         lib
                             valueobjects.jar

  • How to pull data from EJB and present them using Swing ?

    Hi all,
    I've written stateful session bean which connect to Oracle database, and now I must write stand alone client application using Swing.
    The client app must present the data and then let users add,delete and edit data and it must be flexible enough to iterate through the records.
    The swing components can be JTextField,JTable etc.
    How to pull the data from EJB and present them to users with the most efficient network trip ?
    Thanks in advance
    Setya

    Thanks,
    Since the whole app originally was client-server app and I want to make it more scalable, so I decide to separate business logic in the EJB but I also want to keep the performance and the userfriendliness of the original user interface, and I want to continue using Swing as the original user interface does.
    I've read about using Rowset and I need some opinions about this from you guys who already have some experience with it.
    Any suggestions would be greatly appreciated.
    Thanks
    Setya

  • Differences between @EJB and @Resouce?

    Hi,
    I am confused about the differences between @EJB and @Resource?
    1.
    Can Session Beans be injected for both?
    If so what are the pro's / con's?
    2.
    Are the any difference between the type of components that cna be registered for one but not the other?
    3.
    Are they both equally usable with the ENC?
    Many thanks.

    @EJBs are 'special' resources. For example, @EJB (for a stateful session bean) results in
    1. Creation of the Stateful Session Bean,
    2. Other dependencies are injected into this newly created bean,
    3. If the bean has a @PostConstruct bean then that method is invoked (after invoking applicable interceptors)
    Hope this helps

  • RE: design patterns involving EJBs and JDO

    Is the idea that you specify in some config file (xml?) the methods of
    your session bean, whether its stateful or stateless, the default bean
    transaction semantics, etc, then say "go" and it generates the home and
    remote interfaces and the skeletal session bean class?
    -----Original Message-----
    From: Eric Lindauer [mailto:[email protected]]
    Sent: Monday, June 25, 2001 8:26 AM
    To: JDO-ListServ
    Subject: Re: design patterns involving EJBs and JDO
    I don't think it's publicly available yet, I used to work there and was
    helping out a little with testing. I'll tell you in advance, it really
    works well. Much like the JDO implementation, the process of turning
    things into SesisonBeans is very transparent to the developer. I guess
    TT is going to make it available in another week or two, as time
    permits.
    ----- Original Message -----
    From: Matthew <mailto:[email protected]> Adams
    To: '[email protected]' <mailto:'[email protected]'>
    Sent: Monday, June 25, 2001 11:18 AM
    Subject: RE: design patterns involving EJBs and JDO
    IMHO, JDO replaces entity beans, but you'll have to decide for yourself.
    My recommendation would be to use session beans exclusively.
    Where do you get TechTrader's "SessionBean Creator"? What are its
    features? How do you use it?
    -----Original Message-----
    From: Eric Lindauer [mailto:[email protected]]
    Sent: Monday, June 25, 2001 8:12 AM
    To: JDO-ListServ
    Subject: design patterns involving EJBs and JDO
    Hi,
    I was just wondering, if you are using JDO for persistence, does it
    matter whether you wrap your objects with proxy EntityBeans or
    SessionBeans? I am currently demoing TechTrader's SessionBean creator,
    which makes means that for me creating SessionBeans is much easier than
    creating EntityBeans. I am currently using stateful SessionBeans to
    wrap the JDO objects, simply dropping them when the bean is passivated
    and refinding them ( they'll already be in the cache ) when the bean is
    activated.
    My main advantage in doing it this way is SessionBeans are so much
    easier to create. Do you see any problems looming, or any other
    advantages to this decision?
    Thanks in advance.
    Eric

    I don't think it's publicly available yet, I used to work there and was
    helping out a little with testing. I'll tell you in advance, it really
    works well. Much like the JDO implementation, the process of turning
    things into SesisonBeans is very transparent to the developer. I guess
    TT is going to make it available in another week or two, as time
    permits.
    ----- Original Message -----_
    From: Matthew <mailto:[email protected]> Adams_
    To: '[email protected]' <mailto:'[email protected]'>
    Sent: Monday, June 25, 2001 11:18 AM
    Subject: RE: design patterns involving EJBs and JDO
    IMHO, JDO replaces entity beans, but you'll have to decide for yourself.
    My recommendation would be to use session beans exclusively.
    Where do you get TechTrader's "SessionBean Creator"? What are its
    features? How do you use it?
    -----Original Message-----
    From: Eric Lindauer [mailto:[email protected]]
    Sent: Monday, June 25, 2001 8:12 AM
    To: JDO-ListServ
    Subject: design patterns involving EJBs and JDO
    Hi,
    I was just wondering, if you are using JDO for persistence, does it
    matter whether you wrap your objects with proxy EntityBeans or
    SessionBeans? I am currently demoing TechTrader's SessionBean creator,
    which makes means that for me creating SessionBeans is much easier than
    creating EntityBeans. I am currently using stateful SessionBeans to
    wrap the JDO objects, simply dropping them when the bean is passivated
    and refinding them ( they'll already be in the cache ) when the bean is
    activated._
    My main advantage in doing it this way is SessionBeans are so much
    easier to create. Do you see any problems looming, or any other
    advantages to this decision?
    Thanks in advance.
    Eric_

  • Using EJB and CommandBean as Model in WD

    Hi Experts,
    I'm quite new to DI. My problem is, I created an EJB which is accessing a DB. Now I created a commandBean which accesses the EJB. I want to use this commandBean as beanModel in WD. I created public parts for the CommandBean but when I want to create the model in WD-Perspective and choose used dc as source, I can't find the jar file of the commandBean, that I wanted to expose with the public parts. Do I create public parts the wrong way? Or what could be the error? Is my approach correct in using a commandBean to access the EJB and use the CommandBean as Model?
    When I want to create the jar file of the CommandBean I get the following messages:
    JAR creation failed. See details for additional information.
      Problem writing /DI1_TP1IP1_Dzvejbhelpcom.bla/src/packages/com/sap/bla/MyCommandBean.jar to JAR: duplicate entry: com/sap/bla/MyCommandBean.jar
      Problem writing /DI1_TP1IP1_Dzvejbhelpcom.bla/bin/com/sap/bla/MyCommandBean.class to JAR: duplicate entry: com/sap/bla/MyCommandBean.class
      Problem writing /DI1_TP1IP1_Dzvejbhelpcom.chiron/src/packages/com/sap/bla/MyCommandBean.java to JAR: duplicate entry: com/sap/bla/MyCommandBean.java
    But the jar file is created? Could it be corrupted?
    Any help is appreciated
    Regards Manuel

    Hi Stefanie,
    you're right. Web Services is the better approach. So I wanted to use a web service and created a session bean wich calls my entity bean. I created a web service around the session bean. But when I want to deploy the ear-Project with the web service I get the following exception. I already checked sdn for this problem, but I could'nt find the solution:
    Caught exception during application deployment from SAP J2EE Engine's deploy service:
    java.rmi.RemoteException: Cannot deploy application com.chiron/zv_ear.. Reason: Webservices common deployment exception! The reason is: Error occurred, trying to update web services for application com.chiron/zv_ear. . Additional info: none; nested exception is:      java.lang.Exception: com.sap.engine.interfaces.webservices.server.deploy.WSDeploymentException: Webservices common deployment exception! The reason is: Error occurred, trying to update web services for application com.chiron/zv_ear. . Additional info: none
         at com.sap.engine.services.webservices.server.deploy.ws.update.WSUpdateProcessor.updateWebServices(WSUpdateProcessor.java:164)
         at com.sap.engine.services.webservices.server.deploy.ws.update.WSUpdateProcessor.updateWebServices(WSUpdateProcessor.java:118)
         at com.sap.engine.services.webservices.server.deploy.ws.update.WSUpdateProcessor.updateWebServices(WSUpdateProcessor.java:86)
         at com.sap.engine.services.webservices.server.deploy.ws.update.WSUpdateManager.makeUpdate(WSUpdateManager.java:52)
         at com.sap.engine.services.webservices.server.deploy.WSDeployer.makeUpdate(WSDeployer.java:274)
         at com.sap.engine.services.deploy.server.application.UpdateTransaction.makeComponents(UpdateTransaction.java:400)
         at com.sap.engine.services.deploy.server.application.DeployUtilTransaction.commonBegin(DeployUtilTransaction.java:321)
         at com.sap.engine.services.deploy.server.application.UpdateTransaction.begin(UpdateTransaction.java:164)
         at com.sap.engine.services.deploy.server.application.ApplicationTransaction.makeAllPhasesOnOneServer(ApplicationTransaction.java:292)
         at com.sap.engine.services.deploy.server.application.ApplicationTransaction.makeAllPhases(ApplicationTransaction.java:326)
         at com.sap.engine.services.deploy.server.DeployServiceImpl.makeGlobalTransaction(DeployServiceImpl.java:3184)
         at com.sap.engine.services.deploy.server.DeployServiceImpl.update(DeployServiceImpl.java:669)
         at com.sap.engine.services.deploy.server.DeployServiceImplp4_Skel.dispatch(DeployServiceImplp4_Skel.java:1278)
         at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:313)
         at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:199)
         at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:136)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
    Caused by: com.sap.engine.interfaces.webservices.server.deploy.WSDeploymentException: Webservices deployment exception! The reason is: Error occurred, trying to generate web services deployment files for application com.chiron/zv_ear. . The error refers to application: none, jar: , web service: .
         at com.sap.engine.services.webservices.server.deploy.ws.update.WSUpdateProcessor.generateDeployFiles(WSUpdateProcessor.java:296)
         at com.sap.engine.services.webservices.server.deploy.ws.update.WSUpdateProcessor.deployWebServices(WSUpdateProcessor.java:262)
         at com.sap.engine.services.webservices.server.deploy.ws.update.WSUpdateProcessor.updateWebServices(WSUpdateProcessor.java:155)
         ... 21 more
    Caused by: com.sap.engine.interfaces.webservices.server.deploy.WSDeploymentException: Webservices common deployment exception! The reason is: Error occurred, parsing com.sap.engine.services.webservices.server.deploy.descriptors.sapwebservices.WSDescriptor descriptor, application com.chiron/zv_ear, web service zvglWS, location message: type: jar file, location: F:\usr\sap\TP1\JC00\j2ee\cluster\server0\.\temp\deploy\work\deploying\reader1197465981374\com.chiron~zv_model3.jar . . Additional info:
         at com.sap.engine.services.webservices.server.deploy.ws.WSDefinitionFactory.parseWSDescriptor(WSDefinitionFactory.java:907)
         at com.sap.engine.services.webservices.server.deploy.ws.WSDefinitionFactory.loadWebService(WSDefinitionFactory.java:176)
         at com.sap.engine.services.webservices.server.deploy.ws.WSDefinitionFactory.loadWebServices(WSDefinitionFactory.java:158)
         at com.sap.engine.services.webservices.server.deploy.ws.update.WSUpdateProcessor.generateDeployFiles(WSUpdateProcessor.java:284)
         ... 23 more
    Caused by: com.sap.engine.interfaces.webservices.server.deploy.WSDeploymentException: Webservices common deployment exception! The reason is: Error occurred, trying to parse documentation for web service zvglWS. . Additional info:
         at com.sap.engine.services.webservices.server.deploy.ws.WSDefinitionFactory.parseDocumentation(WSDefinitionFactory.java:1590)
         at com.sap.engine.services.webservices.server.deploy.ws.WSDefinitionFactory.parseWSDAndDocumentation(WSDefinitionFactory.java:1564)
         at com.sap.engine.services.webservices.server.deploy.ws.WSDefinitionFactory.parseWSDescriptor(WSDefinitionFactory.java:814)
         ... 26 more
    <b>Caused by: java.io.FileNotFoundException</b>: .\temp\webservices\deploy\com.chiron_zv_ear\webservices\com1\com\sap\chiron\zvglWSWsd.wsdef (The system cannot find the path specified)
         at java.io.FileOutputStream.open(Native Method)
         at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
         at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
         at com.sap.engine.lib.jar.JarExtractor.extractFile(JarExtractor.java:232)
         at com.sap.engine.services.webservices.server.deploy.ws.WSArchiveFilesLocationHandler.getWsdInputStream(WSArchiveFilesLocationHandler.java:184)
         at com.sap.engine.services.webservices.server.deploy.ws.WSDefinitionFactory.parseDocumentation(WSDefinitionFactory.java:1574)
         ... 28 more
    (message ID: com.sap.sdm.serverext.servertype.inqmy.extern.EngineApplOnlineDeployerImpl.performAction(DeploymentActionTypes).REMEXC)
    Deployment exception : The deployment of at least one item aborted
    I already removed the ear and deployed again. That works one time, after that I get the exception again. But even when it works one time, I can't find the web service in the web service navigator of the j2ee engine.
    Regards Manuel

  • EJB and Servlets

    Hi there,
    A frontend processing of HTTP request that pass thru WebLogic server that make
    API calls thru tuxedo to the application servers that eventually running C, C++
    that retrieve data from a backend database of Oracle.
    Being the services of EJB and Servlets, EJB is more kind of processes inside the
    server but Servlets can handle better in request and respond (talk to the client),
    whats your opinions in this kind of integration? Go for pure EJB or Servlets?
    Or shall mixed matched? and how should the architecture should looks like?
    Thanks
    Neo

    Sorry, wrong question, just ignore it.

  • EJB and JavaMail

    Hi,
    I have developed an EJB for sending emails using the javamail api.
    My problem is that when i run the same code using the a standalone java application (i have pasted the code from the EJB) and try sending mails outside the my companies domain the mails are going.
    However when i try sending the mails using the JSP end EJB the mails are not going.
    I noticed that in the standalone java application the protected method getPasswordAuthentication gets called by the system. However the same is not getting called in the EJB.
    I am new to this technology. Can anyone please help me out here.
    I am sending the code also that i am using:-
    // Get all the system properties
    Properties props = System.getProperties();
    props.put("mail.smtp.host", "HOSTNAME");
    props.put("mail.smtp.auth", "true");
    SetAuthentication auth = new SetAuthentication();
    Session session = Session.getInstance(props, auth);
    session.setDebug(true);
    // Create a message
    Message msg = new MimeMessage(session);
    try {
    // Set the From Address
    Address addrFrom =new InternetAddress("[email protected]");
    msg.setFrom(addrFrom);
    // Set the TO address
    Address addrTo = new InternetAddress(strTo);
    msg.setRecipient(MimeMessage.RecipientType.TO, addrTo);
    // Set the subject of the mail
    msg.setSubject(strSubject);
    msg.setContent(strContent, "text/plain");
    msg.saveChanges();
    Transport.send(msg);
    // Code in class SetAuthentication
    private PasswordAuthentication auth;
    public SetAuthentication() {
    super();
    auth = new PasswordAuthentication("user", "password");
    protected PasswordAuthentication getPasswordAuthentication() {
    return auth;

    Hi,
    I have worked on JBoss and Weblogic app servers and one can initialize java mail settings in the app server,.I am sorry, i don't know how its done in the app server you are using.
    I would suggest you to try the following :
    static {
    /* Setting Properties for STMP host */
    props = System.getProperties();
    props.put("mail.smtp.host", "PUT SMTP SERVER HERE");
    props.put("mail.smtp.auth", "true");
    session = Session.getDefaultInstance(props, null);
    try {
    MimeMessage message = new MimeMessage(session);
    message.setRecipient(Message.RecipientType.TO,
    new InternetAddress(this.to));
    message.setFrom(new InternetAddress(this.from));
    message.setSubject(this.subject);
    message.setText(this.message);
    Transport transport = session.getTransport("smtp");
    transport.connect("PUT SMTP SERVER HERE", "PUT USERNAME HERE", "PUT PASSWORD HERE");
    message.saveChanges();
    transport.sendMessage(message, message.getAllRecipients());
    transport.close();
    } catch (MessagingException e) {
    throw new Exception(e.getMessage());

  • EJB and Design Patterns

    Hi all,
    Which design patterns could be applied in coding EJB? I don't know if my question is clear enough, but what I really want to know is which design patterns I could use with EJB and how could I use them this way? (Some example situation)
    Regards,
    Filipe Fedalto

    i think it depends of what u intend to do..
    e.g. i think (maybe i'm wrong, any relevant replies are welcome!) that u could use a stateless session bean to implement some facade, delegating entities creation to some non-bean classes? or why not a stateful session bean to implement a factory (when entities creation depend on client preferences)?

  • Deployment (Ejb and third party jars with portal app)

    My problem is that I'm trying to set up the development env for a portal project.
    I have an ejb and a third party jar in my portal app. My portlets have some java
    classes associated with them. The ejb needs to reference(instantiate) the java
    classes in the portlets.
    Right now the only way I can get it to work is to put the ejb, third party jar
    and the portlet classes(jarred up) into the classpath of the server.
    I think there should be a way to deploy these things without putting them in the
    class path. I've read all the manual sections about deploying.
    Can anyone help me with this. It would be much appreciated.
    Thanks
    Rob Castle
    Principal
    NuWave Solutions, LLC
    12510 Prosperity Drive
    Suite 300
    Silver Spring, MD 20904
    office phone: (301) 625-3000 ext. 2003
    mobile phone: (410) 340-5529
    email: [email protected]
    website: www.nuwavesolutions.com

    On 01/10/2002 06:40 AM, Rob Castle wrote:
    My problem is that I'm trying to set up the development env for a portal project.
    I have an ejb and a third party jar in my portal app. My portlets have some java
    classes associated with them. The ejb needs to reference(instantiate) the java
    classes in the portlets.
    Right now the only way I can get it to work is to put the ejb, third party jar
    and the portlet classes(jarred up) into the classpath of the server.
    I think there should be a way to deploy these things without putting them in the
    class path. I've read all the manual sections about deploying.
    Refer to the portal deployment guide
    (http://edocs.bea.com/wlp/docs40/deploygd/index.htm). Also refer to
    http://edocs.bea.com/wls/docs61/ejb/deploy.html for more general
    information on deployment of ejbs.
    Regards,
    Subbu

Maybe you are looking for

  • VERY frustrated with file names!

    I've read many posts that have explained why we can't use spaces in the file names but none have really explained how to get around it. I'm creating a small web site with about 4 separate photo pages. It will be published to a non-mac server. I've tr

  • Qty from VA88 Settlement for Account based copa

    Hi Gurus, I have a question on VA88 in MTO-E scenario. In account based copa the qty will update in Delivery. In MTO-E Scenario there is no accounting entries in Delivery(PGI). Is there any way to derive Billing qty in Settlement.(VA88) Thanks Vasant

  • Identity Policy Agent Realm

    Hi all Does anyone know how i can define a group in the AgentRealm of the Policy Agent ??? I already map roles to principals using sun-web.xml and it works, but i don't know how to define a group in the AgentRealm so that i can map a role to a group

  • Air Apps filtering on the Android Market  ?

    Hi we have just launched our KIDO'Z TV app on the market and we are getting reports from some users that they can't see the app on the Market This include users with Samsung Galaxy S Acer Liquied That both have froyo 2.2 and as far we understand they

  • No resize?

    hi, here is my code //Siobhan McGuire //Matriculation Number - 200404238 //My Calculator import java.awt.*; import javax.swing.*; import java.awt.event.*; class Calculator extends JFrame {      Calculator.setResizable(false);      //declares all calc