Modify a bit of Maximo functionality through a Java modification
Problem:
I do not have the tools needed to do this.
Solution:
I need to install the tools needed to modify/create java files.
For this we need to download and then install Eclipse
Download it from: http://www.eclipse.org/downloads/
I used the Eclipse IDE for Java Developers (64 bit)
I follwed these steps:
http://maximodev.blogspot.nl/2010/09/quick-maximo-development-environment.html
I extract the downloaded zip to the E:\
From the E:\eclipse folder I run the 'eclipse.exe'
I get the Java error like stated in the post from Bruno:
I copy the jre folder from the Webshere/Appserver folder to the e:\eclipse folder and run eclipse.exe again
Now it starts.
As workspace i use 'E:\Workspace'
Since I will work with Maximo 7.5 I use the Compiler compliance level 1.6 (Windows -> Preferences)
Now I create a new Java Project
Extract the maximo.ear into the workspace
In the Package explorer after doing a Refresh (F5) the maximo folder shows up.
The I go to Project -> Properties and select the JAva build path.
In the Libraries tab I click [Add JARs]
And add the following jars:
- maximo/lib/*.jar
Filter on *.jar and select all the jar files. (On the picture below, only the bottom of the list is shown)
- maximo/businessobjects.jar
The list looks like this:
Then I create a folder structure in my project by Right Clicking on the src folder and adding folders.
I do this until I got this:
In the custom.app.asset I right click and create a new Class
With the info from the example of Bruno his blog:
I paste in the code from Bruno his blog:
Now the explanation on Bruno his post stops, He writes:
The custom Mbo class gets quickly compiled and is ready to be deployed on your Maximo server.
Eeuhhh ok... But how do I compile, or this done automatically?
And how do I deploy the custom Mbo? What do i need to do in Maximo to let it use the custom Mbo?
Seems like Bruno has some other very nice articles about that:
In his Maximo Java Development series he explaines a lot.
http://maximodev.blogspot.nl/p/java-customization.html
First I use:
http://maximodev.blogspot.nl/2012/05/maximo-extend-java-mbo.html
and find out the compiling is done automatically
Some picture and my 'doings' to go along with it:
First I save the Project, then I look around a bit I see that in the Project menu there is a Check at "Build Automatically" and the build option is grayed out. This must mean that my .java is already build to .class.
Then I look in the properties for the project and go to the Java Build Path option and look on the "Source tab" I see the Default output folder.
In Explorer I check this folder, and there is my class file.
I copy this files (and the folder structure) to:
E:\ibm\SMP\maximo\applications\maximo\businessobjects\classes
I rebuild and redeploy the ear file.
- buildmaximoear.cmd
- uninstall maximo application from websphere
- install maximo application in websphere
http://maximodev.blogspot.nl/2012/08/maximo-rapid-java-class-deploy-websphere.html
After starting, MXServer is started, but the MAXIMO appliciation not.
In the SystemOut.log
[1/19/15 15:10:53:880 CET] 00000008 CompositionUn A WSVR0191I: Composition unit WebSphere:cuname=MAXIMOIEHS in BLA WebSphere:blaname=MAXIMOIEHS started.
[1/19/15 15:10:53:880 CET] 00000000 ContainerHelp E WSVR0501E: Error creating component com.ibm.ws.runtime.component.CompositionUnitMgrImpl@68116811
com.ibm.ws.exception.RuntimeWarning: com.ibm.ws.exception.ConfigurationWarning: org.eclipse.jst.j2ee.commonarchivecore.internal.exception.NestedJarException: IWAE0008E An error occurred reading mbojava.jar from E:\IBM\WebSphere\AppServer\profiles\ctgAppSrv01\config\cells\ctgCell01\applications\MAXIMO.ear\deployments\MAXIMO
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2053)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:439)
at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:382)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$300(CompositionUnitMgrImpl.java:110)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$CUInitializer.run(CompositionUnitMgrImpl.java:949)
at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:349)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1604)
Caused by: com.ibm.ws.exception.ConfigurationWarning: org.eclipse.jst.j2ee.commonarchivecore.internal.exception.NestedJarException: IWAE0008E An error occurred reading mbojava.jar from E:\IBM\WebSphere\AppServer\profiles\ctgAppSrv01\config\cells\ctgCell01\applications\MAXIMO.ear\deployments\MAXIMO
at com.ibm.ws.runtime.component.ApplicationMgrImpl.initializeApplication(ApplicationMgrImpl.java:394)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2040)
... 7 more
Caused by: org.eclipse.jst.j2ee.commonarchivecore.internal.exception.NestedJarException: IWAE0008E An error occurred reading mbojava.jar from E:\IBM\WebSphere\AppServer\profiles\ctgAppSrv01\config\cells\ctgCell01\applications\MAXIMO.ear\deployments\MAXIMO
at org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.NestedArchiveLoadStrategyImpl.throwNestedJarException(NestedArchiveLoadStrategyImpl.java:322)
at org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.NestedArchiveLoadStrategyImpl.safeGetZipInputStream(NestedArchiveLoadStrategyImpl.java:339)
at org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.NestedArchiveLoadStrategyImpl.getFiles(NestedArchiveLoadStrategyImpl.java:382)
at org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.LoadStrategyImpl.collectFiles(LoadStrategyImpl.java:732)
at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.ContainerImpl.getFiles(ContainerImpl.java:473)
at org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.EjbJar30NoDDImportStrategyImpl$Discriminator.hasEjbContents(EjbJar30NoDDImportStrategyImpl.java:97)
at org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.EjbJar30NoDDImportStrategyImpl$Discriminator.canImport(EjbJar30NoDDImportStrategyImpl.java:70)
at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.RootEJBJarDescriminatorImpl.canImport(RootEJBJarDescriminatorImpl.java:47)
at org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveTypeDiscriminatorImpl.openArchive(ArchiveTypeDiscriminatorImpl.java:161)
at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.RootEJBJarDescriminatorImpl.openArchive(RootEJBJarDescriminatorImpl.java:108)
at org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveTypeDiscriminatorImpl.getImportableArchiveFromChild(ArchiveTypeDiscriminatorImpl.java:137)
at org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveTypeDiscriminatorImpl.openArchive(ArchiveTypeDiscriminatorImpl.java:165)
at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.CommonarchiveFactoryImpl.openSpecificArchive(CommonarchiveFactoryImpl.java:1527)
at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.CommonarchiveFactoryImpl.openArchive(CommonarchiveFactoryImpl.java:1163)
at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.CommonarchiveFactoryImpl.openNestedArchive(CommonarchiveFactoryImpl.java:1380)
at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.EARFileImpl.openNestedArchive(EARFileImpl.java:1172)
at org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.LoadStrategyImpl.openNestedArchive(LoadStrategyImpl.java:1185)
at org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.LoadStrategyImpl.collectFilesFromLooseArchives(LoadStrategyImpl.java:785)
at org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.LoadStrategyImpl.collectFiles(LoadStrategyImpl.java:731)
at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.ContainerImpl.getFiles(ContainerImpl.java:473)
at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.EARFileImpl.getFiles(EARFileImpl.java:2472)
at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.ContainerImpl.getFile(ContainerImpl.java:222)
at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.ModuleRefImpl.initModuleFileFromEAR(ModuleRefImpl.java:146)
at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.ModuleRefImpl.getModuleFile(ModuleRefImpl.java:120)
at com.ibm.ws.runtime.component.DeployedModuleImpl.isOpen(DeployedModuleImpl.java:238)
at com.ibm.ws.runtime.component.DeployedModuleImpl.close(DeployedModuleImpl.java:293)
at com.ibm.ws.runtime.component.DeployedModuleImpl.initialize(DeployedModuleImpl.java:477)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.initializeModule(DeployedApplicationImpl.java:1274)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.initialize(DeployedApplicationImpl.java:608)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.initialize(DeployedApplicationImpl.java:419)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.initializeApplication(ApplicationMgrImpl.java:364)
... 8 more
Caused by: java.io.FileNotFoundException: E:\IBM\WebSphere\AppServer\profiles\ctgAppSrv01\installedApps\ctgCell01\MAXIMO.ear\mbojava.jar (The system cannot find the file specified.)
at java.io.FileInputStream.<init>(FileInputStream.java:123)
at java.io.FileInputStream.<init>(FileInputStream.java:83)
at org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.DirectoryLoadStrategyImpl.getInputStream(DirectoryLoadStrategyImpl.java:827)
at org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.NestedArchiveLoadStrategyImpl.getZipInputStream(NestedArchiveLoadStrategyImpl.java:296)
at org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.NestedArchiveLoadStrategyImpl.safeGetZipInputStream(NestedArchiveLoadStrategyImpl.java:336)
... 37 more
I synchronise the nodes by stopping the node and then starting the node
Then restart the MXServer.
Now MAXIMO starts
Now in Maximo I point the Asset object to the custom class:
The original class is: (I have a scheduler and HSE installtion on this machine, so that is why the plusg class is the original)
psdi.plusg.app.asset.PlusGAssetSet
I point it to:
custom.app.asset.AssetCust
Set Maximo to Admin Mode and do a Database Configuration
Now when I go to the Asset application I get all invalid bindings and when trying to insert a new asset I get the following error:
BMXAA4160E - A major exception has occurred. Check the system log to see if there are any companion errors logged. Report this error to your system administrator.
custom.app.asset.AssetCust.<init>(psdi.mbo.MboServerInterface)
hmmm ok... Am i extending the wrong class in mu Custom made class? Maybe because of the HSE isntalaltion I need to extend that class?
I read through Bruno his blog and on the Extending Java page he explaines that the "Set" must also be extended.
http://maximodev.blogspot.nl/p/java-customization.html
This makes sense as I replaced a "Set" class with a non "Set" class in the Database Configuration.
So back to Eclipse.
I add another class file, named AssetCustSet with the following code:
package custom.app.asset;
import java.rmi.RemoteException;
import psdi.app.asset.AssetSet;
import psdi.app.asset.AssetSetRemote;
import psdi.mbo.Mbo;
import psdi.mbo.MboServerInterface;
import psdi.mbo.MboSet;
import psdi.util.MXException;
public class AssetCustSet extends AssetSet implements AssetSetRemote
{
public AssetCustSet(MboServerInterface ms)
throws MXException, RemoteException
{
super(ms);
}
protected Mbo getMboInstance(MboSet ms)
throws MXException, RemoteException
{
return new AssetCust(ms);
}
}
for the overview, the AssetCust looks like this:
package custom.app.asset;
import java.rmi.RemoteException;
import psdi.app.asset.Asset;
import psdi.app.asset.AssetRemote;
import psdi.mbo.MboRemote;
import psdi.mbo.MboSet;
import psdi.mbo.MboSetRemote;
import psdi.util.MXException;
public class AssetCust extends Asset implements AssetRemote
{
public AssetCust(MboSet ms)
throws MXException, RemoteException
{
super(ms);
}
public void save()throws MXException, RemoteException {
super.save();
int id = getInt("ASSETID");
String desc = getString("DESCRIPTION");
System.out.println("Saving Asset ID=" + id + " desc=" + desc);
}
}
Save and copy the class files from the bin directory in the businessobject.jar directory.
Note:
I now use the rapid deployment method explained here (The super fast approach):
http://maximodev.blogspot.nl/2012/08/maximo-rapid-java-class-deploy-websphere.html
I restart the MXServer.
Then, instead of pointing the asset object to custom.app.asset.AssetCust I point it to custom.app.asset.AssetCustSet
I do a database configuration and go to the Asset application. Now the applciation shows up normally.
I change an asset and insert a new one.
Now I check the systemOut.log
The lines from the code show up in the log. So it works.
GNZ
No comments:
Post a Comment