Tuesday, October 16, 2012

How to use Spring inside Struts Actions?

Spring can be integrated into Struts actions to take advantage of seamless bean findings, here is how:
Step 1: 
Create a BaseAction class and extend this class to create struts actions.
 
BaseAction.java (add spring-webmvc-struts.jar to web-inf/lib)
 
import org.springframework.web.struts.DispatchActionSupport;
public class BaseAction extends DispatchActionSupport {
 protected Object getBean(String name) {
  return getWebApplicationContext().getBean(name);
 }
} 
 
Step 2: Action class sample: 
BalanceAction.java 
public class BalanceAction extends BaseAction {
 @Override
 public ActionForward execute(ActionMapping mapping, ActionForm form,
   HttpServletRequest request, HttpServletResponse response)
   throws Exception {
  try {
   BeanService handle = (BeanService)getBean("BeanName");
   handle.businessMethod();
  } catch (Exception ex) {
   System.out.println("Cannot find the bean...");
  }
  return mapping.findForward("success");
 }
}

Maven Build Script setup for various configurations

Steps to include a jar in the EAR package while building:
Scenario 1. If the jar project is part of same EAR project heirarchy and need to build before packaging
Follow the steps given here:
step1: Add plugin maven-ear-plugin
step2: Add <configuration> block, add <modules> as follows:
 <configuration>
  <modules>
   <javaModule>
    <groupId>myProjectGroup</groupId>
    <artifactId>myArtifact</artifactId>
    <bundleFileName>myArtifact-x.0.jar</bundleFileName>
    <bundleDir>[Destination-Path]</bundleDir>
   </javaModule>
  </modules>
 </configuration>
Step3: Add the dependency as follows:
 <dependency>
  <groupId>myProjectGroup</groupId>
  <artifactId>myArtifact</artifactId>
  <version>x.0</version>
  <type>jar</type>
 </dependency>
Note: Don't specify the <bundleDir> if you want the jar file to go to default folder.

Scenario 2. If the jar is external and not part of EAR project heirarchy
Follow the steps given here:
step1: Add plugin maven-ear-plugin
step2: Add <configuration> block, add <modules> as follows:
 <configuration>
  <modules>
   <javaModule>
    <groupId>externalGroup</groupId>
    <artifactId>externalJarArtifact</artifactId>
    <bundleFileName>externalJarArtifact-x.0.jar</bundleFileName>
    <bundleDir>[Destination-Path]</bundleDir>
   </javaModule>
  </modules>
 </configuration>
Step3: Add the dependency as follows:
 <dependency>
  <groupId>externalGroup</groupId>
  <artifactId>externalJarArtifact</artifactId>
  <version>x.0</version>
  <scope>system</scope>
  <systemPath>[external-jar-local-path]/externalJarArtifact-x.0.jar</systemPath>
 </dependency>
Note: Don't specify the <bundleDir> if you want the jar file to go to default folder.

Is it the right time to buy a home or rent ?

To analyze whether you should buy a home now or still rent it depends on so many factors including:
- How long you will live in the home?
- How big you want the home?
- How much you can afford?
- What is the market trend?
- How much rent you are paying?
- Property tax
- Mortgage rate

You can analyze here http://www.ginniemae.gov/

Monday, October 15, 2012

Deployment Error while publishing application in OEPE, WebLogic Portal 10.3.4

[HTTP:101216]Servlet: "wsrp-1.0-ServiceDescriptionPortComponent"
Exception Stack Trace:
weblogic.application.ModuleException: [HTTP:101216]Servlet: "wsrp-1.0-ServiceDescriptionPortComponent" failed to preload on startup in Web application: "portalWeb".java.lang.NullPointerException

at weblogic.wsee.monitoring.WseeBaseRuntimeMBeanImpl.unregisterPorts(WseeBaseRuntimeMBeanImpl.java:285)
at weblogic.wsee.monitoring.WseeBaseRuntimeMBeanImpl.unregister(WseeBaseRuntimeMBeanImpl.java:255)
at weblogic.wsee.monitoring.WseeV2RuntimeMBeanImpl.unregister(WseeV2RuntimeMBeanImpl.java:14)
at weblogic.management.runtime.RuntimeMBeanDelegate.unregisterChildren(RuntimeMBeanDelegate.java:350)
at weblogic.management.runtime.RuntimeMBeanDelegate.unregister(RuntimeMBeanDelegate.java:274)
at weblogic.wsee.ws.WsRegistry$1.run(WsRegistry.java:325)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.wsee.ws.WsRegistry.unregisterMBean(WsRegistry.java:321)
at weblogic.wsee.ws.WsRegistry.unregisterMBean(WsRegistry.java:300)
at weblogic.wsee.deploy.DeployInfo.createWsPort(DeployInfo.java:381)
at weblogic.wsee.server.servlet.BaseWSServlet.init(BaseWSServlet.java:83)
at javax.servlet.GenericServlet.init(GenericServlet.java:241)
at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:283)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:64)
at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58)
at weblogic.servlet.internal.StubLifecycleHelper.(StubLifecycleHelper.java:48)
at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:539)
at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1985)
at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1959)
at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1878)
at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3153)
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1508)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:482)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:247)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)
at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:636)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:205)
at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:58)
at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:569)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:150)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:116)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:323)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:844)
at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1253)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:440)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:163)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:68)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:176)

java.lang.Exception: Exception received from deployment driver. See Error Log view for more detail.
at oracle.eclipse.tools.weblogic.server.internal.DeploymentProgressListener.watch(DeploymentProgressListener.java:190)
at oracle.eclipse.tools.weblogic.server.internal.WlsJ2EEDeploymentHelper.redeploy(WlsJ2EEDeploymentHelper.java:893)
at oracle.eclipse.tools.weblogic.server.internal.WlsJ2EEDeploymentHelper.redeploy(WlsJ2EEDeploymentHelper.java:762)
at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publishWeblogicModules(WeblogicServerBehaviour.java:1430)
at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publishToServer(WeblogicServerBehaviour.java:861)
at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publishOnce(WeblogicServerBehaviour.java:655)
at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publish(WeblogicServerBehaviour.java:522)
at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.publish(ServerBehaviourDelegate.java:775)
at org.eclipse.wst.server.core.internal.Server.publishImpl(Server.java:2889)
at org.eclipse.wst.server.core.internal.Server$PublishJob.run(Server.java:337)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: weblogic.application.ModuleException: [HTTP:101216]Servlet: "wsrp-1.0-ServiceDescriptionPortComponent" failed to preload on startup in Web application: "portalWeb".
java.lang.NullPointerException
at weblogic.wsee.monitoring.WseeBaseRuntimeMBeanImpl.unregisterPorts(WseeBaseRuntimeMBeanImpl.java:285)
at weblogic.wsee.monitoring.WseeBaseRuntimeMBeanImpl.unregister(WseeBaseRuntimeMBeanImpl.java:255)
at weblogic.wsee.monitoring.WseeV2RuntimeMBeanImpl.unregister(WseeV2RuntimeMBeanImpl.java:14)
at weblogic.management.runtime.RuntimeMBeanDelegate.unregisterChildren(RuntimeMBeanDelegate.java:350)
at weblogic.management.runtime.RuntimeMBeanDelegate.unregister(RuntimeMBeanDelegate.java:274)
at weblogic.wsee.ws.WsRegistry$1.run(WsRegistry.java:325)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.wsee.ws.WsRegistry.unregisterMBean(WsRegistry.java:321)
at weblogic.wsee.ws.WsRegistry.unregisterMBean(WsRegistry.java:300)
at weblogic.wsee.deploy.DeployInfo.createWsPort(DeployInfo.java:381)
at weblogic.wsee.server.servlet.BaseWSServlet.init(BaseWSServlet.java:83)
at javax.servlet.GenericServlet.init(GenericServlet.java:241)
at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:283)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:64)
at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58)
at weblogic.servlet.internal.StubLifecycleHelper.(StubLifecycleHelper.java:48)
at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:539)
at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1985)
at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1959)
at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1878)
at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3153)
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1508)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:482)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:247)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)
at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:636)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:205)
at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:58)
at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:569)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:150)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:116)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:323)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:844)
at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1253)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:440)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:163)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:68)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:176)

at weblogic.wsee.monitoring.WseeBaseRuntimeMBeanImpl.unregisterPorts(WseeBaseRuntimeMBeanImpl.java:285)
at weblogic.wsee.monitoring.WseeBaseRuntimeMBeanImpl.unregister(WseeBaseRuntimeMBeanImpl.java:255)
at weblogic.wsee.monitoring.WseeV2RuntimeMBeanImpl.unregister(WseeV2RuntimeMBeanImpl.java:14)
at weblogic.management.runtime.RuntimeMBeanDelegate.unregisterChildren(RuntimeMBeanDelegate.java:350)
at weblogic.management.runtime.RuntimeMBeanDelegate.unregister(RuntimeMBeanDelegate.java:274)
at weblogic.wsee.ws.WsRegistry$1.run(WsRegistry.java:325)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.wsee.ws.WsRegistry.unregisterMBean(WsRegistry.java:321)
at weblogic.wsee.ws.WsRegistry.unregisterMBean(WsRegistry.java:300)
at weblogic.wsee.deploy.DeployInfo.createWsPort(DeployInfo.java:381)
at weblogic.wsee.server.servlet.BaseWSServlet.init(BaseWSServlet.java:83)
at javax.servlet.GenericServlet.init(GenericServlet.java:241)
at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:283)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:64)
at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58)
at weblogic.servlet.internal.StubLifecycleHelper.(StubLifecycleHelper.java:48)
at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:539)
at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1985)
at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1959)
at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1878)
at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3153)
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1508)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:482)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:247)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)
at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:636)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:205)
at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:58)
at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:569)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:150)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:116)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:323)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:844)
at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1253)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:440)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:163)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:68)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:176)
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1510)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:482)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:247)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)
at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:636)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:205)
at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:58)
at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:569)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:150)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:116)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:323)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:844)
at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1253)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:440)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:163)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:68)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:176)
Caused by: java.lang.NullPointerException:
at weblogic.wsee.monitoring.WseeBaseRuntimeMBeanImpl.unregisterPorts(WseeBaseRuntimeMBeanImpl.java:285)
at weblogic.wsee.monitoring.WseeBaseRuntimeMBeanImpl.unregister(WseeBaseRuntimeMBeanImpl.java:255)
at weblogic.wsee.monitoring.WseeV2RuntimeMBeanImpl.unregister(WseeV2RuntimeMBeanImpl.java:14)
at weblogic.management.runtime.RuntimeMBeanDelegate.unregisterChildren(RuntimeMBeanDelegate.java:350)
at weblogic.management.runtime.RuntimeMBeanDelegate.unregister(RuntimeMBeanDelegate.java:274)
at weblogic.wsee.ws.WsRegistry$1.run(WsRegistry.java:325)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.wsee.ws.WsRegistry.unregisterMBean(WsRegistry.java:321)
at weblogic.wsee.ws.WsRegistry.unregisterMBean(WsRegistry.java:300)
at weblogic.wsee.deploy.DeployInfo.createWsPort(DeployInfo.java:381)
at weblogic.wsee.server.servlet.BaseWSServlet.init(BaseWSServlet.java:83)
at javax.servlet.GenericServlet.init(GenericServlet.java:241)
at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:283)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:64)
at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58)
at weblogic.servlet.internal.StubLifecycleHelper.(StubLifecycleHelper.java:48)
at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:539)
at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1985)
at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1959)
at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1878)
at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3153)
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1508)

My Observations:
Most of the time I have run into this exception because I have modified resources (JSP, portlet, portal, java etc.) and compiled and tried to publish the application changes through OEPE.

Solution:
If you application compiles fine and does not throw any build errors, you should be able to do another publish and it should publish like a snap without any error. Try two to three times - you should be good.

If you are still facing this error, try removing the project from the server, build, compile again and add the project to the server - publish again.

Monday, September 24, 2012

Difference between SID and Service for WLST Config


How to define a datasource in Oracle WebLogic WLST Configuration

For a SID:
<attribute name="Url" value="jdbc:oracle:thin:@hostname:1521:SID" />

For a Service:
<attribute name="Url" value="jdbc:oracle:thin:@hostname:1521/Service" />

Monday, September 10, 2012

javax.security.auth.callback.UnsupportedCallbackException: [Security:090175]

Application throwing Unrecognized Callback exception when connecting through t3:
javax.security.auth.callback.UnsupportedCallbackException: [Security:090175]Unrecognized Callback com.abc.def.security.identityassertion.DramaCallback@32a4755]
at weblogic.jndi.internal.ExceptionTranslator.toNamingException(ExceptionTranslator.java:44)
at weblogic.jndi.WLInitialContextFactoryDelegate.toNamingException(WLInitialContextFactoryDelegate.java:788)
at weblogic.jndi.WLInitialContextFactoryDelegate.pushSubject(WLInitialContextFactoryDelegate.java:675)
at weblogic.jndi.WLInitialContextFactoryDelegate.newContext(WLInitialContextFactoryDelegate.java:469)
at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:376)
at weblogic.jndi.Environment.getContext(Environment.java:315)
at weblogic.jndi.Environment.getContext(Environment.java:285)
at weblogic.jndi.Environment.createInitialContext(Environment.java:208)
at weblogic.jndi.Environment.getInitialContext(Environment.java:192)
at weblogic.jndi.Environment.getInitialContext(Environment.java:170)
at weblogic.jndi.Environment.getContext(Environment.java:215)


Normally the application works fine when connected through http protocol.
Following are the suggestions to get rid of this error:
1. Move the default SQL authenticator to the top and make it sufficient
2. Don't throw any exception when UnsupportedCallbackException is caught during callback handler handle call

However you may need to watch out for the pros and cons of these solutions provided here.

Default Roles not listed when using RolePolicyManager api


When using RolePolicyManager api, default roles are not listed
If no roles are created by default following two roles are provided for each portal web application:
- AnonymousVisitor
- AuthenticatedVisitor
These can be verified using portal admin console, however these never appear when using the following api:
RolePolicyManager.listRolesForResource(EARName, WEBName, EntitlementConstants.P13N_ROLE_POLICY_POOL);
To make these default roles visible, create a custom role in the web application and same api will list all the three roles:
- AnonymousVisitor
- AuthenticatedVisitor
- Custom role

Find out if database sessions are locked


To Check if there is any database session locked

SELECT s1.username || '@' || s1.machine
    || ' ( SID=' || s1.sid || ' )  is blocking '
    || s2.username || '@' || s2.machine || ' ( SID=' || s2.sid || ' ) ' AS blocking_status
    FROM v$lock l1, v$session s1, v$lock l2, v$session s2
    WHERE s1.sid=l1.sid AND s2.sid=l2.sid
    AND l1.BLOCK=1 AND l2.request > 0
    AND l1.id1 = l2.id1
    AND l2.id2 = l2.id2 ;

select * from v$lock
select * from v$session

Display the session count, max sessions, highwater etc.
select sessions_max, sessions_current, sessions_highwater from v$license;

Oracle sample queries


Sample Oracle queries run on 11g (and 10g comparisons)

Query to display stored procedures:
select OBJECT_NAME from user_procedures
select OBJECT_NAME from user_objects where object_type = 'PROCEDURE'
both returns list of stored procedures
"select OBJECT_NAME from user_procedures" returns the stored procedures and triggers as well for Oracle 11g while
"select OBJECT_NAME from user_objects where object_type = 'PROCEDURE'" returns list of stored procedures only

select * from user_sequences
select * from user_objects where object_type = 'SEQUENCE'

select * from user_tables
select * from user_objects where object_type = 'TABLE'

select * from user_triggers
select * from user_objects where object_type = 'TRIGGER'

select * from user_indexes in 10g returns the LOB as well
select * from user_objects where object_type = 'INDEX'

Display all the roles, previleges, tables
select * from user_tab_privs order by grantee, table_name

Display all the synonyms for the table owner
SELECT * FROM all_synonyms where table_owner = 'XYZ' order by owner, synonym_name;

Select from a table and concat two or more columns
SELECT column1_name || ' # ' || column2_name  as column_both FROM table_name

Grant Privileges on tables/sequences to a role
grant select/insert/update/delete on [Schema].[Table/Sequence] to [Role_Name];

Create public synonyms for table, views, sequences

Create public synonyms for table, views, sequences for the schema XYZSchema


declare
  CURSOR xcur is
    select object_name, object_type from all_objects
where object_type IN ('TABLE', 'VIEW', 'SEQUENCE')
and owner = 'XYZSchema'
     ;

    xdat xcur%ROWTYPE;

begin
  for xdat in xcur loop
    begin
      execute immediate 'create or replace public synonym '|| xdat.object_name || ' for XYZSchema.'||xdat.object_name;
    exception when others
     then null;
    end;
   end loop;
 end;
/

Thursday, August 16, 2012

Creating 10.3.4 WebLogic Portal domain with different port - simpler way

Follow the steps below while running Domain Configuration Wizard:
Step 1:
Open domain configuration wizard and select "WebLogic Portal - 10.3.4.0", click Next
Enter the domain name and choose domain location, click Next
Enter user name, password etc., click Next
Select the JDK, click Next

Step 2:
By now you should be in "Configure JDBC Data Sources" section of the wizard.
Select all the datasources and change the "Port" number as you wish i.e. 1557, click Next
All the tests will fail, thats ok, click Next, click OK, click Next

Step 3:
By now you should be in "Select Optional Configuration" section of the wizard.
Select "Administration Server" and click Next.
Change the port number as you wish and click Next, click Create and click Done.

Step 4:
Open database.properties file and replace these two lines:
derby.driver=org.apache.derby.jdbc.EmbeddedDriver
derby.url=jdbc:derby:weblogic_eval;create=true
with
derby.driver=org.apache.derby.jdbc.ClientDriver
derby.url=jdbc:derby://localhost:1557/weblogic_eval;create=true
save and close the file.

Step 5:
Open config.xml and change the port number as changed, save and close the file.
Open p13nProfileDataSource-jdbc.xml and change the port number as changed, save and close the file.

Step 6:
Open startWebLogic.cmd and replace the word 
- stopNetworkServer.cmd with stopNetworkServer_vkb.cmd
- startNetworkServer.cmd with startNetworkServer_vkb.cmd
save and close the file.

Open stopWebLogic.cmd and replace the word 
- stopNetworkServer.cmd with stopNetworkServer_vkb.cmd
save and close the file.

Step 7:

Go to wlserver_10.3\common\derby\bin folder
Copy following files:
- startNetworkServer.bat
- startNetworkServer.cmd
- stopNetworkServer.bat
- stopNetworkServer.cmd
and paste and rename as followings:
- startNetworkServer_vkb.bat
- startNetworkServer_vkb.cmd
- stopNetworkServer_vkb.bat
- stopNetworkServer_vkb.cmd

Step 8:
Open startNetworkServer_vkb.bat and replace the port number to 1557,  save and close the file.
Open stopNetworkServer_vkb.bat and replace the port number to 1557,  save and close the file.
Open startNetworkServer_vkb.cmd and replace the word startNetworkServer.bat with startNetworkServer_vkb.bat,  save and close the file.
Open stopNetworkServer_vkb.cmd and replace the word stopNetworkServer_vkb.bat with stopNetworkServer_vkb.bat, save and close the file.

Step 9:
Go to domain folder and run the script crate_db.cmd,  it should create the portal database to the new port.
You are good to go now!

Thursday, June 28, 2012

Default Transaction Attribute for EJBs

Default transaction attributes differ from container to container.
In Weblogic Server, default transaction attribute for MDB is NotSupported however for all other EJBs is Supports for version 10.0 onwards - if no attribute value is specified for trans-attribute in the ejb deployment descriptor.

Container-Managed Transaction Elements in ejb-jar.xml (WebLogic Server 10.x)

Element: transaction-type
Description: Allowable values are Bean or Container.
Default: None, EJB 2.x requires this attribute to be specified.


Element: trans-attribute
Description: 
Specifies how the container manages the transaction boundaries when delegating a method invocation to an enterprise bean's business method. Allowable values are:
  • NotSupported
  • With the NotSupported value, when an entity bean runs in an unspecified transaction, if a transaction exists, the EJB container suspends the transaction; when an entity bean runs in an unspecified transaction, and no transaction exists, the EJB container takes no action.
  • Supports
  • With the Supports value, when an entity bean runs in an unspecified transaction, if a transaction exists, the EJB container uses the current transaction; when an entity bean runs in an unspecified transaction, and no transaction exists, the EJB container takes no action.
  • Required
  • RequiresNew
  • Mandatory
  • Never
  • With the Never value, when an entity bean runs in an unspecified transaction, if a transaction exists, the EJB container throws an exception; when an entity bean runs in an unspecified transaction, and no transaction exists, the EJB container takes no action.
Note: In in pre-9.0 releases of WebLogic Server, the EJB container would start a new transaction when no transaction existed and the value of trans-attribute was NotSupportedSupports, and Never. Set entity-always-uses-transaction inweblogic-ejb-jar.xml to True if you want the EJB container to behave as it did in pre-9.0 releasesof WebLogic Server and create a new transaction.

Because clients do not provide a transaction context for calls to an MDB, MDBs that use container-managed transactions must have trans-attribute of Required.


Default: If not specified, the EJB container issues a warning, and usesNotSupported for MDBs and Supportsfor other types of EJBs.

Element: transaction-scope
Description: 
This optional element specifies whether an enterprise bean requires distributed transactions for its methods or whether the local transaction optimization may be used.
Allowable values are Local and Distributed.

Default: If not specified, the container assumes that distributed transactions must be used.


Reference: http://docs.oracle.com/cd/E11035_01/wls100/ejb/implementing.html#wp1150418

Tuesday, April 24, 2012

Return List of Dynamic object types from Method

Sometimes we want to convert the list of objects into a desired data type list. Here is one simple example which returns a list of objects into list of Strings, assuming that all the objects will be of type String.


// method with generic return type
public <T> List<T> getMyList(Class<T> elementType, List objList)
{
    List<T> list = new ArrayList<T>();
    
    for(Object obj : objList)
    list.add(elementType.cast(obj));
    
    return list;
}

// calling the method
getMyList(String.class, objList);

Monday, April 9, 2012

Creating 10.3.4 WebLogic Portal domain with different port number


Follow the steps below after Domain Configuration Wizard is completed:

1. add the following two lines in setDomainEnv.cmd with appropriate port number.
@REM Following line customized to change the port for derby
set DERBY_CMD_LINE_ARGS=-p=1529

2. Start the derby database with different port number as follows:
C:\portal-10.3.4\wlserver_10.3\common\bin\startDerby.cmd -p=1529

3. Modify database.properites with new port as follows:
derby.url=jdbc:derby://localhost:1529/weblogic_eval;create=true
derby.driver=org.apache.derby.jdbc.ClientDriver

4. Run the db script C:\portal-10.3.4\user_projects\domains\ngx_domain01\create_db.cmd

5. Modify startWeblogic.cmd as follows:
@REM Start Derby

set DERBY_DEBUG_LEVEL=0
echo #############################################################
echo DERBY_CMD_LINE_ARGS=%DERBY_CMD_LINE_ARGS%
echo #############################################################
if "%DERBY_FLAG%"=="true" (
call "%WL_HOME%\common\derby\bin\startNetworkServer.cmd" %DERBY_CMD_LINE_ARGS% >"%DOMAIN_HOME%\derby.log" 2>&1

)

6. Modify stopWeblogic.cmd as follows:
echo #############################################################
echo DERBY_CMD_LINE_ARGS=%DERBY_CMD_LINE_ARGS%
echo #############################################################
if "%DERBY_FLAG%"=="true" (
call "%WL_HOME%\common\derby\bin\stopNetworkServer.cmd" %DERBY_CMD_LINE_ARGS% >"%DOMAIN_HOME%\derbyShutdown.log" 2>&1
echo Derby server stopped.
)

7. Change the following line in config.xml for the appropriate port
jdbc:derby://localhost:1529/weblogic_eval

This is optional:
8. Change the port number in jdbc/p13nProfileDataSource-jdbc.xml folder

WebLogic Portal 10.3.4 vs WebLogic Portal 10.3.2

Few differences between WLP 10.3.4 & WLP 10.3.2:
1. First and foremost, its seems its a minor change in the version but its not. You need to install the entire WebLogic Portal 10.3.4 version and create new portal domains in 10.3.4 version to deploy your upgraded portal applications.

2. 10.3.4 uses Apache Derby database as default while 10.3.2 uses pointbase as default

3. Domain configuration wizard in 10.3.4 version is not a 100% wizard, meaning you need to start the derby database manually before checking the box "Run Scripts" while going through wizard - and Oracle is still calling this a wizard.

4. Creating two or more portal domains in WLP 10.3.4 cannot be simply achieved by changing the port numbers for Derby database, as changing port number for db configuration in wizard will not change the server start/stop scripts to listed to different port for Derby database - lot of changes are needed.
Note: Watch for upcoming postings for creating more than one portal domains.

5. Spring 3.0 version is recommended how ever applications can still use 2.5.x versions.

6. A new datasource p13nProfileDataSource-jdbc.xml is created as part of domain creation, which is not at all used - as per Oracle.

7. Eclipse has a new version 3.6.1

8. So many new types of project can be created using Eclipse "New" wizard.

9. Few ui issues are fixed in WebLogic Server Console e.g. "Ordering Authentication Providers"
and more to discover...

Good to know about these when using TFS


These points are helpful when using Microsoft TFS as enterprise repository:

1. We need to specify different labels for different projects i.e. more than one projects cannot be labelled with same label.
(TFS Eclipse client in windows doesn't throw any error while labelling different projects with same label and it works in windows however while trying to get labelled code in Linux,  it does not work)

2. Checking in code - While updating any code in TFS, make sure that the code with right label has been checked out. And after checking in, make sure the new code is labelled with the right label.

3. Deleting files from TFS - Even if the files can be deleted from TFS, they stay no matter what.
If a file XYZ is labelled and need to be deleted then label has to be removed from file XYZ and then deleted.
(File XYZ will still be available to labels other than for what it is deleted)

4. Adding and deleting folder structure is not straight forward - so take more time in designing and finalizing the folder structure. Once it is finalized then only add to TFS.

5. Adding multiple files to an existing label is again not straight forward, take more time and it requires more concentration to avoid any mistake by missing a required file to apply label. Its always better to apply label to the parent folder and then remove label from unwanted files.

6. Using "Microsoft Visual Studio 2010" has some advantages and is flexible to work with when comparing with Eclipse plugin for TFS.

Thursday, February 2, 2012

Maven build on winows and unix


Windows paths differ from that of unix, linux, solaris, aix and sometimes it becomes challange to use one pom.xml for building on two different os.
Here is how one maven script can be used for building applications on windows and unix environments:



<profiles>
    <profile>
        <id>windows</id>
        <activation>
        <os>
            <family>windows</family>
        </os>
        </activation>
        <properties>
            <!-- windows based properties here -->
        </properties>
    </profile>
    <profile>
        <id>non-windows</id>
        <activation>
        <os>
            <family>!windows</family>
        </os>
        </activation>
        <properties>
            <!-- unix based properties here -->
        </properties>
    </profile>
</profiles>

Date Time for Maven Builds

Print/View Datetime stamp in Maven
Since Maven 2.1 M1 version, here is how you can get the datetime stamp while using maven build scripts:
Define a property named "maven.build.timestamp.format" with some legitimate value i.e. "yyyyMMdd.HHmm" and property named "maven.build.timestamp" will be available to use.

Example here:



<properties>
<maven.build.timestamp.format>yyyyMMdd.HHmm</maven.build.timestamp.format>
<CurrentDateTime>${maven.build.timestamp}</CurrentDateTime>
</properties>