System.AggregateException: One or more errors occurred on Xamarin - mysql

Help Guys,
I am new on using Xamarin Android. I am trying to connect a MySQL database to my app. It stops at the con.Open(); line and I am not really sure what is wrong.
string myConnectionString = "Server=db4free.net;Port=3306;Database=*******;Uid=*******;Pwd=*******";
MySqlConnection con = new MySqlConnection(myConnectionString);
if (con.State == ConnectionState.Closed)
{
con.Open(); //error here
}
I have already added the library
using System.Data;
using MySql.Data.MySqlClient;
I also imported the MySQLConnector Nugget package.
I im still on the connection part as I did not do anything yet.
Note that the credentials are correct as I was able to connect in the DB using a php page. Any Ideas?
Edit
got this error on my Catch()
System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> Mono.Btls.MonoBtlsException: Ssl error:100000f0:SSL routines:OPENSSL_internal:UNSUPPORTED_PROTOCOL
at /Users/builder/jenkins/workspace/xamarin-android-d15-7/xamarin-android/external/mono/external/boringssl/ssl/handshake_client.c:808
at Mono.Btls.MonoBtlsContext.ProcessHandshake () [0x00038] in <5a97d41d36694fb19855c17429527b10>:0
at Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake (Mono.Net.Security.AsyncOperationStatus status) [0x0003e] in <5a97d41d36694fb19855c17429527b10>:0
at (wrapper remoting-invoke-with-check) Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake(Mono.Net.Security.AsyncOperationStatus)
at Mono.Net.Security.AsyncHandshakeRequest.Run (Mono.Net.Security.AsyncOperationStatus status) [0x00006] in <5a97d41d36694fb19855c17429527b10>:0
at Mono.Net.Security.AsyncProtocolRequest+<ProcessOperation>d__24.MoveNext () [0x000ff] in <5a97d41d36694fb19855c17429527b10>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <f32579baafc1404fa37ba3ec1abdc0bd>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <f32579baafc1404fa37ba3ec1abdc0bd>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <f32579baafc1404fa37ba3ec1abdc0bd>:0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0
at Mono.Net.Security.AsyncProtocolRequest+<StartOperation>d__23.MoveNext () [0x0008b] in <5a97d41d36694fb19855c17429527b10>:0
--- End of inner exception stack trace ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0
at Mono.Net.Security.MobileAuthenticatedStream+<ProcessAuthentication>d__47.MoveNext () [0x00254] in <5a97d41d36694fb19855c17429527b10>:0 }
base: {System.SystemException}

Related

Problem connecting to mySQL database using xamarin Andriod only but works in iOS and UWP

I am connecting to mySQL server directly(Learning purposes only) from Xamarin cross platform App.
The connection is working good in both iOS and UWP but in android it throws an error in this line:
await conn.OpenAsync();
This is the full error:
{System.TypeInitializationException: The type initializer for 'MySql.Data.MySqlClient.MySqlConfiguration' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.PlatformNotSupportedException: Operation is not supported on this platform. at System.Configuration.ClientConfigPaths..ctor (System.String exePath, System.Boolean includeUserConfig) [0x00050] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 at System.Configuration.ClientConfigPaths.GetPaths (System.String exePath, System.Boolean includeUserConfig) [0x00018] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 at System.Configuration.ClientConfigurationHost.get_ConfigPaths () [0x0000a] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 at System.Configuration.ClientConfigurationHost.GetStreamName (System.String configPath) [0x0006d] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 at System.Configuration.ClientConfigurationHost.get_IsAppConfigHttp () [0x00000] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 at System.Configuration.Internal.DelegatingConfigHost.get_IsAppConfigHttp () [0x00006] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 at System.Configuration.ClientConfigurationSystem..ctor () [0x00051] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 at System.Configuration.ConfigurationManager.EnsureConfigurationSystem () [0x00024] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 --- End of inner exception stack trace --- at System.Configuration.ConfigurationManager.EnsureConfigurationSystem () [0x00060] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 at System.Configuration.ConfigurationManager.PrepareConfigSystem () [0x0000a] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x0000a] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 at MySql.Data.MySqlClient.MySqlConfiguration..cctor () [0x00000] in :0 --- End of inner exception stack trace --- at MySql.Data.MySqlClient.Replication.ReplicationManager..cctor () [0x0001e] in :0 }
Hope someone can help me with this error
Thanks in advance
I was using MySql.Data package and obviously it doesn't support Android yet
The solution is: use MySqlConnector package.
Side note: MySqlConnector package didn't work with: await conn.openAsync();
I had to use: conn.open();
It worked for iOS, Android, and UWP.

Connection error on UserManager CreateAsync

I am getting the following error when trying to create a new user using the UserManager CreateAsync method. I am using an unmodified IdentityUser and IdentityRole. I have a few DBSets which populate with data from the database, so reading is not an issue, just writing to it seems to be.
{System.InvalidOperationException: Connection must be valid and open to commit transaction at MySql.Data.MySqlClient.MySqlTransaction.Commit()
at Microsoft.EntityFrameworkCore.Storage.RelationalTransaction.Commit()
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.<ExecuteAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.<SaveChangesAsync>d__54.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.<SaveChangesAsync>d__52.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.EntityFrameworkCore.DbContext.<SaveChangesAsync>d__35.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore`9.<CreateAsync>d__36.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Identity.UserManager`1.<CreateAsync>d__68.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Identity.UserManager`1.<CreateAsync>d__73.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Controllers.Auth.AuthController.<Register>d__9.MoveNext() in AuthController.cs:line 102}
I'm using;
MySQL Entity Framework Core 7.0.7-m61
Visual Studio 2017
ASP.NET Core MVC 1.1.0
Identity 1.1
Line 102 mentioned in the error is var result = await userManager.CreateAsync(newUser, model.Password);
[HttpPost]
public async Task<ActionResult>Register(RegisterViewModel model)
{
try
{
if (ModelState.IsValid)
{
var newUser = new IdentityUser
{
Email = model.Email,
UserName = model.Username
};
var result = await _userManager.CreateAsync(newUser, model.Password);
if (result.Succeeded)
{
await _signInManager.SignInAsync(newUser, false);
_logger.LogInformation($"New user account created: {model.Username}");
return RedirectToAction("Index", "App");
}
_logger.LogError($"Registration failed for {model.Username}: ", result.Errors);
return View(model);
}
return View(model);
}
catch (Exception ex)
{
_logger.LogError("Database Failure: ", ex);
return View(model);
}
}
I'm learning asp.net and am stumbling here on what I'm hoping is an obvious error as it seems to be a basic connection issue but it's not making sense as the database can be queried using IdentityDBContext but not through the UserManager, which in my understanding uses the IdentityDBContext connection.
Do not use MySql.Data.EntityFrameworkCore-7.0.7-m61 provider and use something else. Oracle manages to embarrass themselves with each pre-release version of it.
With this release they managed to brake the package so hard, that it's unusable as that provider seems to close it's connection after every query. Use Pomelo.EntityFrameworkCore.MySql 1.1.0 instead (or wait for the next release of Oracles provider). Oracle was never strong at supporting ADO.NET/EF with current provider versions
Even better, use PostgreSQL or SqlServer instead.

Unable to connect to any of the specified MySQL hosts. 6

I hosted my website on web server.
I run my website in visual studio using the server database, it worked fine but when i hosted it on the web server, after one day it started giving me this error.
Sometimes some pages works fine and sometimes the same pages gives this error.
What would be the problem ?
Any solution will be appreciable.
This is the error -
Server Error in '/AttWeb' Application.
Unable to connect to any of the specified MySQL hosts.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.]
MySql.Data.MySqlClient.NativeDriver.Open() +1268
MySql.Data.MySqlClient.Driver.Open() +22
MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings) +218
MySql.Data.MySqlClient.MySqlPool.GetPooledConnection() +287
MySql.Data.MySqlClient.MySqlPool.TryToGetDriver() +93
MySql.Data.MySqlClient.MySqlPool.GetConnection() +65
MySql.Data.MySqlClient.MySqlConnection.Open() +543
System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +2086
System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e) +278
System.Web.UI.WebControls.ListControl.PerformSelect() +37
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +114
System.Web.UI.WebControls.ListControl.OnPreRender(EventArgs e) +23
System.Web.UI.Control.PreRenderRecursiveInternal() +88
System.Web.UI.Control.PreRenderRecursiveInternal() +160
System.Web.UI.Control.PreRenderRecursiveInternal() +160
System.Web.UI.Control.PreRenderRecursiveInternal() +160
System.Web.UI.Control.PreRenderRecursiveInternal() +160
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4775
and this is my code -
private MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString);
protected void keepData()
{
MySqlCommand cmd = new MySqlCommand("select deptName, year from subject where subId = '" + Request.Cookies["subject"].Value + "';", con);
try
{
con.Open();
MySqlDataReader result = cmd.ExecuteReader();
if (result.Read())
{
Response.Cookies["deptName"].Value = result["deptName"].ToString();
Response.Cookies["year"].Value = result["year"].ToString();
}
}
catch (MySqlException s) { Label1.Text = "Connection Failed"; }
catch (Exception ex) { Label1.Text = "Network Error"; }
con.Close();
}
and my web.config file contains connection string as
<connectionStrings>
<add name="DBCS"
connectionString="Server=MYSQL5016.SmarterASP.NET;Database=db_a0d03d_demo1;Uid=a0d03d_demo1;Pwd=***"
providerName="MySql.Data.MySqlClient" />
I am new to this please help me.
When you try to connect to other not local database you need allow remote request.

Website in Azure gives database connection error

I just moved my MVC5 web-project to Azure. The project uses a MySql database which is now hosted in Azure as well. I have updated the connection strings, and if I start the website from localhost on my own machine (still pointing to the database on Azure) all works well. But if I start the website from my Azure url, I get an sql error.
System.Data.Entity.Core.ProviderIncompatibleException: The provider
did not return a ProviderManifestToken string. --->
MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the
specified MySQL hosts. ---> System.Net.Sockets.SocketException: An
attempt was made to access a socket in a way forbidden by its access
permissions 127.0.0.1:3306 at
System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult) at
MySql.Data.Common.MyNetworkStream.CreateSocketStream(MySqlConnectionStringBuilder
settings, IPAddress ip, Boolean unix) at
MySql.Data.Common.MyNetworkStream.CreateStream(MySqlConnectionStringBuilder
settings, Boolean unix) at
MySql.Data.Common.StreamCreator.GetStream(MySqlConnectionStringBuilder
settings) at MySql.Data.MySqlClient.NativeDriver.Open() --- End of
inner exception stack trace --- at
MySql.Data.MySqlClient.NativeDriver.Open() at
MySql.Data.MySqlClient.Driver.Open() at
MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder
settings) at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection() at
MySql.Data.MySqlClient.MySqlPool.TryToGetDriver() at
MySql.Data.MySqlClient.MySqlPool.GetConnection() at
MySql.Data.MySqlClient.MySqlConnection.Open() at
MySql.Data.MySqlClient.MySqlProviderServices.GetDbProviderManifestToken(DbConnection
connection) at
System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection
connection) --- End of inner exception stack trace --- at
System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection
connection) at
System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices
providerServices, DbConnection connection) --- End of inner exception
stack trace --- at
System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices
providerServices, DbConnection connection) at
System.Data.Entity.Infrastructure.DefaultManifestTokenResolver.<>c__DisplayClass1.b__0(Tuple3
k) at
System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey
key, Func2 valueFactory) at
System.Data.Entity.Infrastructure.DefaultManifestTokenResolver.ResolveManifestToken(DbConnection
connection) at
System.Data.Entity.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection
connection, DbProviderManifest& providerManifest) at
System.Data.Entity.DbModelBuilder.Build(DbConnection
providerConnection) at
System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext
internalContext) at
System.Data.Entity.Internal.RetryLazy2.GetValue(TInput input) at
System.Data.Entity.Internal.LazyInternalContext.InitializeContext() at
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type
entityType) at
System.Data.Entity.Internal.Linq.InternalSet1.Initialize() at
System.Data.Entity.Internal.Linq.InternalSet1.Include(String path) at
System.Data.Entity.Infrastructure.DbQuery1.Include(String path) at
System.Data.Entity.QueryableExtensions.Include[T](IQueryable1 source,
String path) at
System.Data.Entity.QueryableExtensions.Include[T,TProperty](IQueryable1
source, Expression1 path) at
Microsoft.AspNet.Identity.EntityFramework.UserStore6.GetUserAggregateAsync(Expression1
filter) at
Microsoft.AspNet.Identity.EntityFramework.UserStore6.FindByNameAsync(String
userName) at
Microsoft.AspNet.Identity.UserManager2.FindByNameAsync(String
userName) at
Microsoft.AspNet.Identity.Owin.SignInManager2.<PasswordSignInAsync>d__29.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
tripplanner.Controllers.AccountController.<Login>d__2.MoveNext() ---
End of stack trace from previous location where exception was thrown
--- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult
asyncResult) at
System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.<BeginInvokeAsynchronousActionMethod>b__36(IAsyncResult
asyncResult) at
System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult1.CallEndDelegate(IAsyncResult
asyncResult) at
System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase1.End()
at
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult
asyncResult) at
System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
at
System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
at
System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) at
System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult1.CallEndDelegate(IAsyncResult
asyncResult) at
System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
at
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult
asyncResult) at
System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.b__1c()
at
System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.b__1e(IAsyncResult
asyncResult);
Hope someone can help.
UPDATE: I was using the wrong web.config file in Azure.

ESB Mule Client staring with xml-properties fails

I use Mule 3.x
I have a code that tests MuleClient connectivity.
This test is ok and works proper way:
public void testHello() throws Exception
{
MuleClient client = new MuleClient(muleContext);
MuleMessage result = client.send("http://127.0.0.1:8080/hello", "some data", null);
assertNotNull(result);
assertNull(result.getExceptionPayload());
assertFalse(result.getPayload() instanceof NullPayload);
//TODO Assert the correct data has been received
assertEquals("hello", result.getPayloadAsString());
}
But this tes is not ok - it fail with an connection exceptions:
public void testHello_with_Spring() throws Exception {
MuleClient client = new MuleClient("mule-config-test.xml");
client.getMuleContext().start();
//it fails here
MuleMessage result = client.send("http://127.0.0.1:8080/hello", "some data", null);
assertNotNull(result);
assertNull(result.getExceptionPayload());
assertFalse(result.getPayload() instanceof NullPayload);
//TODO Assert the correct data has been received
assertEquals("hello", result.getPayloadAsString());
}
The 'mule-config-test.xml' is used in both tests, the path for this file is ok, i checked.
This is error message I have in the end:
Exception stack is:
1. Address already in use (java.net.BindException) java.net.PlainSocketImpl:-2 (null)
2. Failed to bind to uri "http://127.0.0.1:8080/hello" (org.mule.transport.ConnectException)
org.mule.transport.tcp.TcpMessageReceiver:81
(http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/transport/ConnectException.html)
-------------------------------------------------------------------------------- Root Exception stack trace: java.net.BindException: Address already in
use at java.net.PlainSocketImpl.socketBind(Native Method) at
java.net.PlainSocketImpl.bind(PlainSocketImpl.java:383) at
java.net.ServerSocket.bind(ServerSocket.java:328)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
[10-05 16:33:37] ERROR HttpConnector [main]:
org.mule.transport.ConnectException: Failed to bind to uri
"http://127.0.0.1:8080/hello" [10-05 16:33:37] ERROR ConnectNotifier
[main]: Failed to connect/reconnect: HttpConnector {
name=connector.http.mule.default lifecycle=stop this=7578a7d9
numberOfConcurrentTransactedReceivers=4
createMultipleTransactedReceivers=true connected=false
supportedProtocols=[http] serviceOverrides= } . Root Exception
was: Address already in use. Type: class java.net.BindException [10-05
16:33:37] ERROR DefaultSystemExceptionStrategy [main]: Failed to bind
to uri "http://127.0.0.1:8080/hello"
org.mule.api.lifecycle.LifecycleException: Cannot process event as
"connector.http.mule.default" is stopped
I think the problem is in what you're not showing: testHello_with_Spring() is probably executing while Mule is already running. The second Mule you're starting in it then port-conflicts with the other one.
Are testHello() and testHello_with_Spring() in the same test suite? If yes, seeing that testHello() relies on an already running Mule, I'd say that would be the cause of port conflict for testHello_with_Spring().