I'm trying to connect to a webservice https protected through a webservice client. Eclipse generated a stub based webservice client and looks nice to me. The problem comes when I try to call a method from the webservice:
String a = (String)webservice.userProfileServices(xml);
I'm also using the following SOAP headers:
esgGatewayPort = (new EsgGatewayLocator()).getesgGatewayPort();
//setting the authentication header
PrefixedQName name = new PrefixedQName("http://schemas.xmlsoap.org/ws/2002/07/secext","Security","wsse");
System.out.println("Setting headers for authentication");
org.apache.axis.message.SOAPHeaderElement sh = new org.apache.axis.message.SOAPHeaderElement(name);
SOAPElement sub;
try {
String clntUserName="myUser";
String clntPassword="myPassword";
sub = sh.addChildElement("UsernameToken");
SOAPElement element = sub.addChildElement("Username");
element.addTextNode(clntUserName);
element = sub.addChildElement("Password");
element.addTextNode(clntPassword);
((org.apache.axis.client.Stub) esgGatewayPort).setHeader(sh);
} catch (SOAPException e) {
e.printStackTrace();
}
I receive the following:
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXException: Bad envelope tag: HTML
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException: Bad envelope tag: HTML
at org.apache.axis.message.EnvelopeBuilder.startElement(EnvelopeBuilder.java:71)
at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1048)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at weblogic.xml.jaxp.WebLogicXMLReader.parse(WebLogicXMLReader.java:133)
at weblogic.xml.jaxp.RegistryXMLReader.parse(RegistryXMLReader.java:153)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
Any help will be truly appreciated.
Wrong format of the endpoint
Ex: http://localhost:8080/YourService/
Ex: http://localhost:8080/YourService?wsdl
Correct endpoint format to set the constructor
Ex: http://localhost:8080/YourService
I resolved the problem in WAS (WebSphere Application Server), following http://www-01.ibm.com/support/docview.wss?uid=swg1PK54518. Applying the appropriate Fix Pack for your version of WAS resolved the issue.
The problem is probably that you are trying to bind to a https service using http. I had this problem when eclipse generated the stubs for me from a wsdl that was hosted on a https server.
Edit the generated files by eclipse that points to the server URL and it should connect correctly.
Hope that helps.
In my case it got resolved after removing "/" from end of the URL in Axis (not Axis2)
The URL which I was using http://localhost:7000/myWS/
After changing it to http://localhost:7000/myWS worked fine!
Exception:
Main: org.xml.sax.SAXException: Bad envelope tag: table
at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:701)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
Main: org.xml.sax.SAXException: Bad envelope tag: script
In our case error "Bad envelope tag: script" occurred because of user id got locked
Related
Can someone please let me know how to configure the maxFileSize for fileUploads in Jodd, when using Joy?
I've tried in joy.props, even under [joy.madvoc] section with the earlier working:
madvocConfig.fileUploadFactory.maxFileSize=-1
But have no luck :(
Another question is how to force it, to report error, as without it, got:
java.lang.NullPointerException
com.mycircle.action.CircleAction.add(CircleAction.java:78)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
jodd.madvoc.ActionRequest.invokeActionMethod(ActionRequest.java:256)
jodd.madvoc.ActionRequest.lambda$createExecutionArray$1(ActionRequest.java:226)
jodd.madvoc.ActionRequest.invoke(ActionRequest.java:240)
jodd.madvoc.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:79)
jodd.madvoc.interceptor.ActionInterceptor.apply(ActionInterceptor.java:38)
jodd.madvoc.ActionRequest.invoke(ActionRequest.java:240)
jodd.joy.i18n.I18nInterceptor.intercept(I18nInterceptor.java:46)
jodd.madvoc.interceptor.ActionInterceptor.apply(ActionInterceptor.java:38)
jodd.madvoc.ActionRequest.invoke(ActionRequest.java:240)
jodd.madvoc.ActionRequest.lambda$createExecutionArray$0(ActionRequest.java:209)
jodd.madvoc.ActionRequest.invoke(ActionRequest.java:240)
jodd.madvoc.component.MadvocController.invoke(MadvocController.java:163)
jodd.madvoc.MadvocServletFilter.doFilter(MadvocServletFilter.java:109)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
jodd.decora.DecoraServletFilter.doFilter(DecoraServletFilter.java:144)
After debugging, I figured out that is due to file size limitation 100240 bytes defined in FileUploadFactory and AdaptiveFileUploadFactory as well.
I have a #In FileUpload image; in CircleAction and it become null due to this.
Here is how to do so:
from Joy get to the Madvoc
in Madvoc get the FileUploader component - it's a new one that simply holds a FileUploadFactory instance.
Use it:)
Something like this:
public class MyWebApplication extends JoyContextListener {
#Override
protected JoddJoy createJoy() {
final JoddJoy joy = super.createJoy();
joy.withWebApp(webApp -> {
webApp.withRegisteredComponent(FileUploader.class, fileUploader -> {
AdaptiveFileUploadFactory adaptiveFileUploadFactory =
(AdaptiveFileUploadFactory) fileUploader.get();
adaptiveFileUploadFactory.setMaxFileSize(10000000);
});
});
return joy;
}
}
The seccond way is to use registerComponent and simply pass your implementation of FileUploader.
Atm, it is not possible to set this value from the madvoc config, but I will fix that soon. There is no more madvocConfig - instead you can set each component. So you will be able to do so like this: fileUploader.maxFileSize (after the fix:).
I have created a REST API at URL: http://localhost:8888/rest/contacts with this JSON output:
{
"contact": {
"address": [
{
"city":"Shanghai",
"street":"Long Hua Street"
},
{
"city":"Shanghai",
"street":"Dong Quan Street"
}
],
"id": "huangyim",
"name": "Huang Yi Ming"
}
}
I want to print only the id value in a smartGWT ListGrid.
public class ExampleEntry implements EntryPoint {
#Override
public void onModuleLoad() {
DataSource dataSource = new DataSource();
dataSource.setDataFormat(DSDataFormat.JSON);
dataSource.setDataURL("http://localhost:8888/rest/contacts");
dataSource.setRecordXPath("/contact");
DataSourceTextField field = new DataSourceTextField("id", "id");
dataSource.addField(field);
final ListGrid grid = new ListGrid();
grid.setDataSource(dataSource);
grid.setAutoFetchData(true);
grid.draw();
}
}
But it is throwing the following exception:
15:33:12.766 [ERROR] [jerseyexample] 15:33:12.747:XRP2:WARN:RPCManager:xmlHttpRequest.getAllResponseHeaders() returned null
com.smartgwt.client.core.JsObject$SGWT_WARN: 15:33:12.747:XRP2:WARN:RPCManager:xmlHttpRequest.getAllResponseHeaders() returned null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
at java.lang.Thread.run(Unknown Source)
I tried searching google to find a fix but that did not help. Please let me know if anyone knows a solution for this issue.
You just need to change the data url, instead of using an absolute path use a relative one.
change
dataSource.setDataURL("http://localhost:8888/rest/contacts");
to
dataSource.setDataURL("rest/contacts");
This is also neccesary when you'll have to deploy it to a remote server.
I recommend you use a RestDataSource instead of a plain DataSource, it has been designed specificaly for REST services, as you've said you use.
Using a RestDataSource is as simple as using DataSource.
#Override
public void onModuleLoad() {
RestDataSource dataSource = new RestDataSource();
dataSource.setDataFormat(DSDataFormat.JSON);
dataSource.setDataURL("rest/contacts");
dataSource.setRecordXPath("/contact");
DataSourceTextField field = new DataSourceTextField("id", "id");
dataSource.addField(field);
OperationBinding get=new OperationBinding();
get.setOperationType(DSOperationType.FETCH);
dataSource.setOperationBindings(get);
final ListGrid grid = new ListGrid();
grid.setDataSource(dataSource);
grid.setAutoFetchData(true);
grid.draw();
}
You can map each OperationBinding with each http method (GET, POST PUT, DELETE) or whatever suits your REST API.
Cheers!
You can put directly Xpath in the field you want to map
RecordXPath can be specified directly on the DataSource for a simple read-only DataSource only capable of "fetch" operations.
field.setRecordXPath("contact")
I got following repsonse from a Web service call, I tried to unmarshal the same using JAXB to map it to a java class. I was getting unmarshal exception while doing so.
<?xml version="1.0" encoding="UTF-8"?>
<ns0:QueryByLNResponse xmlns:ns0="UIS_CTMPeople_WS" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns0:getListValues>
<ns0:First_Name>Pradeep</ns0:First_Name>
<ns0:Internet_E-mail/>
<ns0:ManagersName/>
<ns0:Person_ID>PPL1</ns0:Person_ID>
<ns0:Last_Name>Srinivasa Reddy</ns0:Last_Name>
<ns0:Full_Name>Pradeep M Srinivasa Reddy</ns0:Full_Name>
</ns0:getListValues>
<ns0:getListValues>
<ns0:First_Name>Geeth </ns0:First_Name>
<ns0:Internet_E-mail>bas#yahoo.com</ns0:Internet_E-mail>
<ns0:ManagersName/>
<ns0:Person_ID>PPL2</ns0:Person_ID>
<ns0:Last_Name>Srinivasan</ns0:Last_Name>
<ns0:Full_Name>Geeth Srinivasan</ns0:Full_Name>
</ns0:getListValues>
</ns0:QueryByLNResponse>
I tried to unmarshal the above code using
public static Object xmlToObject(String xml, Class... objClass) throws Exception {
JAXBContext jc = JAXBContext.newInstance(objClass);
final Unmarshaller unmarshaller = jc.createUnmarshaller();
return unmarshaller.unmarshal(new StringReader(xml.toString()));
}
It was throwing following error
javax.xml.bind.UnmarshalException: unexpected element (uri:"UIS_CTMPeople_WS", local:"QueryByLNeResponse"). Expected elements are (none)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportError(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportError(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.SAXConnector.startElement(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Unknown Source)
How can i unmarshalling this using JAXB ( xml to object ).
Below are a few items that should help:
NAMESPACES
You should use a the #XmlSchema annotation on the package-info class to specify the namespace qualification. Below is an example, you will need to change the package name to match your model.
package-info.java
#XmlSchema(
namespace = "UIS_CTMPeople_WS",
elementFormDefault = XmlNsForm.QUALIFIED)
package example;
import javax.xml.bind.annotation.XmlNsForm;
import javax.xml.bind.annotation.XmlSchema;
For More Information
http://blog.bdoughan.com/2010/08/jaxb-namespaces.html
ROOT ELEMENTS
It appears that you do not have any of your classes mapped with #XmlRootElement (or #XmlElementDecl). I would expect you to have something like the following:
QueryByLNResponse
package example;
#XmlRootElement(name="QueryByLNResponse")
public class QueryByLNResponse {
}
Alternatively you could specify the class you wish to unmarshal to, by using one of the unmarshal methods that take a Class parameter:
return unmarshaller.unmarshal(xml, QueryByLNResponse.class)
For More Information
http://blog.bdoughan.com/2012/07/jaxb-and-root-elements.html
PERFORMANCE
In your same code you are creating a new JAXBContext each time you do an unmarshal. JAXBContext is a thread safe object which can be created once and reused to improve performance.
I am searching for a library to visualize data as glyphs over a map. Therefore I thought of using google maps api v3 in gwt and dwar the glyohs as an overlay overlay.
Unfortunately I couldn't find any working sample code to get started.
I followed this tutorial
and while executing the project I got this Error:
Unable to load module entry point
classcom.example.google.gwt.mapstutorial.client.SimpleMaps (see associated exception or
details)
java.lang.RuntimeException: Deferred binding failed for
'com.google.gwt.maps.client.impl.MapOptionsImpl' (did you forget to inherit a required module?)
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:53)
at com.google.gwt.core.client.GWT.create(GWT.java:97)
at com.google.gwt.maps.client.impl.MapOptionsImpl.<clinit>(MapOptionsImpl.java:31)
at com.google.gwt.maps.client.MapOptions.<init>(MapOptions.java:40)
at com.example.google.gwt.mapstutorial.client.SimpleMaps.onModuleLoad(SimpleMaps.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:396)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Unknown Source)Caused by: java.lang.IncompatibleClassChangeError: Found interface com.google.gwt.core.ext.typeinfo.JClassType, but class was expected
at com.google.gwt.jsio.rebind.JSWrapperGenerator.generate(JSWrapperGenerator.java:276)
at com.google.gwt.core.ext.GeneratorExtWrapper.generate(GeneratorExtWrapper.java:48)
at com.google.gwt.core.ext.GeneratorExtWrapper.generateIncrementally(GeneratorExtWrapper.java:60)
at com.google.gwt.dev.javac.StandardGeneratorContext.runGeneratorIncrementally(StandardGeneratorContext.java:647)
at com.google.gwt.dev.cfg.RuleGenerateWith.realize(RuleGenerateWith.java:41)
at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind(StandardRebindOracle.java:78)
at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:268)
at com.google.gwt.dev.shell.ShellModuleSpaceHost.rebind(ShellModuleSpaceHost.java:141)
at com.google.gwt.dev.shell.ModuleSpace.rebind(ModuleSpace.java:585)
at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:455)
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:49)
at com.google.gwt.core.client.GWT.create(GWT.java:97)
at com.google.gwt.maps.client.impl.MapOptionsImpl.<clinit>(MapOptionsImpl.java:31)
at com.google.gwt.maps.client.MapOptions.<init>(MapOptions.java:40)
at com.example.google.gwt.mapstutorial.client.SimpleMaps.onModuleLoad(SimpleMaps.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:396)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Unknown Source)
Could anyone help me out here, or does anyone has another suggestion for a library to use in gwt, thanks!
Here is my Code:
package com.example.google.gwt.mapstutorial.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.maps.client.MapOptions;
import com.google.gwt.maps.client.MapTypeId;
import com.google.gwt.maps.client.MapWidget;
import com.google.gwt.maps.client.base.LatLng;
import com.google.gwt.user.client.ui.RootPanel;
public class SimpleMaps implements EntryPoint {
private MapWidget mapWidget;
// GWT module entry point method.
public void onModuleLoad() {
final MapOptions options = new MapOptions();
// Zoom level. Required
options.setZoom(8);
// Open a map centered on Cawker City, KS USA. Required
options.setCenter(new LatLng(39.509, -98.434));
// Map type. Required.
options.setMapTypeId(new MapTypeId().getRoadmap());
// Enable maps drag feature. Disabled by default.
options.setDraggable(true);
// Enable and add default navigation control. Disabled by default.
options.setNavigationControl(true);
// Enable and add map type control. Disabled by default.
options.setMapTypeControl(true);
mapWidget = new MapWidget(options);
mapWidget.setSize("800px", "600px");
// Add the map to the HTML host page
RootPanel.get("mapsTutorial").add(mapWidget);
}
}
In my application, I have the following Message Driven Bean to connect to the Postfix SMTP server to send emails to user:
#MessageDriven(mappedName = "jms/OutgoingEmailQueue", activationConfig = {
#ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
#ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
})
public class OutgoingEmailBean implements MessageListener {
//Resource
#Resource(name = "mail/MailSession")
private Session mailSession;
public void onMessage(Message message) {
try {
....
//Create the email
javax.mail.Message email = new MimeMessage(mailSession);
....
//Send the email
Transport.send(email);
} catch (Exception e) {
System.out.println(e.toString());
}
}
}
When I deploy this application using NetBeans with GlassFish 2.1 on my laptop, it can connect to the SMTP server and send out emails perfectly. However, when I copy all the settings over to the online Sun Java System Application Server 9.1 and deploy my application, my application no longer can send out emails. Instead, I got the exception javax.mail.AuthenticationFailedException at the line "Transport.send(email)". In the server log, I saw these lines:
[#|2011-08-01T15:18:02.077+0400|SEVERE|sun-appserver9.1|ejb.Mailing.OutgoingEmailBean|_ThreadID=34;_ThreadName=p: thread-pool-1; w: 665;_RequestID=52699cfe-71a2-46be-83b0-f3af23d74c0c;|The log message is null.
javax.mail.AuthenticationFailedException
at javax.mail.Service.connect(Service.java:319)
at javax.mail.Service.connect(Service.java:169)
at javax.mail.Service.connect(Service.java:118)
at javax.mail.Transport.send0(Transport.java:188)
at javax.mail.Transport.send(Transport.java:118)
at ejb.Mailing.OutgoingEmailBean.onMessage(OutgoingEmailBean.java:110)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1067)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176)
at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2895)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3986)
at com.sun.ejb.containers.MessageBeanContainer.deliverMessage(MessageBeanContainer.java:1111)
at com.sun.ejb.containers.MessageBeanListenerImpl.deliverMessage(MessageBeanListenerImpl.java:74)
at com.sun.enterprise.connectors.inflow.MessageEndpointInvocationHandler.invoke(MessageEndpointInvocationHandler.java:179)
at $Proxy93.onMessage(Unknown Source)
at com.sun.messaging.jms.ra.OnMessageRunner.run(OnMessageRunner.java:258)
at com.sun.enterprise.connectors.work.OneWork.doWork(OneWork.java:76)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
|#]
I spent 2 days looking around to make sure all the local settings of GlassFish 2.1 are identical to the settings of the online appserver but I still cannot solve the problem. I'd be very grateful if someone could give me an advice on how to tackle this issue.
Best regards,
James Tran
I found out that in Postfix configuration, "mynetworks" property didn't include the IP address of my domain. After adding the IP address, my application can send out emails normally already.