I get generic error occurred in GDI+ for selenium webdriver.It was working fine still yesterday,But suddenly I get this error.
public string TakeScreenshot(IWebDriver driver, string SnapFolderPath, string TCID, string KeyFunction)
{
try
{
// driver.Manage().Window.Maximize();
ITakesScreenshot ssdriver = driver as ITakesScreenshot;
Screenshot screenshot = ssdriver.GetScreenshot();
string filePath = testReport + "\\" + TCID + "_" + KeyFunction + "_" + GetDateTimeforFilePath() + ".png";
screenshot.SaveAsFile(filePath, ImageFormat.Png);
return filePath;
}
catch (Exception ex)
{
return string.Empty;
}
}
Resolved this Issue .We need to give full access permission to the folder where we want to store the image.If we don't give full permission we get this error
Related
I have a requirement that I need to convert xsd file to POJO files. While using tomcat I didnot face any issue but when I am using weblogic I am getting error
Can't find resource for bundle java.util.PropertyResouceBundle,key JAXPSupportedProperty
File tmpDir = util.createTempPOJODirectory();
String xsdFilePath = convertToXSD(xmlResponse, tmpDir); // The xml response will be converted to XML file and then converted to XSD file
if (StringUtils.isNotBlank(xsdFilePath)) {
log("XSD location ::" + xsdFilePath + " and output location :: " + tmpDir);
// Setup schema compiler
SchemaCompiler sc = XJC.createSchemaCompiler();
sc.forcePackageName("");
// Setup SAX InputSource
File schemaFile = new File(xsdFilePath);
InputSource is = new InputSource(schemaFile.toURI().toString());
// is.setSystemId(schemaFile.getAbsolutePath());
// Parse & build
sc.parseSchema(is);
log("after parsing and building");
log("sc :: " + sc);
S2JJAXBModel model = null;
try {
model = sc.bind();
}
catch (Exception e1) {
log("Exception :: " + ExceptionUtils.getFullStackTrace(e1));
}
log("model :: " + model);
try {
JCodeModel jCodeModel = model.generateCode(null, null);
jCodeModel.build(tmpDir);
log("generation POJO's is success");
return "POJO are created under " + tmpDir + " successfully.";
}
catch (IOException e) {
log("unable to generate POJO's");
log("IOException occurs :: " + ExceptionUtils.getFullStackTrace(e));
}
catch (Exception e) {
log("Exception occurs :: " + ExceptionUtils.getFullStackTrace(e));
}`
For this I have used below jars :-
xsd-gen-0.2.1.jar
xom-1.2.5.jar
wiztools-commons-lib-0.4.1.jar
jaxb-xjc-2.2.11.jar
jaxb-core-2.2.11.jar
cli-7.jar
Thanks guys, I have resolved this issue by removing jaxb jars.
I am new to linux environment.I have a web application which is running fine in windows environment and it is developed using play framework.Now we want to move our application from windows to linux. Here issue is,while uploading files i'm getting internal server error.I have given permissions as 777 for folder.Even the controller doesn't invoke the method,how to solve it?I am unable to find where the error goes,For all help thanks in advance.
Error is :
Controller action :
#helper.form(action =routes.HoForms.uploadHoFormsByHeadOffice(),'enctype -> "multipart/form-data" ,'id -> "shiftSummaryForm")
{
}
In routes file :
POST /HeadOfficeForms/upload controllers.HoForms.uploadHoFormsByHeadOffice()
Controller method :
public static Result uploadHoFormsByHeadOffice() throws Exception {
Logger.info("#C HoForms -->> uploadHoFormsByHeadOffice() -->> ");
}
Upload method() :
public static Result uploadHoFormsByHeadOffice() throws Exception {
final String basePath = "/var/www/html/pdfs/";
Date date = new Date();
DateFormat format = new SimpleDateFormat("dd-MM-yyyy");
String startDate = format.format(date);
date = format.parse(startDate);
play.mvc.Http.MultipartFormData body = request().body()
.asMultipartFormData();
String formType = body.asFormUrlEncoded().get("formType")[0];
FilePart upFile = body.getFile("hoFormFiles");
String fileName = upFile.getFilename();
try {
File ftemp = new File(basePath + "HeadOfficeForms/" + formType
+ "");
ftemp.mkdirs();
String filePathString = "HeadOfficeForms/" + formType + "/"
+ fileName;
File f1 = new File(ftemp.getAbsolutePath() + "/" + fileName);
File file = upFile.getFile();
file.setWritable(true);
file.setReadable(true);
f1.setWritable(true);
f1.setReadable(true);
Files.copy(file.toPath(), f1.toPath(), REPLACE_EXISTING);
HoForm.create(fileName, date, formType, filePathString);
flash("success", fileName + " Has been Successfully Uploaded");
} catch (IOException e) {
e.printStackTrace();
}
return redirect(routes.HoForms.showHoFormUploadPage());
}
I am trying to connect MS SQL database using JDBC in Android Studio 1.1.0. I am refering to this site for connecting. Here is my code for connecting:
import android.annotation.SuppressLint;
import android.os.StrictMode;
import android.util.Log;
import java.sql.SQLException;
import java.sql.Connection;
import java.sql.DriverManager;
public class ConnectionClass {
String ip = "IP_Address(for eg.192.168.5.60)";
String classs = "net.sourceforge.jtds.jdbc.Driver";
String db = "Andro";
String un = "username";
String password = "pwd";
#SuppressLint("NewApi")
public Connection CONN() {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.permitAll().build();
StrictMode.setThreadPolicy(policy);
Connection conn = null;
String ConnURL = null;
try {
Class.forName(classs);
/* ConnURL = "jdbc:jtds:sqlserver://" + ip + "/"
+ "databaseName=" + db + ";user=" + un + ";password="
+ password + ";";*/
ConnURL= "jdbc:jtds:sqlserver://IP_Address(for eg.192.168.5.60)/databaseName=Andro;user=username;password=pwd;";
conn = DriverManager.getConnection(ConnURL);
} catch (SQLException se) {
Log.e("ERRO", se.getMessage());
} catch (ClassNotFoundException e) {
Log.e("ERRO", e.getMessage());
} catch (Exception e) {
Log.e("ERRO", e.getMessage());
}
return conn;
}
}
Calling connectionClass.CONN() function like this:
#Override
protected String doInBackground(String... params) {
if(userid.trim().equals("")|| password.trim().equals(""))
z = "Please enter User Id and Password";
else
{
try {
Connection con = connectionClass.CONN();
if (con == null) {
z = "Error in connection with SQL server";
} else {
heading.setText("u"+con.toString());
String query = "select * from Usertbl where UserId='" + userid + "' and Password='" + password + "'";
Statement stmt = con.createStatement();
heading.setText("After statement");
ResultSet rs = stmt.executeQuery(query);
// heading.setText(rs.getString(1));
z = "under else block";
if(rs.next())
{
z = "Login successfull";
isSuccess=true;
}
else
{
z = "Invalid Credentials";
isSuccess = false;
}
}
}
catch (Exception ex)
{
isSuccess = false;
z = "Exceptions";
}
}
return z;
}
I just want to connect database with android studio. The error shows like this
Please suggest any solution or any hint to perform connectivity.
The error is because you are trying to set the text value of a textview field from the Asynchronous task.
Over here : heading.setText("u"+con.toString());
Just remove this and the error might be solved.
Also note that Asynchronous task cannot set the value of the activity component like EditText,Textview or even a button field.
i had also been trying to connect ms sql database from android studio, succeeded last night using the given link
https://www.youtube.com/watch?v=HRF8NpoFteg
note that jtds-1.2.7 must be downloaded, latest versions might not work for real mobile (i was facing this problem for one week the database connected on emulator but not on real mobile).
further after including jtds-1.2.7 gradle build might give an error of instant run kindly uncheck instant run from file -> settings -> instant run -> uncheck enable instant run.
hope it hepls!!!
Not Found Exception some times while starting the MaagementEventWatcher
My code sample is given below :
try
{
string scopePath = #"\\.\root\default";
ManagementScope managementScope = new ManagementScope(scopePath);
WqlEventQuery query =
new WqlEventQuery(
"SELECT * FROM RegistryKeyChangeEvent WHERE " + "Hive = 'HKEY_LOCAL_MACHINE'"
+ #"AND KeyPath = 'HARDWARE\\DEVICEMAP\\SERIALCOMM'");
registryWatcher = new ManagementEventWatcher(managementScope, query);
registryWatcher.EventArrived += new EventArrivedEventHandler(SerialCommRegistryUpdated);
registryWatcher.Start();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
if (registryWatcher != null)
{
registryWatcher.Stop();
}
}
Exception:
Not found
at System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode)
at System.Management.ManagementEventWatcher.Start()
at MTTS.LabX.RockLog.AppService.USBMonitor.AddRegistryWatcherHandler()]
Note : I checked in the registry,folder and files are found.
ManagementException "Not found" is thrown when there is not match in the WQL query. Maybe you have specified the wrong KeyPath or the KeyPath is no longer available.
Actually the problem was, In the laptops(pcs having the serial ports so COM1 port) when starting first time SERIALCOMM folder not created in the Registry because,
basically we plugged the device in the USB port or serial port the SERIALCOMM folder will create, in this case we are using WMI to get the connected comm ports from the registry.
in some laptops no USB ports and Serial Ports are connected So, the SERIALCOMM folder not created, In that time we are accessing this registry path we get the error.
so the Solution is,
try
{
string scopePath = #"\\.\root\default";
ManagementScope managementScope = new ManagementScope(scopePath);
string subkey = "HARDWARE\\DEVICEMAP\\SERIALCOMM";
using (RegistryKey prodx = Registry.LocalMachine)
{
prodx.CreateSubKey(subkey);
}
WqlEventQuery query = new WqlEventQuery(
"SELECT * FROM RegistryKeyChangeEvent WHERE " +
"Hive = 'HKEY_LOCAL_MACHINE'" +
#"AND KeyPath = 'HARDWARE\\DEVICEMAP\\SERIALCOMM'");
registryWatcher = new ManagementEventWatcher(managementScope, query);
registryWatcher.EventArrived += new EventArrivedEventHandler(SerialCommRegistryUpdated);
registryWatcher.Start();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
if (registryWatcher != null)
{
registryWatcher.Stop();
}
}
I am working with a Windows Phone Schedule Agent and I am trying to update the picture name after sync the problem is that I am getting an invalid cross exception when on this function at line "BitmapImage bmp = new BitmapImage();" and really don’t understand why.
void UpdateSyncPictureName(int AsyncStatus, int AticketID, int AsyncID, int ApictureID, int TsyncStatus = 0, int TsyncID = 0)
{
string filename = AsyncStatus + "-" + AticketID + "-" + AsyncID + "-" + ApictureID;
using (IsolatedStorageFile ISF = IsolatedStorageFile.GetUserStoreForApplication())
{
if (ISF.FileExists(filename))
{
BitmapImage bmp = new BitmapImage();
using (IsolatedStorageFileStream isoStream =
ISF.OpenFile(filename, System.IO.FileMode.Open))
{
bmp.SetSource(isoStream);
}
ISF.DeleteFile(filename);
WriteableBitmap Wbmp = new WriteableBitmap(bmp);
using (IsolatedStorageFileStream isoStream =
ISF.OpenFile(TsyncStatus + "-" + AticketID + "-" + TsyncID + "-" + ApictureID, System.IO.FileMode.Create))
{
Extensions.SaveJpeg(Wbmp, isoStream,
Wbmp.PixelWidth,
Wbmp.PixelHeight,
0, 100);
}
}
}
}
The issue arises from the fact that BitmapImage cannot be instantiated outside of the UI thread. You can fix this issue by wrapping your calls in a Dispatcher Invoke call.
However, you need to make sure that you call NotifyComplete correctly. As such you may need to put NotifyComplete in the Dispatcher call.
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
UpdateSyncPictureName(...);
NotifyComplete();
});