Any other option to deploy in jboss server ither than hot deployment? - deployment

I want to know what are the methods to deploy in jboss server other than hot deployment.

Get the client and the builder to build plans:
ModelControllerClient client = ModelControllerClient.Factory.create(host, port);
ServerDeploymentManager manager = ServerDeploymentManager.Factory.create(client);
DeploymentPlanBuilder builder = manager.newDeploymentPlan();
And the method to execute any kind of operation (here some ones are implemented):
public DeployementActionStatus execute(Type deploy) throws IOException
{
List<Throwable> errors = new LinkedList<Throwable>();
DeployementActionStatus status = DeployementActionStatus.SUCCESS;
switch (deploy)
{
case DEPLOY:
if (archive != null)
{
plan = builder.add(archive).deploy(archive.getName()).build();
}
else
{
return DeployementActionStatus.FAILURE;
}
break;
case REDEPLOY:
{
if (archive != null)
{
plan = builder.redeploy(archive.getName()).build();
}
else
{
return DeployementActionStatus.FAILURE;
}
break;
}
case UNDEPLOY:
{
plan = builder.undeploy(getApplicationName()).build();
break;
}
case REMOVE:
{
plan = builder.remove(getApplicationName()).build();
break;
}
default:
plan = null;
break;
}
if (plan == null)
{
throw new IllegalStateException("Invalid type: " + deploy);
}
if (plan.getDeploymentActions().size() > 0)
{
try
{
final ServerDeploymentPlanResult planResult = manager.execute(plan).get();
// Check the results
for (DeploymentAction action : plan.getDeploymentActions())
{
final ServerDeploymentActionResult actionResult = planResult.getDeploymentActionResult(action
.getId());
final ServerUpdateActionResult.Result result = actionResult.getResult();
switch (result)
{
case FAILED:
case NOT_EXECUTED:
case ROLLED_BACK:
{
log.error(actionResult.getDeploymentException());
if (actionResult.getDeploymentException().getMessage() != null
&& actionResult.getDeploymentException().getMessage().contains("Duplicate"))
{
status = DeployementActionStatus.FAILURE_ALREADY_DEPLOYED;
}
else
{
status = DeployementActionStatus.FAILURE;
}
break;
}
case CONFIGURATION_MODIFIED_REQUIRES_RESTART:
// Should show warning
break;
default:
break;
}
}
}
catch (InterruptedException e)
{
errors.add(e);
status = DeployementActionStatus.FAILURE;
}
catch (ExecutionException e)
{
errors.add(e);
status = DeployementActionStatus.FAILURE;
}
catch (Exception e)
{
if (e instanceof RuntimeException)
{
status = DeployementActionStatus.CONNECTION_TO_SERVER_FAILED;
}
}
}
return status;
}

Deploying is considered hot only when JBoss is running. If you don't want hot deployment you can turn off deployment scanner [1] or stop JBoss and deploy the artifact.
[1] https://community.jboss.org/wiki/ConfiguringTheDeploymentScannerInConfjbossSystemxml

Related

Unable to catch Google cloud storage exception

I have a function in my flutter app to download a file from google cloud and store it locally. This function works for existing files, but when I try to download a non existent file, it fails to catch the 'file not found' exception. I'm obviously doing something wrong, but I can't figure it out!
bool downloadFile({required String localFile, required String remoteFile}) {
try {
final storageRef = FirebaseStorage.instance.ref();
final remoteFileRef = storageRef.child(remoteFile);
final file = File(localFile);
final downloadTask = remoteFileRef.writeToFile(file);
downloadTask.snapshotEvents.listen((taskSnapshot) {
switch (taskSnapshot.state) {
case TaskState.running:
print('TaskState.running');
break;
case TaskState.paused:
print('TaskState.paused');
break;
case TaskState.success:
print('TaskState.success');
break;
case TaskState.canceled:
print('TaskState.canceled');
break;
case TaskState.error:
print('TaskState.error');
break;
}
});
//} on firebase_core.FirebaseException catch (error) {
} catch (e) {
print("########### got ex");
return false;
}
return true;
}

Unhandled Exception: Unhandled error 'package:bloc/src/transition.dart': Failed assertion: line 27 pos 16: 'nextState != null': is not true

I am getting this error while updating a value in state . please suggest me how to resolve it. what is best way to update current state while working with BLOC in flutter. My BLOC class code added. This Error Occurs onItemClick Event.
onItemClicked: (e) async* {
try {
yield walmartState;
List<CommonDataObj> dataList =
walmartItemChanged(e.index, e.walmartList);
yield state.copyWith(walmartList: some(right(dataList)));
LinkedHashMap<String, RequestData> reqMap = state.requestDataMap;
dataList.forEach((element) {
if (element.isSelected) {
RequestData data = RequestData(element.intStoreId, element.intId);
if (reqMap.containsKey(e.key)) {
reqMap.update(e.key, (value) => data);
} else {
reqMap.putIfAbsent(e.key, () => data);
}
} else {
if (reqMap.containsKey(e.key)) {
var value = reqMap[e.key];
if (value.int_product_id == element.intId &&
value.int_store_id == element.intStoreId) {
reqMap.remove(e.key);
}
}
}
});
yield state.copyWith(requestDataMap: reqMap);
yield state.copyWith(requestDataMap: reqMap);
print('State request Data Map : $reqMap');
} catch (e) {
print(e);
}
try {
bool selected = false;
e.currentDataMap.forEach((key, value) {
for (var item in value) {
if (item.isSelected) {
selected = true;
break;
}
}
});
int curQuantity = state.currentQuantity;
if (curQuantity == 0) {
curQuantity = curQuantity + 1;
} else if (curQuantity > 0 && !selected) {
curQuantity = 0;
}
var newState = state.copyWith(currentQuantity: curQuantity);
yield newState;
} catch (e) {
print(e);
}
}

Flutter BLoC:Global exception handler for mapEventToState

I use felangel's bloc library. I fetch data by using a repository in mapEventToState method .If the repository throws an exception, I want to catch it on a global exception handler.
#override
Stream<MyState> mapEventToState(Event event) async* {
if (event is MyEvent) {
try {
var data = await repository.fetchData();
yield MyState(data);
} catch (e) {
//There may be many exceptions
}
}
}
Is there any way catch exceptions without try-catch blocks and what is best practice?
You could write a util for managing errors. I wrote something for this. It could be an idea for you.
static String handleError(Error error) {
String errorDescription = "";
if (/*error is SomethingError*/) {
switch (error.type) {
case ErrorType.CANCEL:
errorDescription = "ErrorType.CANCEL";
break;
case ErrorType.CONNECT_TIMEOUT:
errorDescription = "ErrorType.CONNECT_TIMEOUT";
break;
case ErrorType.DEFAULT:
errorDescription = "ErrorType.DEFAULT";
break;
case ErrorType.RECEIVE_TIMEOUT:
errorDescription = "ErrorType.RECEIVE_TIMEOUT";
break;
case ErrorType.RESPONSE:
switch (error.response.toString()) {
case "usernamePasswordFail":
errorDescription = "usernamePasswordFail";
break;
default:
errorDescription = "errorDescription";
}, ${error.response.data ?? ''}";
break;
}
break;
case ErrorType.SEND_TIMEOUT:
errorDescription = "ErrorType.SEND_TIMEOUT";
break;
}
} else {
errorDescription = "somethingElseError";
}
return errorDescription;
}

SOAP service exception after second call

I created a SOAP service that fetches some data from a remote server.
After second call I always get an exception:
stackTrace: org.w3c.dom.DOMException: WRONG_DOCUMENT_ERR: A node is used in a different document than the one that created it.
Any ideas what could be wrong?
function getInstance () {
return LocalServiceRegistry.createService('SaveNewCustomerService', new SaveNewCustomerServiceObject());
}
function SaveNewCustomerServiceObject() {};
SaveNewCustomerServiceObject.prototype.initServiceClient = function() {
this.webReference = webreferences.CustomerWS;
return this.webReference.getDefaultService();
}
SaveNewCustomerServiceObject.prototype.createRequest = function(svc, params) {
return params;
}
SaveNewCustomerServiceObject.prototype.execute = function(svc, requestObject) {
var customerRequestObjTest = new webreferences.CustomerWS.SaveNewCustomer();
if (requestObject != null) {
setObj(); //reduced
}
var result;
try{
result = svc.serviceClient.saveNewCustomer(customerRequestObjTest);
var a =result;
}catch(ex){
var e = ex; //
if(e.faultString == "Import error"){
log.info("Import error" + e.faultDetail);
}else{
log.info(e.faultDetail);
}
}
return result;
}
SaveNewCustomerServiceObject.prototype.parseResponse = function(svc, responseObject) {
return responseObject;
}

Magento 2 - new inscription newsletter error (no such entity with customerId = 0)

I always have this error when I try to register to newsletter in Magento 2. The error is:
No such entity with customerId = 0
If I try to add it directly from database, it works perfectly.
The function is :
vendor/magento/module-newsletter/Model/Subscriber.php
public function subscribe($email)
{
$this->loadByEmail($email);
if (!$this->getId()) {
$this->setSubscriberConfirmCode($this->randomSequence());
}
$isConfirmNeed = $this->_scopeConfig->getValue(
self::XML_PATH_CONFIRMATION_FLAG,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
) == 1 ? true : false;
$isOwnSubscribes = false;
$isSubscribeOwnEmail = $this->_customerSession->isLoggedIn()
&& $this->_customerSession->getCustomerDataObject()->getEmail() == $email;
if (!$this->getId() || $this->getStatus() == self::STATUS_UNSUBSCRIBED
|| $this->getStatus() == self::STATUS_NOT_ACTIVE
) {
if ($isConfirmNeed === true) {
// if user subscribes own login email - confirmation is not needed
$isOwnSubscribes = $isSubscribeOwnEmail;
if ($isOwnSubscribes == true) {
$this->setStatus(self::STATUS_SUBSCRIBED);
} else {
$this->setStatus(self::STATUS_NOT_ACTIVE);
}
} else {
$this->setStatus(self::STATUS_SUBSCRIBED);
}
$this->setSubscriberEmail($email);
}
if ($isSubscribeOwnEmail) {
try {
$customer = $this->customerRepository->getById($this->_customerSession->getCustomerId());
$this->setStoreId($customer->getStoreId());
$this->setCustomerId($customer->getId());
} catch (NoSuchEntityException $e) {
$this->setStoreId($this->_storeManager->getStore()->getId());
$this->setCustomerId(0);
}
} else {
$this->setStoreId($this->_storeManager->getStore()->getId());
$this->setCustomerId(0);
}
$this->setStatusChanged(true);
try {
$this->save();
if ($isConfirmNeed === true
&& $isOwnSubscribes === false
) {
$this->sendConfirmationRequestEmail();
} else {
$this->sendConfirmationSuccessEmail();
}
return $this->getStatus();
} catch (\Exception $e) {
throw new \Exception($e->getMessage());
}
}