File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JBoss/WildFly and the fly likes I set up JBoss mail, so why can't I access the mail bean? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "I set up JBoss mail, so why can Watch "I set up JBoss mail, so why can New topic
Author

I set up JBoss mail, so why can't I access the mail bean?

Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
Hi,

I'm using JBoss 5.1 (Java 1.6) on Mac 10.5.6. I haev a web application and am trying to access the mail session via



in which "getMailSession" returns "java:/Mail". However I'm getting the error below. What is the proper way to lookup the mail session? I have this defined in my mail-server.xml file ...



- Dave


Stack trace follows ...
javax.naming.NameNotFoundException: Mail not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
at org.jnp.server.NamingServer.lookup(NamingServer.java:443)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:726)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
at javax.naming.InitialContext.lookup(InitialContext.java:409)
at
myco.galc.capitol.tours.Emailer.lookupMailSession(Emailer.java:68)
at myco.galc.capitol.tours.Emailer.sendEmail(Emailer.java:55)
at
myco.galc.capitol.tours.CapitolToursController.sendEmail(CapitolToursController.java:297)
at
myco.galc.capitol.tours.CapitolToursController.sendEmail(CapitolToursController.java:282)
at
myco.galc.capitol.tours.CapitolToursController.confirmTourRequests(CapitolToursController.java:163)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.el.parser.AstValue.invoke(AstValue.java:170)
at
org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
at
org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:68)
at
javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
at
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:387)
at
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
at
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756)
at
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
at
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:285)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:341)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at
org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at
org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at
org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:567)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:636)
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

Try using JNDIview to see where the mail server name was bound: http://www.jboss.org/community/wiki/DisplayTheJDNITreeWithTheJMXConsole


JBoss In Action
Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
Thanks, I did as you suggested, and didn't even see a mail bean set up (Output is below). Is mail not turned on by default? I have everything set up in

/opt/jboss/current/server/default/deploy/mail-service.xml

How does that get loaded? Thanks, - Dave



Ouptut of jmx-console JNDI View:
=====================

java: Namespace

+- securityManagement (class: org.jboss.security.integration.JNDIBasedSecurityManagement)
+- comp (class: javax.namingMain.Context)
+- DeploymentManager (class: org.jboss.aop.generatedproxies.AOPProxy$4)
+- TransactionPropagationContextImporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
+- policyRegistration (class: org.jboss.security.plugins.JBossPolicyRegistration)
+- TransactionPropagationContextExporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
+- jaas (class: javax.naming.Context)
| +- jboss-web-policy (class: org.jboss.security.plugins.SecurityDomainContext)
+- TransactionSynchronizationRegistry (class: com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple)
+- SecurityProxyFactory (class: org.jboss.security.SubjectSecurityProxyFactory)
+- TransactionManager (class: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate)
+- timedCacheFactory (class: javax.naming.Context)
Failed to lookup: timedCacheFactory, errmsg=org.jboss.util.TimedCachePolicy cannot be cast to javax.naming.NamingEnumeration
+- ManagementView (class: org.jboss.aop.generatedproxies.AOPProxy$3)


Global JNDI Namespace

+- UserTransactionSessionFactory (proxy: $Proxy92 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
+- ProfileService (class: org.jboss.aop.generatedproxies.AOPProxy$2)
+- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
+- jmx (class: org.jnp.interfaces.NamingContext)
| +- invoker (class: org.jnp.interfaces.NamingContext)
| | +- RMIAdaptor (proxy: $Proxy85 implements interface org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface org.jboss.jmx.adaptor.rmi.RMIAdaptorExt)
| +- rmi (class: org.jnp.interfaces.NamingContext)
| | +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class: javax.naming.LinkRef)
+- TomcatAuthenticators (class: java.util.Properties)
+- console (class: org.jnp.interfaces.NamingContext)
| +- PluginManager (proxy: $Proxy86 implements interface org.jboss.console.manager.PluginManagerMBean)
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

Look through the console log, you should see the following line as part of startup:

08:09:41,786 INFO [MailService] Mail Service bound to java:/Mail

And here is my java: namespace:



I seem to have many more names - are you sure your are running the 'default' config?


Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
Good question. Since I am so new to JBoss, how do I verify that I'm running the default config? - Dave
Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
One other thing, I don't see any "Mail" set up in your namespace. Is that because you don't have java:/Mail set up either? - Dave
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10202
    
166

Dave Alvarado wrote:One other thing, I don't see any "Mail" set up in your namespace. Is that because you don't have java:/Mail set up either? - Dave

It's there in Peter's JNDI output:




Since I am so new to JBoss, how do I verify that I'm running the default config?


How do you start the server? When you use the run.sh or the run.bat files to start the server, by default the "default" server configuration is started. If you want to start a different server configuration then you use, the -c option:



The above command starts the "all" server configuration.

When the server is starting it logs the server config name to the console (as well as server.log):


[My Blog] [JavaRanch Journal]
Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
Oops, don't know how I missed that. I checked my "boot.log" file (for some reason, that is where my console output is going to) and I have this line ...



However in my "server" folder (in the JBoss installation directory), I only have "all", "default", "standard", "minimal", and "web" folders. So do I need to create another folder matching the server name that I'm using? Is this potentially why my mail bean isn't loading?

Thanks for all the help, - Dave
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10202
    
166

This doesn't look like a clean downloaded version of AS. Probably someone customized the JBoss you are using? Where did you get it from?
Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
I did inherit a project from a developer who is no longer here. To answer your earlier question, I start/stop the server using scripts that invoke run.sh. I'm cutting and pasting the contents of the start script here




But things do appear to run fine even with the different server name. But do I need to create a folder with the same name under server? Thanks, - Dave
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10202
    
166

1) Since this a customized JBoss installation, there might be some services which might have been removed like the Mail service, some services added or something changed. Overall, if you want to try things out (since you mentioned you are new to JBoss), i would recommend you try out on a clean downloaded AS instance and then port them to this customized server. That way, if you run into any issues with the default downloaded instance, someone else here will be able to help.
2)

But things do appear to run fine even with the different server name. But do I need to create a folder with the same name under server


If the "dev-jboss-web-5.1.0" server configuration was absent, then the server would never even have started. So i guess you are looking at the wrong place for this folder. The scripts shows that the server being used is located at



So it's under that path where you have to look for the AS files. The scripts also seem to be changing logging related configs, which would explain why you saw the logs only in boot.log.
Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
Let me ask a more general question going to back the Mail bean issue. How does JBoss know to load the Mail bean? In other words, does it know to look for a file named "mail-service.xml" and if so, where does it expect that file to live?

Thanks again, - Dave
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10202
    
166

The files/applications under JBOSS_HOME/server/< servername>/deploy folder are deployed by JBoss. Different application types have files with different extensions. Like .war, .ear, .jar. Then there are xml files like *-ds.xml (meant for datasources) and *-service.xml (meant for MBean services). So if you place a file named blahblahblah-service.xml in the deploy folder, it will be picked up, parsed and deployed if there are no issues with the file.
Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
You are a certified genius. Placing a "mail-serivce.xml" file in my server/deploy directory did it. I am now able to look up the bean. Although I'm getting some other errors, I have gotten past this problem so thanks so much for your help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I set up JBoss mail, so why can't I access the mail bean?