Exception of sending email doesn't show in the CC.net Dashboard - cruisecontrol.net

All, I succeed to config a email publisher in the ccnet.config. and it works fine. all the task like build, unittest, merge result, etc are completed successfully.
But for some reason. I mistake the smtp authentication user name which will cause a exception when run a build. By the way. I set the notifications is Always.
<publishers>
<statistics />
<merge>
<files>
<file>TestResult\UnitTestResults.trx</file>
</files>
</merge>
<buildpublisher>
<sourceDir>E:\study\cc.net\Test\KMIH\BackUpFolder\Source</sourceDir>
<publishDir>E:\study\cc.net\Test\KMIH\BackUpFolder\Publish</publishDir>
<useLabelSubDirectory>true</useLabelSubDirectory>
<alwaysPublish>true</alwaysPublish>
</buildpublisher>
<email mailport="25" mailhostUsername="xxxxxx" mailhostPassword="xxxxxx" useSSL="FALSE" includeDetails="true">
<from>xxxxx#163.com</from>
<mailhost>smtp.163.com</mailhost>
<users>
<user name="JoeWang" group="BuildMaster" address="xxxxx#163.com"/>
</users>
<groups>
<group name="BuildMaster">
<notifications>
<notificationType>Always</notificationType>
</notifications>
</group>
</groups>
</email>
<xmllogger/>
<artifactcleanup cleanUpMethod="KeepLastXBuilds" cleanUpValue="50"/>
</publishers>
So Hopefully I would like to see this error show up when I check the build report of Dashboard. I can see a failed build. But I didn't found any error message or information to let me know what exactly error it is. (In this case. it is wrong email configuration).
Am I missing something ? Thanks.

After check out the Source Code. (1.8.5.0) . I think I found why..
It seems it is a CC.net bug. Hopefully it is not.
Here is the exception coming from ThoughtWorks.CruiseControl.Core.Tasks.TaskBase.
public virtual void Run(IIntegrationResult result)
{
// Initialise the task
this.WasSuccessful = false;
if ((this.currentStatus == null) ||
(this.currentStatus.Status != ItemBuildStatus.Running))
{
InitialiseStatus(ItemBuildStatus.Pending);
currentStatus.Status = ItemBuildStatus.Running;
}
// Perform the actual run
currentStatus.TimeOfEstimatedCompletion = CalculateEstimatedTime();
currentStatus.TimeStarted = DateTime.Now;
try
{
this.WasSuccessful = Execute(result);//Email sending exception is threw out...
}
catch (Exception error)
{
// Store the error message
currentStatus.Error = error.Message;
result.Status = IntegrationStatus.Exception;
throw;
}
finally
{
// Clean up
currentStatus.Status = (this.WasSuccessful) ? ItemBuildStatus.CompletedSuccess : ItemBuildStatus.CompletedFailed;
currentStatus.TimeCompleted = DateTime.Now;
switch (result.Status)
{
case IntegrationStatus.Unknown:
case IntegrationStatus.Success:
result.Status = this.WasSuccessful ? IntegrationStatus.Success : IntegrationStatus.Failure;
break;
}
}
}
The Execute is a abstract function.
protected abstract bool Execute(IIntegrationResult result);
And the build log is built in the Class XmlIntegrationResultWriter
public void Write(IIntegrationResult result)
{
writer.WriteStartElement(Elements.CRUISE_ROOT);
writer.WriteAttributeString("project", result.ProjectName);
WriteRequest(result.IntegrationRequest);
WriteModifications(result.Modifications);
WriteIntegrationProperties(result);
WriteBuildElement(result);
WriteException(result);//since no exception found . so the log no exception detail populated. That is the root cause.
writer.WriteEndElement();
}
So I think the exception should added into IIntegrationResult like below when it happened.
try
{
this.WasSuccessful = Execute(result);
}
catch (Exception error)
{
// Store the error message
result.ExceptionResult = error;//Add the exception in the build process so that it will be generated in the build log.
currentStatus.Error = error.Message;
result.Status = IntegrationStatus.Exception;
throw;
}
I replaced the ccnet.exe with the new compiled one. Then the exception will show in the build report of Dashboard.
Any better idea? Thanks.

Related

Access Denied exception being thrown in UWP

I'm trying to save a video file to a specific folder location instead of a library; which is what it defaults saves to. I'm using StorageFolder.GetFolderFromPathAsync to get the location. When it reaches that line in the function it'll throw the exception. 'Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))'
private async Task StartRecordingAsync()
{
try
{
// Create storage file for the capture
var videoFile = await _captureFolder.CreateFileAsync("SimpleVideo.mp4", CreationCollisionOption.GenerateUniqueName);
var encodingProfile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto);
// Calculate rotation angle, taking mirroring into account if necessary
Debug.WriteLine("Starting recording to " + videoFile.Path);
await _mediaCapture.StartRecordToStorageFileAsync(encodingProfile, videoFile);
_isRecording = true;
_isPreviewing = true;
Debug.WriteLine("Started recording!");
}
catch (Exception ex)
{
// File I/O errors are reported as exceptions
Debug.WriteLine("Exception when starting video recording: " + ex.ToString());
}
}
Code in between
private async Task SetupUiAsync()
{
var lvmptVid = await StorageFolder.GetFolderFromPathAsync("C:\\Users\\Nano\\Documents\\lvmptVid");
// var videosLibrary = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Videos);
// var picturesLibrary = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Pictures);
// Fall back to the local app storage if the Pictures Library is not available
_captureFolder = lvmptVid;
}
I've tried using different saving techniques, currently in the process of revamping the process.
I've tried using a public file location instead of a user specific one.
When you are trying to use GetFolderFromPathAsync to get the file directly using a path, please make sure that you've enabled the broadFileSystemAccess capability in the manifest file.
Like this:
<Package
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap mp rescap">
<Capabilities>
<rescap:Capability Name="broadFileSystemAccess" />
</Capabilities>
Please also remember to enable the file system settings in Settings > Privacy > File system.
Like this:

IOException message not printed correctly when using Java 9 on Windows 10 set to Japan locale and language

An Exception is thrown in this particular block.
try
{
transport.m_readListener.onReadTransport(transport);
}
catch (IOException e)
{
->onIOException(e,transport);
}
The onIOException() method puts it on the log:
private void onIOException(IOException e, AbstractConnection connection)
{
String reason = e.getMessage();
...
log.error("Closing ",connection," because ",reason);
}
The reason variable in Java 8 shows a correct japanese phrase:
reason : 既存の接続はリモート ホストに強制的に切断されました。
(meaning: The existing connection was forcibly disconnected to the remote host)
When ran on Java 9, the exception message is now broken:
reason : 譌「蟄倥?ョ謗・邯壹?ッ繝ェ繝「繝シ繝? 繝帙せ繝医↓蠑キ蛻カ逧?縺ォ蛻?譁ュ縺輔l縺セ縺励◆縲?
The code block that checks if the Socket port is still open is inside a try catch block that catches the IOException. The message from the IOException is acquired via
String reason = e.getMessage();
if (null == reason) reason = e.toString();
Tried running the app with java.locale.providers=COMPAT,CLDR,SPI to make it behave like in Java 8 but nothing happens. Anyone has an idea on this issue? Can anyone help? Thanks!

How to handle Connect/ Authentication errors when using imap-idle-channel-adapter

I am able to handle and report connection/ authentication related errors for imap and pop adapter by using error-channel on the poller.
I have one for imap-idle too but its not getting these error on that channel but a warning in the logs only.
what is the way out to handle and report similar errors for email idle adapter?
I guess you mean this peace of code:
catch (Exception e) { //run again after a delay
logger.warn("Failed to execute IDLE task. Will attempt to resubmit in " + ImapIdleChannelAdapter.this.reconnectDelay + " milliseconds.", e);
ImapIdleChannelAdapter.this.receivingTaskTrigger.delayNextExecution();
ImapIdleChannelAdapter.this.publishException(e);
}
And you see that WARN in your logs.
Pay attention, please, to the latest line about publishException(). It is this code:
private void publishException(Exception e) {
if (this.applicationEventPublisher != null) {
this.applicationEventPublisher.publishEvent(new ImapIdleExceptionEvent(e));
}
So, what you need is to add an EventListener for that ImapIdleExceptionEvent. For example you can use ApplicationEventListeningMessageProducer.

Transaction handling with JDBC Connection Pooling in Tomcat7

I am developing a JSF application which uses JNDI connection pooling to a DB2 database through the Tomcat 7 configuration. I am having problems managing transactions and more specifically rolling back when an exception is thrown from a method which shares a connection.
The following code establishes a connection and passes this down through all other methods being called. This connection is then only closed in the finally block of the method. My issue is that for example...if an exception is thrown at any point in the method, any work completed prior to this is committed and not rolled back. I was under the impression that when closing a connection in the finally block, this would not commit if any exceptions were thrown during the life time of this connection and then the connection is returned to the pool regardless if the work has been committed or rolled back.
public boolean updateSubCountry(SubCountryDTO dto,
List<FeatureAliasDTO> aliases, List<FeatureCodeDTO> codes)
throws ReferenceDataException {
boolean success = true;
Connection c = null;
try {
c = fDao.getConnection();
success = fDao.updateSubCountry(c, dto, TEMP_USERNAME) && success;
success = updateAliases(c, aliases, dto.getOdi(), TEMP_USERNAME,
dto.getSubCountryId()) && success;
for (FeatureCodeDTO codeDto : codes) {
success = updateFeatureCode(c, codeDto, dto.getSubCountryId())
&& success;
}
} finally {
closeConnection(c, DEFAULT_CONNECTION_ERROR_MSG);
}
return success;
}
My JNDI configuration is as follows (sensitive info starred out):
<Resource name="jdbc/core" auth="Container" type="javax.sql.DataSource"
url="****"
driverClassName="com.ibm.db2.jcc.DB2Driver"
username="****" password="****"
maxActive="20" maxIdle="3" maxWait="10000"
poolPreparedStatements="true"
maxOpenPreparedStatements="100"
validationQuery="SELECT 1 FROM SYSIBM.SYSDUMMY1" />
Any help is appreciated.
Thanks.
UPDATE
I have attempted to implement the suggestions made by #Tiny. However, the when purposely making updateFeatureCode() method throw an exception on the database level, any work before this is still not rolled back?
#Transactional (rollbackFor={Exception.class, ReferenceDataException.class})
public boolean updateSubCountry(SubCountryDTO dto,
List<FeatureAliasDTO> aliases, List<FeatureCodeDTO> codes)
throws ReferenceDataException {
boolean success = true;
Connection c = null;
try {
c = fDao.getConnection();
success = fDao.updateSubCountry(c, dto, TEMP_USERNAME) && success;
success = updateAliases(c, aliases, dto.getOdi(), TEMP_USERNAME,
dto.getSubCountryId()) && success;
for (FeatureCodeDTO codeDto : codes) {
success = updateFeatureCode(c, codeDto, dto.getSubCountryId())
&& success;
}
} finally {
closeConnection(c, DEFAULT_CONNECTION_ERROR_MSG);
}
return success;
}
The IBM JDBC driver, when connected to a DB2 database, defaults to autoCommit=true, which means that an explicit COMMIT is issued after each statement. If you wish to control transactions yourself, disable autocommit and commit or rollback as necessary. Alternatively, as suggested by #Tiny, use a transaction manager.

play file wav j2me - IllegalArgumentException at Manager.createPlayer()

I got problem about play wav file in my application.
This is my error:
java.lang.IllegalArgumentException
at javax.microedition.media.Manager.createPlayer(), bci=8
at Tajwid.Tajwid.run(Tajwid.java:649)
at Tajwid.Tajwid.actionPerformed(Tajwid.java:186)
at com.sun.lwuit.util.EventDispatcher.fireActionSync(), bci=19
at com.sun.lwuit.util.EventDispatcher.fireActionEvent(EventDispatcher.java:257)
This is my code:
public void run() {
try {
InputStream is = getClass().getResourceAsStream("/tes.wav");
player = Manager.createPlayer(is, "audio/x-wav");
player.realize();
// get volume control for player and set volume to max
vc = (VolumeControl) player.getControl("VolumeControl");
if (vc != null) {
vc.setLevel(100);
}
player.prefetch();
player.start();
} catch (Exception e) {
e.printStackTrace();
}
Device Configuration : CLDC-1.1
Device Profile MIDP 2.0
Error message you've got has sufficient information to figure what went wrong in the code.
Look at it a bit closer:
java.lang.IllegalArgumentException
at javax.microedition.media.Manager.createPlayer()...
It says something went wrong in Manager.createPlayer(). From your code, it is apparent that you use method Manager.createPlayer(java.io.InputStream stream, java.lang.String type).
If you look into API documentation for the method you use (available online), you'll find the explanation when this exception occurs:
Throws:
java.lang.IllegalArgumentException - Thrown if stream is null.
Above means that stream parameter (is in your code) passed to the method is null.
You could add some logging right after initialization of the is to debug this issue easier:
InputStream is = getClass().getResourceAsStream("/tes.wav");
// add some logging to see if initialization was OK or not:
System.out.println("input stream is null: [" + (is == null) + "]");
That way, when running your MIDlet in emulator, you will see whether is was initialized as expected or not.
Actually, looking at the code I would guess that you made a typo in file name passed to getResourceAsStream: "/tes.wav" looks like a mis-typed "/test.wav".

Resources