Websphere Application Server 7 Datasource test connection error - websphere

I am trying to connect data source with correct username and password in Websphere application server 7. I am getting following error:
[10/17/16 12:34:18:510 EDT] 00041199 DSConfigurati W DSRA8200W: DataSource Configuration: DSRA8020E: Warning: The property 'metaDataSource' does not exist on the DataSource class com.ibm.as400.access.AS400JDBCConnectionPoolDataSource.
[10/17/16 12:34:18:635 EDT] 00041199 DSConfigurati W DSRA8200W: DataSource Configuration: DSRA8020E: Warning: The property 'translateBoolean' does not exist on the DataSource class com.ibm.as400.access.AS400JDBCConnectionPoolDataSource.
[10/17/16 12:34:18:932 EDT] 00041199 DSConfigurati I DSRA8203I: Database product name : DB2 UDB for AS/400
[10/17/16 12:34:18:948 EDT] 00041199 DSConfigurati I DSRA8204I: Database product version : 07.01.0000 V7R1m0
[10/17/16 12:34:18:948 EDT] 00041199 DSConfigurati I DSRA8205I: JDBC driver name : AS/400 Toolbox for Java JDBC Driver
[10/17/16 12:34:18:948 EDT] 00041199 DSConfigurati I DSRA8206I: JDBC driver version : 7.0
[10/17/16 12:34:19:010 EDT] 000411a4 access E Mon Oct 17 12:34:18 EDT 2016 run(): Caught IOException:
java.net.SocketException: socket closed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:140)
at com.ibm.as400.access.DataStream.readFromStream(DataStream.java:48)
at com.ibm.as400.access.ClientAccessDataStream.construct(ClientAccessDataStream.java:46)
at com.ibm.as400.access.AS400ThreadedServer.run(AS400ThreadedServer.java:321)
at java.lang.Thread.run(Thread.java:761)
[10/17/16 12:34:19:104 EDT] 00041199 DSConfigurati I DSRA8030I: Successfully connected to DataSource, with 2 warnings.
Can anyone tell why it is coming like this. Because I have searched lot of times in internet there is no exact match of answers for this error.

Related

Why Weblogic server is not able to access Oracle DB account on localhost?

I have an Spring MVC application with oracle db for storage. I have deployed SpringMVC.war in tomcat and its working fine. But whenever I am deploying my application on Weblogic, it is throwing following exception
I have an account with the name "Asif123" on Oracle DB and is configured in "application-context.xml" in my project, but it is only accessible in Tomcat , not Weblogic.
application-context.xml
<bean id="ds" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:/comp/env/ds1"/>
</bean>
Successful datasource test:
####<30-Oct-2017, 3:27:00,931 PM IST> <Error> <Deployer> <asif-dell> <AdminServer> <[STANDBY] ExecuteThread: '11' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <727e01e2-9cca-411b-8bc9-290fc833664e-00000014> <1509357420931> <[severity-value: 8] [rid: 0] [partition-id: 0] [partition-name: DOMAIN] > <BEA-149265> <Failure occurred in the execution of deployment request with ID "155312441642365" for task "weblogic.deploy.configChangeTask.1" on [partition-name: DOMAIN]. Error is: "weblogic.application.ModuleException: java.sql.SQLException: Access denied for user 'asif123'#'localhost' (using password: YES)"
weblogic.application.ModuleException: java.sql.SQLException: Access denied for user 'asif123'#'localhost' (using password: YES)
at weblogic.jdbc.module.JDBCModule.prepare(JDBCModule.java:411)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:100)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:192)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:187)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
at weblogic.application.internal.flow.ModuleStateDriver.prepare(ModuleStateDriver.java:37)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:77)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:55)
at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:727)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:239)
at weblogic.application.internal.SingleModuleDeployment.prepare(SingleModuleDeployment.java:52)
at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:158)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:65)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:229)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:103)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:241)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:794)
at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1340)
at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:235)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:177)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:186)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.prepare(DeploymentReceiverCallbackDeliverer.java:42)
at weblogic.deploy.service.internal.statemachines.targetserver.AwaitingContextUpdateCompletion.callDeploymentReceivers(AwaitingContextUpdateCompletion.java:170)
at weblogic.deploy.service.internal.statemachines.targetserver.AwaitingContextUpdateCompletion.handleContextUpdateSuccess(AwaitingContextUpdateCompletion.java:66)
at weblogic.deploy.service.internal.statemachines.targetserver.AwaitingContextUpdateCompletion.contextUpdated(AwaitingContextUpdateCompletion.java:32)
at weblogic.deploy.service.internal.targetserver.TargetDeploymentService.notifyContextUpdated(TargetDeploymentService.java:232)
at weblogic.deploy.service.internal.DeploymentService$1.run(DeploymentService.java:210)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:666)
at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:348)
at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:333)
at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:54)
at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41)
at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:640)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:406)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:346)
Caused By: java.sql.SQLException: Access denied for user 'asif123'#'localhost' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1058)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:919)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1694)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1244)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2396)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2429)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2214)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:797)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:31)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
The fact that you are getting a MySQL error message when connecting to an Oracle database might be a bit of a clue.
Check your Weblogic datasource type - have you incorrectly configured it to be a MySQL connection to an Oracle DB ?

Remote EJB issue with Liberty and Spring Boot 1.4.2

I am getting the following error when making remote EJB call with Liberty Profile in a Spring Boot application.
org.omg.CORBA.BAD_PARAM: bad address: iiop port is invalid: vmcid: OMG minor code: 0x8
My code looks like this:
InitialContext ctx = new InitialContext();
Object obj = ctx.lookup("corbaloc:iiop:my.host.com:9810#ejb/com/dwl/base/requestHandler/beans/DWLServiceController");
dwlServiceControllerHome = (DWLServiceControllerHome) PortableRemoteObject.narrow(obj, DWLServiceControllerHome.class);
Error Trace:
[err] org.omg.CORBA.BAD_PARAM: bad address: iiop port is invalid: vmcid: OMG minor code: 0x8 completed: No
[err] at org.apache.yoko.orb.OCI.IIOP.CorbalocProtocol_impl.parse_address(CorbalocProtocol_impl.java:121)
[err] at [internal classes]
[err] at javax.naming.InitialContext.lookup(InitialContext.java:417)
I am using JEE 7 full profile Liberty profile 16.0.0.3.
You may try adding "NameServiceServerRoot" after port:
InitialContext ctx = new InitialContext();
Object obj = ctx.lookup("corbaloc:iiop:my.host.com:9810/NameServiceServerRoot#ejb/com/dwl/base/requestHandler/beans/DWLServiceController");
dwlServiceControllerHome = (DWLServiceControllerHome) PortableRemoteObject.narrow(obj, DWLServiceControllerHome.class);
We solved CORBA.BAD_PARAM error adding it to the url. Our case was invoking a deployed ejb in a WAS full from a Liberty profile

Hikaricp Oracle connection issue

I have the following code to get connection to the oracle database. But using hikaricp I am getting the exception.
java.sql.SQLException: Invalid Oracle URL specified: OracleDataSource.makeURL
Code:
private static HikariDataSource dataSource() {
final HikariDataSource hikariDataSource = new HikariDataSource();
hikariDataSource.setMaximumPoolSize(100);
hikariDataSource.setMinimumIdle(10);
hikariDataSource.setDataSourceClassName("oracle.jdbc.pool.OracleDataSource");
Properties properties = new Properties();
properties.put("user", "user");
properties.put("password", "pass");
properties.put("databaseName", "XE");
properties.put("serverName", "192.168.21.13");
properties.put("portNumber", "1521");
hikariDataSource.setDataSourceProperties(properties);
//Additionally I am setting connection test query and max life time also
return hikariDataSource;
}
The complete stacktrace is
Exception in thread "main" java.lang.RuntimeException: Fail-fast during pool initialization
at com.zaxxer.hikari.pool.HikariPool.fillPool(HikariPool.java:499)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:162)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:113)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:102)
at java.lang.reflect.Method.invoke(Method.java:597)
Caused by: java.sql.SQLException: Invalid Oracle URL specified: OracleDataSource.makeURL
at oracle.jdbc.pool.OracleDataSource.makeURL(OracleDataSource.java:1277)
at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:185)
at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:157)
at com.zaxxer.hikari.pool.HikariPool.addConnection(HikariPool.java:418)
at com.zaxxer.hikari.pool.HikariPool.fillPool(HikariPool.java:498)
... 11 more
How do I establish successful pool? I am using oracle jar
http://download.oracle.com/otn/utilities_drivers/jdbc/111070/ojdbc6.jar
and the jdk is 1.6. Hikaricp version is 2.2.5 for java 6.
try to set the driver type to thin.
properties.put("driverType", "thin");

Webshpere datasource error:Unable to lookup JNDI name

I am developing an application with Hibernate and Websphere Application Server 8.0.
I have create a datasource in Websphere and it can connect with database successfully.
But from application I am getting following error:
SystemErr R Error creating Session: org.hibernate.service.jndi.JndiException: Unable to lookup JNDI name [java:comp/env/jdbc/OracleDS]
Following is the setup I have done:
Websphere datasource setup:
hibernate.cfg.xml
web.xml
When I try to get sessiofactory, it gives me error:
HibernateUtil.java:
try
{
Configuration configuration = new Configuration().configure();
serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
}
catch (HibernateException he)
{
System.err.println("Error creating Session: " + he);
throw new ExceptionInInitializerError(he);
}
Error:
java.lang.NullPointerException
at com.ibm.ws.webcontainer.metadata.WebComponentMetaDataImpl.getJavaNameSpace(WebComponentMetaDataImpl.java:143)
at com.ibm.ws.threadContext.JavaNameSpaceAccessorImpl.getJavaNameSpace(JavaNameSpaceAccessorImpl.java:79)
at com.ibm.ws.naming.java.javaURLContextFactory.createURLContextRoot(javaURLContextFactory.java:137)
at com.ibm.ws.naming.urlbase.UrlContextFactory.getObjectInstance(UrlContextFactory.java:101)
at org.apache.aries.jndi.URLContextProvider.getContext(URLContextProvider.java:43)
at org.apache.aries.jndi.DelegateContext.getURLContext(DelegateContext.java:252)
at org.apache.aries.jndi.DelegateContext.findContext(DelegateContext.java:214)
at org.apache.aries.jndi.DelegateContext.findContext(DelegateContext.java:207)
at org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.java:157)
at javax.naming.InitialContext.lookup(InitialContext.java:432)
at org.hibernate.service.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:65)
at org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl.configure(DatasourceConnectionProviderImpl.java:116)
at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:223)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:89)
at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1818)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1776)
at com.test.util.HibernateUtil.(HibernateUtil.java:25)
Error creating Session: org.hibernate.service.jndi.JndiException: Unable to lookup JNDI name [java:comp/env/jdbc/OracleDS]
Please let me know what I am missing.
I have applied more tries, now I am getting following error:
FFDC Exception:javax.naming.NamingException SourceId:com.ibm.ws.naming.java.javaURLContextFactory.createURLContextRoot ProbeId:142 Reporter:java.lang.Class#dfac0b43
javax.naming.NamingException: NMSV0308W: javaURLContextFactory cannot create a javaURLContext object because there is no java URL name space currently accessible from the executing thread.
at com.ibm.ws.naming.java.javaURLContextFactory.createURLContextRoot(javaURLContextFactory.java:170)
at com.ibm.ws.naming.urlbase.UrlContextFactory.getObjectInstance(UrlContextFactory.java:101)
at org.apache.aries.jndi.URLContextProvider.getContext(URLContextProvider.java:43)
at org.apache.aries.jndi.DelegateContext.getURLContext(DelegateContext.java:252)
at org.apache.aries.jndi.DelegateContext.findContext(DelegateContext.java:214)
at org.apache.aries.jndi.DelegateContext.findContext(DelegateContext.java:207)
at org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.java:157)
at javax.naming.InitialContext.lookup(InitialContext.java:432)
at org.hibernate.service.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:65)
at org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl.configure(DatasourceConnectionProviderImpl.java:116)
at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:223)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:89)
at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1818)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1776)
at com.test.util.HibernateUtil.(HibernateUtil.java:25)
Did you create binding between you reference and JNDI name?
You can do it
either using admin console - Enterprise Application > ApplicationName > Resource references. then select reference and map it to the datasource JNDI name
or using binding file - you need to create ibm-web-bnd.xml file with the following contents:
<resource-ref name="jdbc/OracleDS" binding-name="jdbc/OracleDS" />
In WebSphere you don't need java:comp/env at the hibernate datasource.
So your hibernate.cfg.xml would look like this:
.
.
.
<!-- JNDI Datasource -->
<property name="hibernate.connection.datasource">jdbc/OracleDS</property>
.
.
.

Websphere 7 javax.mail.MessagingException: SSLSocketFactory is null

I am trying to connect to mail server using SSL, running on Websphere 7. I have no problem running the code as a standalone test main method, everything goes fine.
I have also no problem running the code on Websphere - connecting to mail server (example imap.seznam.cz), but when I do not use SSL. In case I want to use SSL, exception is thrown like this:
javax.mail.MessagingException: SSLSocketFactory is null. This can occur if javax.net.ssl.SSLSocketFactory.getDefault() is called to
create a socket and javax.net.ssl.* properties are not set.; nested
exception is:
javax.net.ssl.SSLException: SSLSocketFactory is null. This can occur if javax.net.ssl.SSLSocketFactory.getDefault() is called to create a
socket and javax.net.ssl.* properties are not set.
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:571)
at javax.mail.Service.connect(Service.java:288)
Here is a part of a code:
Properties imapProps = new Properties();
System.out.println(imapProps);
imapProps.setProperty("mail.imap.ssl.enable", ssl ? "true" : "false");
if(ssl) {
imapProps.setProperty("mail.imap.starttls.enable", "true");
}
imapProps.setProperty("javax.net.ssl.trustStore", "c:/Program Files/IBM/WebSphere/AppServer/profiles/AppSrv01/config/cells/T431sNode03Cell/nodes/T431sNode03/trust.p12");
imapProps.setProperty("javax.net.ssl.trustStorePassword", "WebAS");
imapProps.setProperty("javax.net.ssl.trustStoreType", "PKCS12");
imapProps.setProperty("javax.net.ssl.keyStore", "c:/Program Files/IBM/WebSphere/AppServer/profiles/AppSrv01/config/cells/T431sNode03Cell/nodes/T431sNode03/key.p12");
imapProps.setProperty("javax.net.ssl.keyStorePassword", "WebAS");
imapProps.setProperty("mail.debug", "true");
Session session = Session.getInstance(imapProps, null);
session.setDebug(true);
System.out.println("--------------------------------------------------------------------------------------------");
System.out.println(imapProps.toString());
System.out.println("--------------------------------------------------------------------------------------------");
SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
System.out.println(sslsocketfactory);
// connect
try {
store = session.getStore(ssl ? "imaps" : "imap");
store.connect(imapServer, imapPort, login, password);
return true;
} catch(NoSuchProviderException ex) {
ex.printStackTrace();
return false;
} catch (MessagingException e) {
e.printStackTrace();
return false;
}
Parameters are taken from properties file...
ssl true, imapServer imap.seznam.cz, imapPort 993
This is only to check whether SSLSocketFactory is null or not, not needed in code
SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
System.out.println(sslsocketfactory);
I can see that sslsocketfactory is not null ans is of type: com.ibm.websphere.ssl.protocol.SSLSocketFactory
What I tried is:
I have certificate from mail server stored in trusted store on Websphere (using admin console, read from server's port, I can see it there)
I set up some javax.net.ssl.* properties on a Websphere server's properties and also in a code as you can see - but I do not think it it necessary
I assume Websphere is reading certificates from trust store location as seen in admin console: ${CONFIG_ROOT}/cells/T431sNode03Cell/nodes/T431sNode03/trust.p12
Can any Websphere expert help me with this problem? I am trying to fix it a couple of days with no success :-(
As I mentioned, it is working on Websphere when not using SSL, but not running when using SSL for the same mail server (for example imap.seznam.cz, also imap.gmail.com) and it is working fine with SSL when running outside Websphere as a standalone java apllication.
Thank you all, guys!
UPDATE:
Thanks Gas to pointing me to the right way how to configure mail in Websphere. So I did it, I am using Built-in Mail Provider and only created 2 mail sessions
one with SSL support using "imaps" provider
the other one without SSL support using "imap" provider
Both sessions have the same server defined and debug enabled.
In java code I am doing this:
Context context = new InitialContext();
Session session = null;
if(ssl) {
session = (Session) context.lookup("mail/exchangeSSL");
} else {
session = (Session) context.lookup("mail/exchange");
}
store = session.getStore();
store.connect(login, password);
And interesting think, the result is exactly the same. When I am using non SSL session, everything goes fine, but when I use SSL session, got this exception:
[25.6.14 16:35:19:615 SELČ] 00000023 SystemOut O *** In SessionFactory.getObjectInstance, session properties:
[25.6.14 16:35:19:615 SELČ] 00000023 SystemOut O mail.store.protocol=imaps
[25.6.14 16:35:19:615 SELČ] 00000023 SystemOut O mail.imaps.class=com.sun.mail.imap.IMAPSSLStore
[25.6.14 16:35:19:615 SELČ] 00000023 SystemOut O mail.debug=true
[25.6.14 16:35:19:615 SELČ] 00000023 SystemOut O mail.pop3s.class=com.sun.mail.pop3.POP3SSLStore
[25.6.14 16:35:19:615 SELČ] 00000023 SystemOut O mail.smtp.class=com.sun.mail.smtp.SMTPTransport
[25.6.14 16:35:19:615 SELČ] 00000023 SystemOut O mail.imaps.host=imap.seznam.cz
[25.6.14 16:35:19:616 SELČ] 00000023 SystemOut O mail.smtps.class=com.sun.mail.smtp.SMTPSSLTransport
[25.6.14 16:35:19:616 SELČ] 00000023 SystemOut O mail.imap.class=com.sun.mail.imap.IMAPStore
[25.6.14 16:35:19:616 SELČ] 00000023 SystemOut O mail.mime.address.strict=false
[25.6.14 16:35:19:616 SELČ] 00000023 SystemOut O mail.pop3.class=com.sun.mail.pop3.POP3Store
[25.6.14 16:35:19:616 SELČ] 00000023 SystemOut O DEBUG: mail.imaps.class property exists and points to com.sun.mail.imap.IMAPSSLStore
[25.6.14 16:35:19:617 SELČ] 00000023 SystemOut O DEBUG: mail.imap.fetchsize: 16384
[25.6.14 16:35:19:618 SELČ] 00000023 SystemErr R javax.mail.MessagingException: SSLSocketFactory is null. This can occur if javax.net.ssl.SSLSocketFactory.getDefault() is called to create a socket and javax.net.ssl.* properties are not set.;
nested exception is:
javax.net.ssl.SSLException: SSLSocketFactory is null. This can occur if javax.net.ssl.SSLSocketFactory.getDefault() is called to create a socket and javax.net.ssl.* properties are not set.
[25.6.14 16:35:19:618 SELČ] 00000023 SystemErr R at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:479)
[25.6.14 16:35:19:618 SELČ] 00000023 SystemErr R at javax.mail.Service.connect(Service.java:275)
UPDATE2:
I created a new fresh project from this example:
http://www.mkyong.com/maven/how-to-create-a-web-application-project-with-maven/
I only added mail session related code to the controller:
try {
Context context = new InitialContext();
Session session = (Session) context.lookup("mail/exchangeSSL");
Store store = session.getStore();
store.connect("<user>", "<password>");
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchProviderException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (MessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
And when I deploy this new web app and invoke it, the same error. In WEB-INF/lib there are only jars related to spring and commons logging:
aopalliance-1.0.jar
commons-logging-1.1.1.jar
spring-aop-3.0.5.RELEASE.jar
spring-asm-3.0.5.RELEASE.jar
spring-beans-3.0.5.RELEASE.jar
spring-context-3.0.5.RELEASE.jar
spring-context-support-3.0.5.RELEASE.jar
spring-core-3.0.5.RELEASE.jar
spring-expression-3.0.5.RELEASE.jar
spring-web-3.0.5.RELEASE.jar
spring-webmvc-3.0.5.RELEASE.jar
So I think this has something to do with server settings? I use Websphere 7.0.0.31. I added mail server certificate to NodeDefaultTrustStore in admin console (read from port) and I can see it there.
And here is the listing of jars we are using in our project:
ant-1.7.1.jar
ant-launcher-1.7.1.jar
antlr-2.7.7.jar
aopalliance-1.0.jar
asm-3.3.1.jar
aspectjrt-1.7.4.jar
aspectjweaver-1.7.4.jar
avalon-framework-api-4.3.1.jar
avalon-framework-impl-4.2.0.jar
avalon-framework-impl-4.3.1.jar
barcode4j-2.1.jar
batik-anim-1.7.jar
batik-awt-util-1.7.jar
batik-bridge-1.7.jar
batik-css-1.7.jar
batik-dom-1.7.jar
batik-ext-1.7.jar
batik-extension-1.7.jar
batik-gvt-1.7.jar
batik-js-1.7.jar
batik-parser-1.7.jar
batik-script-1.7.jar
batik-svg-dom-1.7.jar
batik-svggen-1.7.jar
batik-transcoder-1.7.jar
batik-util-1.7.jar
batik-xml-1.7.jar
bcmail-jdk16-1.45.jar
bcprov-jdk16-1.45.jar
bctsp-jdk16-1.45.jar
bsh-2.0b4.jar
c3p0-0.9.1.1.jar
cglib-2.2.2.jar
commons-beanutils-1.9.1.jar
commons-cli-1.0.jar
commons-codec-1.9.jar
commons-collections-3.2.1.jar
commons-io-1.4.jar
commons-lang-2.6.jar
commons-logging-1.1.3.jar
core-1.0-SNAPSHOT.jar
core-interface-1.0-SNAPSHOT.jar
cxf-api-2.7.5.jar
cxf-rt-bindings-soap-2.7.5.jar
cxf-rt-core-2.7.5.jar
cxf-rt-databinding-jaxb-2.7.5.jar
cxf-rt-frontend-jaxws-2.7.5.jar
cxf-rt-frontend-simple-2.7.5.jar
cxf-rt-transports-http-2.7.5.jar
cxf-rt-ws-security-2.7.5.jar
cz.dalvi.commons.common-0.1.jar
cz.dalvi.commons.crypto-0.1.jar
cz.dalvi.commons.xml-0.1.jar
dom4j-1.6.1.jar
ehcache-core-2.5.1.jar
filenet-client-1.0-SNAPSHOT.jar
flexjson-2.0.jar
fontbox-1.8.5.jar
fop-1.1.jar
hibernate-commons-annotations-4.0.4.Final.jar
hibernate-core-4.3.5.Final.jar
hibernate-entitymanager-4.3.5.Final.jar
hibernate-jpa-2.1-api-1.0.0.Final.jar
iba-commons-core-1.5.jar
iba-commons-util-1.5.jar
ibm.filenet-stax-api-1.0.jar
ini4j-0.5.1.jar
ISDSClient-1.0-SNAPSHOT.jar
isds-client-1.0-SNAPSHOT.jar
Jace-1.0.jar
jackson-annotations-2.0.5.jar
jackson-core-2.0.5.jar
jackson-databind-2.0.5.jar
jandex-1.1.0.Final.jar
javassist-3.18.1-GA.jar
javax.xml.stream-stax-api-1.0.jar
jaxb-api-2.1.jar
jaxb-impl-2.1.11.jar
jaxws-api-2.1.jar
jaxws-rt-2.1.7.jar
jboss-logging-3.1.3.GA.jar
jboss-logging-annotations-1.2.0.Beta1.jar
jboss-transaction-api_1.2_spec-1.0.0.Final.jar
jcl-over-slf4j-1.7.1.jar
jcommander-1.27.jar
jempbox-1.8.5.jar
joda-time-2.3.jar
jstl-1.2.jar
log4j-1.2.17.jar
mimepull-1.3.jar
mimepull-1.7.jar
opensaml-2.5.1-1.jar
openws-1.4.2-1.jar
pdfbox-1.8.5.jar
quartz-2.2.1.jar
resolver-20050927.jar
saaj-impl-1.3.18.jar
slf4j-api-1.7.1.jar
slf4j-log4j12-1.7.6.jar
spring-aop-4.0.3.RELEASE.jar
spring-beans-4.0.3.RELEASE.jar
spring-context-4.0.3.RELEASE.jar
spring-context-support-4.0.3.RELEASE.jar
spring-core-4.0.3.RELEASE.jar
spring-expression-4.0.3.RELEASE.jar
spring-jdbc-4.0.3.RELEASE.jar
spring-ldap-core-1.3.2.RELEASE.jar
spring-orm-4.0.3.RELEASE.jar
spring-security-config-3.2.4.RELEASE.jar
spring-security-core-3.2.4.RELEASE.jar
spring-security-ldap-3.2.4.RELEASE.jar
spring-security-web-3.2.4.RELEASE.jar
spring-tx-4.0.3.RELEASE.jar
spring-web-4.0.3.RELEASE.jar
spring-webmvc-4.0.3.RELEASE.jar
sta-client-1.0-SNAPSHOT.jar
stax2-api-3.1.1.jar
stax-api-1.0.1.jar
stax-ex-1.2.jar
streambuffer-0.9.jar
testng-6.8.8.jar
usertype.core-3.1.0.GA.jar
usertype.spi-3.1.0.GA.jar
velocity-1.7.jar
woodstox-core-asl-4.2.0.jar
ws-api-1.0-SNAPSHOT.jar
wsdl4j-1.6.3.jar
wss4j-1.6.10.jar
wstx-asl-3.2.3.jar
xalan-2.6.0.jar
xercesImpl-2.11.0.jar
xlxpScanner-1.0.jar
xlxpScannerUtils-1.0.jar
xml-apis-1.4.01.jar
xml-apis-ext-1.3.04.jar
xmlgraphics-commons-1.5.jar
xmlsec-1.5.4.jar
xmlschema-core-2.0.3.jar
xmltooling-1.3.2-1.jar
xpp3_min-1.1.4c.jar
xstream-1.3.1.jar
I think this could also be helpful, from java.security setting on my WAS:
# Default JSSE socket factories
#ssl.SocketFactory.provider=com.ibm.jsse2.SSLSocketFactoryImpl
#ssl.ServerSocketFactory.provider=com.ibm.jsse2.SSLServerSocketFactoryImpl
# WebSphere socket factories (in cryptosf.jar)
ssl.SocketFactory.provider=com.ibm.websphere.ssl.protocol.SSLSocketFactory
ssl.ServerSocketFactory.provider=com.ibm.websphere.ssl.protocol.SSLServerSocketFactory
This is not the correct way using mail sessions in the application server environment.
You should define your mail session via Resources > Mail, specify all required properties there and select whether you want to use SSL (imaps). In your application you should get the mail session via JNDI or annotations, not using getInstance().
You will need to add SSL certificate from your mail server to the NodeDeafaultTrustStore.
In general , in WebSphere, you should avoid changing any javax.net.ssl system properties.
Answer Update
Marek here is my test code (fragment). I'm able to successfully connect (I'm using WAS v8.5.5). Look at log below.
Do you have any additional jars in your application? Please remove any third party jars like mail.jar, activation.jar etc...
public class IMapTest extends HttpServlet {
private static final long serialVersionUID = 1L;
#Resource(name="mail", lookup="mail/test")
Session mailSession;
/**
* #see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
System.out.println("Accessing session");
try {
Store store = mailSession.getStore();
System.out.println("gotStore");
store.connect("user", "pass");
System.out.println("connected!");
} catch (NoSuchProviderException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (MessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Log (fragmet):
[6/25/14 22:25:26:615 CEST] 0000007e SystemOut O DEBUG: JavaMail version 1.4.2
[6/25/14 22:25:26:615 CEST] 0000007e SystemOut O DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
[6/25/14 22:25:26:615 CEST] 0000007e SystemOut O DEBUG: Tables of loaded providers
...
[6/25/14 22:25:26:615 CEST] 0000007e SystemOut O DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
[6/25/14 22:25:26:615 CEST] 0000007e SystemOut O *** In SessionFactory.getObjectInstance, session properties:
[6/25/14 22:25:26:615 CEST] 0000007e SystemOut O mail.store.protocol=imaps
[6/25/14 22:25:26:615 CEST] 0000007e SystemOut O mail.imaps.class=com.sun.mail.imap.IMAPSSLStore
[6/25/14 22:25:26:615 CEST] 0000007e SystemOut O mail.debug=true
[6/25/14 22:25:26:615 CEST] 0000007e SystemOut O mail.pop3s.class=com.sun.mail.pop3.POP3SSLStore
[6/25/14 22:25:26:615 CEST] 0000007e SystemOut O mail.smtp.class=com.sun.mail.smtp.SMTPTransport
[6/25/14 22:25:26:615 CEST] 0000007e SystemOut O mail.imaps.host=imap.gmail.com
[6/25/14 22:25:26:615 CEST] 0000007e SystemOut O mail.smtps.class=com.sun.mail.smtp.SMTPSSLTransport
[6/25/14 22:25:26:615 CEST] 0000007e SystemOut O mail.imap.class=com.sun.mail.imap.IMAPStore
[6/25/14 22:25:26:615 CEST] 0000007e SystemOut O mail.mime.address.strict=true
[6/25/14 22:25:26:615 CEST] 0000007e SystemOut O mail.pop3.class=com.sun.mail.pop3.POP3Store
[6/25/14 22:25:26:630 CEST] 0000007e ServletWrappe I com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I: [servlet.IMapTest]: Initialization successful.
[6/25/14 22:25:26:630 CEST] 0000007e SystemOut O Accessing session
[6/25/14 22:25:26:630 CEST] 0000007e SystemOut O DEBUG: mail.imaps.class property exists and points to com.sun.mail.imap.IMAPSSLStore
[6/25/14 22:25:26:646 CEST] 0000007e SystemOut O DEBUG: mail.imap.fetchsize: 16384
[6/25/14 22:25:26:646 CEST] 0000007e SystemOut O DEBUG: mail.imap.statuscachetimeout: 1000
[6/25/14 22:25:26:646 CEST] 0000007e SystemOut O DEBUG: mail.imap.appendbuffersize: -1
[6/25/14 22:25:26:646 CEST] 0000007e SystemOut O DEBUG: mail.imap.minidletime: 10
[6/25/14 22:25:26:646 CEST] 0000007e SystemOut O gotStore
[6/25/14 22:25:26:646 CEST] 0000007e SystemOut O **DEBUG: trying to connect to host "imap.gmail.com", port 993, isSSL true**
[6/25/14 22:25:27:380 CEST] 0000007e SystemOut O * OK Gimap ready for requests from
...
[6/25/14 22:25:27:474 CEST] 0000007e SystemOut O DEBUG: protocolConnect login, host=imap.gmail.com, user=uuuu, password=pass
[6/25/14 22:25:28:599 CEST] 0000007e SystemOut O connected!
The javax.net.ssl.* properties need to be set as System properties, not JavaMail Session properties. Although I would hope that if they weren't set at all some reasonable defaults would be used.

Resources