Dev Team Assemble

Evil beware!
Add to Technorati Favorites

Archive

Category: Development

I have been working with jDeveloper and JDE (J.D.Edwards) for a little while. Mostly to build integration pieces for portals and custom applications. One of the strangest things happened to me after I did a package update (upgrade to local JDE application) the other day.

After the package update, I grabbed my project code from the OMW (object management workbench) and tried to go back to development. All of a sudden it had replaced my ValueObject classes with generated classes ( really...I have no idea why) and copied some other strange code articles to my computer.

This was really strange but good thing I managed to backup my code using an alternative source code control system just in case something bizarre like this happened....which of course it did. I copied my code back over the top of the JDE code and all was well, with the exception of some oracle.e1.bssvfoundation classes not working correctly (complaining that the method could not be found, etc). In order to build my code I needed to remove some new code (that showed up during the package build) in the c:\e812\dv812\java\source\oracle\e1\bssvfoundation folder. I think its safe to say you can delete that entire folder because it should not exist in your source code folder.

To try and make a confusing story short and understandable I guess what I am trying to say if you find that you have the folder c:\e812\dv812\java\source\oracle\e1\bssvfoundation you can delete it because you probably shouldn't have it....these are system functions that you don't need the source for, and chances are if you do have the source its not the right version :s. I am not sure why they are included in our package but they are.

If your still with me then I hope this helped...if you are confused then drop me a line and I will attempt to explain by adding more acronyms and file paths.

Calvin

Technorati Tags: , , ,

I have been doing some integration work with JD Edwards Business Services (aka BSSV) lately and I came across this error when trying to run my Published Business Service .

Internal Server Error (Caught exception while handling request: oracle.e1.bssvfoundation.exception.E1AuthorizationException: User is not authorized to invoke this published business service

Here is the article that led me to the answer I needed https://forums.oracle.com/forums/thread.jspa?threadID=867569 specifically ChrisWalsh's comment.

Essentially in order to run a published business service you need to have security to the object declared in JDE. This is done in the F00950 table (or file) and should probably be setup as *ALL for your dev team.

HTH

Technorati Tags: , ,

I often find in my sharepoint development environments that I have issues with transaction logs filling up. This gives me the "Error" page with no indication of what the problem is...yes I can go and change the <customErrors> tag to set the customer errors mode to off and add the callstack to the page but it still doesn't address the problem. I whipped this script up because the dev sql server we are using has well over a hundred db's on it and I didn't fell like manually typing the ALTER DATABASE [xxx] SET RECOVERY SIMPLE for each one or doing the clickity click thing either. Now the solution below probably breaks lots of best practices and such but it works for what I wanted it to do....which is modify all existing db's recovery mode. To modify new db's recovery mode, just set the model db's option to simple and voila..you are ready to go.

Quick note: YOU PROBABLY DO NOT WANT TO EVER...I MEAN EVER...USE THIS ON A PRODUCTION SYSTEM.


*/

Modify th recovery model for all databases on your server

*/

DECLARE @lasterror int

DECLARE @sql nvarchar(max)

DECLARE @dbname nvarchar(100)

DECLARE @dbid int

DECLARE @recModel int

-- cycle the log

exec sp_cycle_errorlog

CREATE Table #dbInfo

(

database_id int NOT NULL,

dbName nvarchar(100) NOT NULL,

recoveryModel int

)

--SELECT database_id, [name], recovery_model FROM sys.databases order by database_id

SELECT TOP 1 @dbid = database_id FROM sys.databases where database_id > 4 ORDER BY database_id asc;

SELECT @dbname = [name] FROM sys.databases where database_id = @dbid;

SELECT @recModel = recovery_model FROM sys.databases where database_id = @dbid;

-- begin backup process

WHILE @dbid > 0

BEGIN

INSERT INTO #dbInfo (database_id, dbName, recoveryModel) VALUES (@dbid, @dbname, @recModel);

IF @recModel = 1

BEGIN

SELECT @sql = 'ALTER DATABASE [' + @dbname + '] SET RECOVERY SIMPLE'

EXEC sp_executesql @sql

SELECT @lasterror = @@ERROR

IF @lasterror <> 0

-- log the error to the message console

PRINT 'ERROR: Changing the recovery mode for database : ' + @dbname + ' with error number ' + CAST(@lasterror as nvarchar(25))

ELSE

PRINT 'Recovery mode changed to simple (3) for database : ' + @dbname

END

-- get a new record

SELECT @dbid = 0;

SELECT TOP 1 @dbid = database_id FROM sys.databases where database_id > 4 and

database_id NOT IN (SELECT DISTINCT x.database_id FROM #dbInfo x);

SELECT @dbname = [name] FROM sys.databases where database_id = @dbid;

SELECT @recModel = recovery_model FROM sys.databases where database_id = @dbid;

END

DROP Table #dbInfo

SELECT database_id, [name], recovery_model FROM sys.databases order by database_id

GO

Technorati Tags: , , , ,

Heres a neat little snippit that comes in handy for running commands against the operating system.

Sourced directly from here: http://stackoverflow.com/questions/691716/running-cmd-commands-via-net ...but I like having the code here as well.

 
// Kills a process
<span> </span> private static void ExecuteCommand(string command)
{
try
{
// create the ProcessStartInfo using "cmd" as the program to be run,
// and "/c " as the parameters. &gt; tell the command to execute the command that follows
System.Diagnostics.ProcessStartInfo procStartUpInfo =
new System.Diagnostics.ProcessStartInfo("cmd", "/c " + command);
// The following commands are needed to redirect the standard output.
// This means that it will be redirected to the Process.StandardOutput StreamReader.
procStartUpInfo.RedirectStandardOutput = true;
procStartUpInfo.UseShellExecute = false;
// Do not create a window.
procStartUpInfo.CreateNoWindow = true;
// Now we create a process, assign its ProcessStartInfo and start it
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartUpInfo;
proc.Start();
// Get the output into a string
string result = proc.StandardOutput.ReadToEnd();
// Display the command output.
Console.WriteLine(result);
}
catch (Exception objException)
{
Console.WriteLine(objException);
}
}
 

Technorati Tags: , , , ,

Here is some useful information that I always seem to forget when developing windows services.

  • To install/uninstall manually, which i find helpful to do from the bin folder of your project use the following commands:
    • INSTALL: %windir%\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe [the name of the executable]
    • UNINSTALL: %windir%\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe -u [the name of the executable]
  • To Debug a windows service add the following code to your Main method

    static void Main(string[] args)
    {
    #if DEBUG
    System.Diagnostics.Debugger.Break();
    #endif

    ServiceBase.Run(new Service());

    }

  • To create an installation package for a service: ....I will come back to that - no time to put it together today :)

Technorati Tags: , , ,

I have been working with xml serialization over the last week or so and ran into a strange issue today. It only came to light when I decided to implement IXmlSerializable and write my own methods for reading and writing the xml. I posted recently about using he XmlRootAttribute as a fix for the xmlns='' > was not expected error I was seeing. This all worked fine and dandy until I really started to utilize that method over and over again in my code. I found the performance of this to be horrible...so horrible in fact it was taking 2-3 minutes to deserialize a moderately complex 1MB xml file. After doing some digging (on "The Google") I discovered that microsoft decided to only implement caching on the Xml serializer when you use one of the two "more common" constructors (see documentation). Of course it would seem the one I need would not be one of them.

I was thinking of somehow adding the XmlSerializers for each type/root pair that I was using to the application level cache or something like that but thought that might bring with it its own set of challenges. I found a great article here on stack overflow that shows a possible workaround for the problem using a static class to act as a cache or you.

Please note this code is taken directly from the article above:


public static class XmlSerializerCache
{
private static readonly Dictionary cache =
new Dictionary();

public static XmlSerializer Create(Type type, XmlRootAttribute root)
{
var key = String.Format( CultureInfo.InvariantCulture, "{0}:{1}", type, root.ElementName);

if (!cache.ContainsKey(key))
{
cache.Add(key, new XmlSerializer(type, root));
}

return cache[key];
}
}

Here is how you use it to create an XmlSerializer object:


var xmlRootAttribute = new XmlRootAttribute("ExampleElement");
var serializer = XmlSerializerCache.Create(target.GetType(), xmlRootAttribute);

After implementing that I was still experiencing the 2-3 minute deserialization one the first call but all subsequent calls to that code with similar xml took only 2 seconds.

NOTE:
Seems microsoft is in the habit of only half implementing caching in their code. This problem is almost identical to the problems with the CrossListQueryCache object in SharePoint....where they again only implemented caching for two of the four available method signatures. Here is an interesting article I found in the nether-regions of cyberspace where microsoft state this half implementation is by design...

Technorati Tags: , , , , , , ,

I had what turns out to be a fairly common error the other day when trying to deserialize an xml file in one of my applications.  Here is the code I was running:


XmlSerializer ser = new XmlSerializer(typeof(MyObject));
XmlReader xRdr = XmlReader.Create(new StringReader(xmlData));
MyObject tvd = (MyObject)ser.Deserialize(xRdr);

As it turns out this was causing the error: xmlns=''> was not expected during deserialization. Alot of the resources online (including the msdn article here) were pointing me to the namespaces not being the same on the serializer and document. I am not sure why it wasn't working for me because I was playing around with the namespaces but couldn't seem to figure out how to get that working. Maybe because I was only serializing a fragment of a document I'm not sure. Anyway it turns out that specifying the XmlRootAttribute in the XmlSerializer constructor fixed the problem for me. This Stack Overflow article really helped Here is the snippet of code that I am using now:


XmlRootAttribute xRoot = new XmlRootAttribute();
xRoot.ElementName = elementName;
xRoot.IsNullable = true;

XmlSerializer ser = new XmlSerializer(typeof(MyObject), xRoot);
XmlReader xRdr = XmlReader.Create(new StringReader(xmlData));
MyObject tvd = (MyObject)ser.Deserialize(xRdr);

Hope this helps

Technorati Tags: , , , , ,

So I was trying to restore a content db from production into my dev box the other day and got the following error:

Your backup is from a different version of Windows SharePoint Services and cannot be restored to a server running the current version. The backup file should be restored to a server with version '12.0.0.6510'

Ahh ok...so my dev box is out of sync no biggie, it was't a real pressing update anyway.  So I figured I would go back to my site to finish up some dev tasks and to my dismay....the site was gone.   Ummmm...hello?!?!?!

Turns out, the restore process (via 'stsadm -o restore -url http://omg.net -filename c:\arrggggh.bak') wipes out your content db.  Great so now I HAVE to update my dev box to the version of the production server (which isn't a bad idea...just rather make that choice myself!).

Here is a great resource for figuring out which updates you need:

http://sharepointadminwiki.com/display/SharePointAdministrationWiki/SharePoint+Versions

To determine your version of SharePoint go to Central Admin > Operation > Servers in Farm

HTH

Technorati Tags: , ,

One thing I always seem to forget when moving from one db system to the other (not using DB2 all that often) is how to select the TOP n rows from a query.

In MS SQL Server this is expressed as SELECT TOP n * FROM [table] ...

the equivilent in DB2 is SELECT * FROM [table] FETCH FIRST n ROWS ONLY

Technorati Tags: ,

One of the things I was working on today was trying to get an actual image from the library was that initially I was expecting to get a PublishingImage.  All the samples on MSDN and the ones strewn about the web refer to using the ImageFieldValue and getting it from a field in the SPListItem.  Like outlined on MSDN :

  // Retrieve the current value from an SPListItem with a
  // column of the ImageField type with the name imageFieldName
  ImageFieldValue currentFieldValue =
        listItemWithImageField[imageFieldName] as ImageFieldValue;

The problem is this only works for images that are in a list, like the PublishingRollupImage of a page that links to an image in the Site Collection Images library.  The actual images in the library are stored as documents (Referenced using SPFile) so in order utilize them I need to extract the information out and create an image tag for it...like so:

 
     ImageFieldValue imageValue = new ImageFieldValue(
          string.Format("<img src=\"{0}\" alt=\"{1}\" />",
          file.Url, file.Title == null ? string.Empty : file.Title));
 

Now that I had the ImageFieldValue it was easy to work with. I could manipulate many aspects of the image using this object and then save it for rendering using ToString(). Funny thing is for my purposes (ImageGallery xml generation) I didn't even end up needing this code after all...frustrating but a good learning experience.

Props to Phanat Chan as he did the initial development on this.

Technorati Tags: , ,