[Javassist user questions] - JNDI and java: context problem
by fla83tn
Hi,
In my project I'd like to send an e-mail from my message-driven bean but I have 2 problem.
First of all this is my problematic code:
|
| private void send(Context c,String to){
| javax.mail.Session session = null;
|
| try {
|
| session = ---- see after -----
|
| MimeMessage m = new MimeMessage(session);
| m.setFrom();
|
| m.setRecipients(javax.mail.Message.RecipientType.TO,
| InternetAddress.parse(to, false));
| m.setSubject("Pinestore Order confirmation");
| m.setSentDate(new Date());
| m.setContent("The Order has been processed",
| "text/plain"); //equivalent to setText..
| Store s = session.getStore();
| s.connect(); // POP authentication
| Transport.send(m);
|
| System.out.println("Message sent OK.");
| } catch (javax.mail.MessagingException e) {
| e.printStackTrace();
| } catch (javax.naming.NamingException e) {
| e.printStackTrace();
| }
| }
|
| public static void main(String args[]){
| Context c = null;
| try {
| Hashtable environment = new Hashtable();
| environment.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
| environment.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
| environment.put(Context.PROVIDER_URL, "jnp://localhost:1099");
| c =new InitialContext(environment);
|
| }
| catch (NamingException ex) {
| }
| send(c,"xxx@domain");
| }
|
This are my question:
| this is only because I have some confusion:
| Why couldn't I access to resources in jndi at java:comp/env?
| If I do
|
| | Context c = b.getInitialContext();
| | Context compEnv = (Context) c.lookup("java:comp/env");
| |
| compEnv is null..the only things that work is c.lookup("") or lookup of everything that is located under Global JNDI Namespace..
|
|
| | My second question is:
| | If I leave the default <attribute name="JNDIName">java:/Mail</attribute> in file mail-service.xml I can't manage to lookup via jndi to the MBean...this because the java: context seems to be invisible..only names that are in Global JNDI Namespace are visible..
| |
|
|
| | So I try to get around the problem modifying the file mail-service.xml as <attribute name="JNDIName">Mail</attribute> so now I can do in my code:
| |
| | | session = (javax.mail.Session)PortableRemoteObject.narrow(
| | | c.lookup("Mail"), javax.mail.Session.class);
| | |
| | In this case the lookup works, but now I get still error because javax.mail.Session isn't a remote interface and then I can not do a PortableRemoteObject.narrow...
| |
|
|
| Somewhere I read that:
|
| "objects referenced behind the java: root are not reachable by external JNDI calls, they are private to the VM of the server."
|
| Is it true? How can I solve the problem?
|
| Instead for the last error I don't know how to bind the result of the lookup..
|
| Please somebody help me!!!!!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3960213#3960213
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3960213
19 years, 9 months
[JBoss Seam] - How to get some debug information?
by niesar
Hi guys,
I'm close to get crazy because I don't find a way to debug what JSF/Seam is doing behind the curtain.
My current problem is that I'm displaying a data table and I want to enable the user to select a few of these rows using checkboxes. I'm doing fine to display the table, and all the rows which should be pre-selected by default are indeed checked. However, I'm getting a funny result when I'm getting the user's input back from JSF. (_all_ table rows are returned as non-selected, regardless of what the user actually selected)
Well, I'm sitting with this problem for the complete weekend now and don't know which way I could find out what is going wrong. Could anybody please give me any idea how I could debug this baby? I tried a lot in the last days, but it looks like I'm missing the point - and I don't know how to find out what's going wrong.
To give you an idea what I'm doing:
I'm writing a data table like this: <h:dataTable value="#{sortedTangibleLocations}" var="distanceLocationPair" rendered="#{sortedTangibleLocations!=null and sortedTangibleLocations.rowCount>0}">
| ... [display distanceLocationPair, never mind - works fine]
| <h:column>
| <f:facet name="header">"In" Area #{areaSearch.selectedArea}</f:facet>
| <h:selectBooleanCheckbox value="#{areaMemberSelections[distanceLocationPair]}" />
| </h:column>
| </h:dataTable>
I kind of need to understand what happens with "areaMemberSelection." areaMemberSelection is a Map<DistanceLocationPair,Boolean> and it is supposed to carry the information which data row is selected to and from the JSF page. @In(scope=ScopeType.CONVERSATION,required=false)
| @Out(scope=ScopeType.CONVERSATION,required=false)
| private Map<DistanceLocationPair,Boolean> areaMemberSelections;
As I said before, I'm able to pre-select rows from the data table (List sortedTangibleLocations). Map areaMemberSelections is initialized with those (few) table rows which should be displyed as pre-selected. Please note that I don't include all table rows here, just those which should be marked as selected.
However, when I get the user selecetions back in the action bean, I always get the same strange result. Map areaMemberSelections is obviously changed - but it's wrong. I'm getting a map with _all_ the rows from the displayed table - and none of them is selected, the Boolean is always false. No matter what the user does and no matter what the default selections were. In the end I'm only getting "unselected" table rows.
You see, since populating my "input fields" (checkboxes) worls fine, I think I'm on the right track. Furthermore, it's done quite closely following the Seam examples (dvdstore). So I would really like to debug what's going on and why I keep on getting this strange result with everything unselected. But I don't know how to do that. Any ideas what to do, please?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3960212#3960212
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3960212
19 years, 9 months