Thursday, October 4, 2012

EJB Invokation exception : org.omg.CORBA.NO_PERMISSION Exception

While invoking EJB from target system from Source System.

Whenever we are hitting ejb service from portal which is deployed on different WAS , and if we face the below stack trace:---


Exception = org.omg.CORBA.NO_PERMISSION Source = com.ibm.ws.naming.jndicos.CNContextImpl.doLookup probeid = 1489 Stack Dump = org.omg.CORBA.NO_PERMISSION: >> SERVER (id=64e777ef, host=SVHJ0898.ideaconnect.com) TRACE START: >> org.omg.CORBA.NO_PERMISSION: Subject is null. Authentication Failed. vmcid: 0x49424000 minor code: 300 completed: No >> at com.ibm.ISecurityLocalObjectBaseL13Impl.PrincipalAuthFailReason.map_auth_fail_to_minor_code(PrincipalAuthFailReason.java:88) >> at com.ibm.ISecurityLocalObjectBaseL13Impl.CSIServerRIBase.authenticateSecurityTokens(CSIServerRIBase.java:2815) >> at com.ibm.ISecurityLocalObjectBaseL13Impl.CSIServerRI.receive_request(CSIServerRI.java:622) >> at com.ibm.rmi.pi.InterceptorManager.invokeInterceptor(InterceptorManager.java:631) >> at com.ibm.rmi.pi.InterceptorManager.iterateServerInterceptors(InterceptorManager.java:535) >> at com.ibm.rmi.pi.InterceptorManager.iterateReceiveRequest(InterceptorManager.java:777) >> at com.ibm.CORBA.iiop.ServerDelegate.dispatchInvokeHandler(ServerDelegate.java:616) >> at com.ibm.CORBA.iiop.ServerDelegate.dispatch(ServerDelegate.java:480) >> at com.ibm.rmi.iiop.ORB.process(ORB.java:512) >> at com.ibm.CORBA.iiop.ORB.process(ORB.java:1571) >> at com.ibm.rmi.iiop.Connection.respondTo(Connection.java:2680) >> at com.ibm.rmi.iiop.Connection.doWork(Connection.java:2543) >> at com.ibm.rmi.iiop.WorkUnitImpl.doWork(WorkUnitImpl.java:62) >> at com.ibm.ejs.oa.pool.PooledThread.run(ThreadPool.java:118) >> at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1560) >> SERVER (id=64e777ef, host=SVHJ0898.ideaconnect.com) TRACE END. vmcid: 0x49424000 minor code: 300 completed: No at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:67)


1.Go To Security of the WAS.
2.Then go to global security on clicking Secure administration, applications, and infrastructure.
3. Go To Authentication mechanisms and expiration 
4. Put given value : password ( WAS login password) and path


 

 5. Copy keys.key to source system
6.  Import that key in Portal WAS 6
7.  Restart Server.

Thursday, June 7, 2012

Login , Logout and Session Time Out Filter in WebSphere Portal

Here useful filter used when user log in, log out and session time in WebSphere portal Example package com.filter; import com.ibm.websphere.security.WSSecurityException; import com.ibm.portal.auth.ExplicitLoginFilter; import com.ibm.portal.auth.ExplicitLoginFilterChain; import com.ibm.portal.auth.FilterChainContext; import com.ibm.portal.auth.exceptions.*; import com.ibm.portal.security.SecurityFilterConfig; import com.ibm.portal.security.exceptions.SecurityFilterInitException; import javax.security.auth.Subject; import javax.security.auth.login.LoginException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class SampleLoginFilter implements ExplicitLoginFilter { public void login(HttpServletRequest req, HttpServletResponse arg1, String arg2, char[] arg3, FilterChainContext arg4, Subject arg5, String arg6, ExplicitLoginFilterChain chain) throws LoginException, WSSecurityException, PasswordInvalidException, UserIDInvalidException, AuthenticationFailedException, AuthenticationException, SystemLoginException, com.ibm.portal.auth.exceptions.LoginException { // TODO Auto-generated method stub System.out.println("SampleLoginFilter login successfull from filter 1"); chain.login(req, arg1, arg2, arg3, arg4, arg5, arg6); System.out.println("SampleLoginFilter login successfull from filter 2"); System.out.println("SampleLoginFilter login"+req.getRemoteHost()); System.out.println("SampleLoginFilter login"+req.getLocalAddr()); } public void destroy() { // TODO Auto-generated method stub } public void init(SecurityFilterConfig arg0) throws SecurityFilterInitException { // TODO Auto-generated method stub System.out.println("SampleLoginFilter init"); } } ------------------------------------------------------------------------ package com.filter; import javax.security.auth.login.LoginException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.ibm.portal.auth.ExplicitLogoutFilter; import com.ibm.portal.auth.FilterChainContext; import com.ibm.portal.auth.LogoutFilterChain; import com.ibm.portal.auth.exceptions.LogoutException; import com.ibm.portal.security.SecurityFilterConfig; import com.ibm.portal.security.exceptions.SecurityFilterInitException; public class SampleLogoutFilter implements ExplicitLogoutFilter { public void logout(HttpServletRequest arg0, HttpServletResponse arg1, FilterChainContext arg2, LogoutFilterChain chain) throws LogoutException, LoginException { // TODO Auto-generated method stub System.out.println("SampleLogoutFilter logout successfull from filter 1"); chain.logout(arg0, arg1, arg2); System.out.println("SampleLogoutFilter logout successfull from filter 2"); } public void destroy() { // TODO Auto-generated method stub } public void init(SecurityFilterConfig arg0) throws SecurityFilterInitException { // TODO Auto-generated method stub } } ---------------------------------------------------------------------------------------------- package com.filter; import java.util.Map; import javax.servlet.http.HttpSession; import com.ibm.portal.auth.SessionTimeoutFilter; import com.ibm.portal.auth.SessionTimeoutFilterChain; import com.ibm.portal.auth.exceptions.UserSessionTimeoutException; import com.ibm.portal.security.SecurityFilterConfig; import com.ibm.portal.security.exceptions.SecurityFilterInitException; public class SampleSessionTimeoutFilter implements SessionTimeoutFilter { public void onUserSessionTimeout(HttpSession arg0, Map arg1, SessionTimeoutFilterChain chain) throws UserSessionTimeoutException { // TODO Auto-generated method stub System.out.println("SampleSessionTimeoutFilter timeout successfull from filter 1"); chain.onUserSessionTimeout(arg0, arg1); System.out.println("SampleSessionTimeoutFilter timeout successfull from filter 1"); } public void destroy() { // TODO Auto-generated method stub } public void init(SecurityFilterConfig arg0) throws SecurityFilterInitException { // TODO Auto-generated method stub } } ----------------------------------------------------------- Add above filter in WP AuthenticationService under Resources > Resource Environment > Resource Environment Providers > Custom properties Value as below name : login.explicit.filterchain Value : com.filter.SampleLoginFilter name :logout.explicit.filterchain Value :com.filter.SampleLogoutFilter name :sessiontimeout.filterchain Value : com.filter.SampleSessionTimeoutFilter

Monday, May 7, 2012

Key OR Certificate miagration on WebSphere application server

Introduction Generally Service application and Web application deployed in different WAS machine. And required to communicate web to service application either by EJB ( Remote or Web service ). Communication over EJB required certification or key ma management at both source and target application. Example . 1) Service application machine ( 127.0.0.1 ) 2) Web application machine ( 127.0.0.2 ) Now Import key from service machine to Web machine Goto
Click on Retrieve from port
Click Retrieve signer information. Do the same process for NodeDefaultTrustStore NodeLTPAKeys
Click apply, makes sure synchronize all nodes Restart server.

Tuesday, April 17, 2012

WAS 6.1 Scheduler Configuration using Stateless Session Beans

Introduction
The Scheduler service in WebSphere® Business Integration Server Foundation Version 5.1 (formerly WebSphere Application Server Enterprise) is a full-featured timer service that enables high performance, high availability, persistence and transactional scheduling of J2EE operations.
The Scheduler is comprised of two components:
• Scheduler resource
• Scheduler API.
The Scheduler resource represents a Scheduler instance that is available in the WebSphere Application Server Java™ Naming and Directory Interface (JNDI). Each Scheduler resource has unique properties that govern its behavior; for example, in which database to store the persistent schedules. The Scheduler resource is configured using the standard WebSphere Application Server administrative console (admin console) or the AdminControl scripting object.
The Scheduler API is a Java interface that enables creating and administering tasks. The API is accessible from any J2EE server application (Enterprise Java Beans and servlets).
The Scheduler enables the execution of two types of tasks:
• Calling stateless session Enterprise Java Beans (EJBs). (This approach is shown here).
• Sending Java Message Service (JMS) Messages.
The Scheduler stores its data in any database that WebSphere Application Server supports and uses the WebSphere Application Server Transaction Manager. All Scheduler operations are therefore transactional and persistent; each task is guaranteed to run successfully one time. If a task fails for any reason, the entire operation is rolled back.
The Scheduler enables application developers to create their own stateless session EJBs to receive event notifications during a task's life cycle, allowing the plugging-in of custom logging utilities or workflow applications. Stateless session EJBs are also used to provide generic calendaring. Developers can either use the supplied calendar bean or create their own for their existing business calendars.

Configuring schedulers using the administrative console
Schedulers can be created or configured using the administrative console.
Procedure
1. Start the administrative console.
2. Select Resources > Schedulers.
3. Click New.
4. Specify configuration settings.
5. Click OK or Apply to save the changes.
6. Save the changes to the configuration repository.
Here is an example .
1. Scheduler Name : MySchedular
2. JNDI Name : sched/MyScheduler
3. Data Source JNDI Name : DataSource should be created using jdbc->Data Source and list box will list that data source.
4. Data Source Alias: Alias should be create using Secure administration, applications, and infrastructure > JAAS - J2C authentication data >
Step Wise Images of from Admin console to create Scheduler,J2C Authentication Alias and Data Source.
StepWise Example with Images




JAAS - J2C authentication data

Data Source Creation Part One

DataSource Creation Part two





Creating Tables For Scheduler
1. Verify that the database to be used for this scheduler is available and accessible by the application server. Review the Creating scheduler databases and tables topic for instructions on creating a database. The remaining steps describe how to create scheduler tables in an existing database. We will be using DB2 Database here.
2. Start the administrative console.
3. Create a JDBC data source that refers to the scheduler database.
4. Test the data source connection.
5. Create a scheduler. This configuration object contains the desired table prefix and the JNDI name of the JDBC data source. Verify that you save the new Scheduler to the configuration repository before you proceed to the next step.
6. Click Resources > Schedulers to view all defined schedulers.
7. Select one or more schedulers.
8. Click Create Tables to create the tables for the selected schedulers in their associated database. The tables and indices you created reflect the table prefixes and data sources specified in each scheduler configuration.
9. Restart the server or start the poll daemon to run scheduler tasks.



Accessing schedulers
Each configured scheduler is available using the Scheduler API from a J2EE server application, such as a servlet or EJB module. Use a JNDI name or resource reference to access schedulers. Each scheduler is also available using the JMX API, using its associated WASScheduler MBean. However we will use the first one here.
StartUpBeans
We have used A startUpBeans here to fire the Scheduler. An application startup bean is a session bean that is loaded when an application starts. Application startup beans enable Java 2 Platform Enterprise Edition (J2EE) applications to run business logic automatically, whenever an application starts or stops normally.
A. Startup beans are especially useful when used with asynchronous bean features. For example, a startup bean might create an alarm object that uses the Java Message Service (JMS) to periodically publish heartbeat messages on a well-known topic. This enables clients or other server applications to determine whether the application is available.
B. For Application startup beans, use the home interface, com.ibm.websphere.startupservice.AppStartUpHome, to designate a bean as an Application startup bean and use the remote interface, com.ibm.websphere.startupservice.AppStartUp, to define start() and stop() methods on the bean.



C. The startup bean start() method is called when the module or application starts and contains business logic to be run at module or application start time.
D. The start() method returns a boolean value. True indicates that the business logic within the start() method ran successfully. Conversely, False indicates that the business logic within the start() method failed to run completely. A return value of False also indicates to the Application server that application startup is aborted.
E. The startup bean stop() methods are called when the module or application stops and contains business logic to be run at module or application stop time. Any exception thrown by a stop() method is logged only. No other action is taken.
F. The start() and stop() methods must never use the TX_MANDATORY transaction attribute. A global transaction does not exist on the thread when the start() or stop() methods are invoked. Any other TX_* attribute can be used. If TX_MANDATORY is used, an exception is logged, and the application start is aborted.
G. The start() and stop() methods on the remote interface use Run-As mode. Run-As mode specifies the credential information to be used by the security service to determine the permissions that a principal has on various resources. If security is on, the Run-As mode needs to be defined on all of the methods called. The identity of the bean without this setting is undefined.
H. There are no restrictions on what code the start() and stop() methods can run, since the full Application Server programming model is available to these methods.
An Example of Start method in StartUp Bean.






Developing a TaskHandler Session Bean
This topic describes how to create a task to call a method on a TaskHandler session bean. We will use EJB Session Beans to fire the Job.
Procedure
1. Create a new enterprise application with an EJB module. This application hosts the TaskHandler EJB module.
2. Create a stateless session bean in the EJB Module that implements the process() method in the com.ibm.websphere.scheduler.TaskHandler remote interface. Place the business logic you want created in the process() method. The process() method is called when the task runs. The process method should contain the actual business method that should be fired by the Scheduler. The Home and Remote interfaces must be set as follows in the deployment descriptor bean:
o com.ibm.websphere.scheduler.TaskHandlerHome
o com.ibm.websphere.scheduler.TaskHandler




3. Create an instance of the BeanTaskInfo interface by using the following example factory method. Using a JavaServer Pages (JSP) file, servlet or EJB component, create the instance as shown in the following code example (Example is above used and Stateless EJB to call TaskHandler). This code should coexist in the same application as the previously created TaskHandler EJB module:
4. // Assume that a scheduler has already been looked-up in JNDI.
5. BeanTaskInfo taskInfo = (BeanTaskInfo) scheduler.createTaskInfo(BeanTaskInfo.class).


Startup beans service settings
Use this page to enable startup beans that control whether application-defined startup beans function on this server. Startup beans are session beans that run business logic through the invocation of start and stop methods when applications start and stop. If the startup beans service is disabled, then the automatic invocation of the start and stop methods does not occur for deployed startup beans when the parent application starts or stops. This service is disabled by default. Enable this service only when you want to use startup beans. Startup beans are especially useful when used with asynchronous beans.
To view this administrative console page, click Servers > Application servers >server_name > Container services > Startup beans service.


Summary
In this way we can schedule a task or any business logic inside Websphere Application Server. The moment Server is up and Application starts up Start Up Beans will start firing the Scheduler using TaskHandler process method.
For API/Resources about
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/com.ibm.websphere.javadoc.doc/public_html/api/com/ibm/websphere/scheduler/TaskHandler.html

Tuesday, March 20, 2012

Custom variable in WAS, Help in to different env properties

1) Create custom properties in WAS where application deployed.



2) Access custom properties in Java code

System.getProperty("Custom property name");

Actually in J2EE application,in each env access point & log file location is different and maintain in code is very difficult. Best option to have some properties in each env and access in code.

Wednesday, March 14, 2012

CSV DATA LAOD IN ORACLE

Create control file.
--------------------------------------------------------

1) Create table : CHARGE_DEPOSIT_CONFIG_UPE

with following fields

CREATE TABLE CHARGE_DEPOSIT_CONFIG_UPE
(
PART_NUMBER VARCHAR2(100 BYTE),
PARENT_PART_NO VARCHAR2(100 BYTE),
CIRCLE VARCHAR2(100 BYTE),
BILL_PLAN_REF_NUMBER VARCHAR2(100 BYTE),
PRODUCT_NAME VARCHAR2(100 BYTE),
PRODUCT_TYPE VARCHAR2(100 BYTE),
PARENT_PRODUCT_REF_NUMBER VARCHAR2(100 BYTE)
)



For example LoadData.ctl
----------------------------------------------------
options (skip=1)
LOAD DATA
INFILE 'C:\Project\General\Plans\LoadData.csv'
INSERT
INTO TABLE CHARGE_DEPOSIT_CONFIG_UPE
FIELDS TERMINATED BY ','
optionally enclosed by "'"
TRAILING NULLCOLS
(PART_NUMBER,
PARENT_PART_NO,
CIRCLE,
BILL_PLAN_REF_NUMBER,
PRODUCT_NAME,
PRODUCT_TYPE,
PARENT_PRODUCT_REF_NUMBER
)
-----------------------------------------------------

Import data




Choose existing one
select control file
and Click on Finish button

Friday, February 10, 2012

Automatic login with the login URL

http://server:port/wps/portal/cxml/04_SD9ePMtCP1I800I_KydQvyHFUBADPmuQy?userid=userid&password=password

for example

http://localhost:10040/wps/portal/cxml/04_SD9ePMtCP1I800I_KydQvyHFUBADPmuQy?userid=wpsadmin&password=wpsadmin

Show pages only to wpsadmin : WebSphere portal v 6.1

Show pages only to Portal administrator (wpsadmin) ,

Simple steps

1) Create the pages, add some porlets in case required.
2) Remove access right under Allow Inheritance column.

And done.

Thursday, February 9, 2012

Custom Login Portlet : WPS v6.1.5

IBM WebSPhere Portal Server provides a Login Service that you can use to create a custom login portlet. You may want to create a custom login portlet to IBM WebSphere Portal if the base portlet is not in the format you want, or if you want to add additional checking to the login.


CustomLoginPortlet.java
-----------------------------------------------------------------------------


package com.webspherenotes.services;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.GenericPortlet;
import javax.portlet.PortletException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.security.auth.login.LoginException;

import com.ibm.portal.auth.exceptions.AuthenticationException;
import com.ibm.portal.auth.exceptions.AuthenticationFailedException;
import com.ibm.portal.auth.exceptions.PasswordInvalidException;
import com.ibm.portal.auth.exceptions.PortletLoginDisabledException;
import com.ibm.portal.auth.exceptions.SessionTimeOutException;
import com.ibm.portal.auth.exceptions.SystemLoginException;
import com.ibm.portal.auth.exceptions.UserAlreadyLoggedInException;
import com.ibm.portal.auth.exceptions.UserIDInvalidException;
import com.ibm.portal.portlet.service.PortletServiceHome;
import com.ibm.portal.portlet.service.login.LoginHome;
import com.ibm.portal.portlet.service.login.LoginService;
import com.ibm.websphere.security.WSSecurityException;

public class CustomLoginPortlet extends GenericPortlet{
protected void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
System.out.println("Entering CustomLoginPortlet.doView()");
response.setContentType("text/html");
getPortletContext().getRequestDispatcher("/login.jsp").include(request, response);
System.out.println("Exiting CustomLoginPortlet.doView()");
}

LoginHome loginHome;
public void init() throws PortletException {
System.out.println("Entering CustomLoginPortlet.init()");
try {
InitialContext ctx = new InitialContext();
PortletServiceHome psh = (PortletServiceHome) ctx.lookup(LoginHome.JNDI_NAME);
loginHome = (LoginHome) psh.getPortletService(LoginHome.class);
//loginHome =(LoginHome) ctx.lookup(LoginHome.JNDI_NAME);
} catch (NamingException e) {
e.printStackTrace();
}
System.out.println("Exiting CustomLoginPortlet.init()");
}

public void processAction(ActionRequest request, ActionResponse response)
throws PortletException, IOException {
try {
System.out.println("Entering CustomLoginPortlet.processAction()");
String userId = request.getParameter("USER_NAME");
System.out.println("User Id " + userId);
String password = request.getParameter("PASSWORD");
System.out.println("Password " + password);
LoginService loginService = loginHome.getLoginService(request, response);
System.out.println("Login Service " + loginService);
Map contextMap = new HashMap();
contextMap.put(LoginService.DO_RESUME_SESSION_KEY, new Boolean(false));
loginService.login(userId, password.toCharArray(), contextMap, null);
System.out.println("Exiting CustomLoginPortlet.processAction()");
response.sendRedirect("/wpcert/mydemo");
} catch (PasswordInvalidException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UserIDInvalidException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (AuthenticationFailedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (AuthenticationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SessionTimeOutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (PortletLoginDisabledException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UserAlreadyLoggedInException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SystemLoginException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (LoginException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (WSSecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (com.ibm.portal.auth.exceptions.LoginException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
--------------------------------------------------------------------------
You can refer : http://wpcertification.blogspot.in/2010/06/custom-login-portlet.html

Followers