Why is my VS Code breakpoint (php) only working in one folder and not in others? - xdebug

I am using VS Code to debug a php file. I have installed the PHP Debug extension and configured PHP to debug using XDebug. Server is Apache (using Xampp).
The file I want to debug is in .../htdocs/Nuurd and breakpoints are hit. But when I open another folder and try to debug a file in (for instance) .../htdocs/Test it cannot be debugged, i.e. the program is finished without stopping at any breakpoint (it runs through).
Why does it depend on the folder and what settings are required to make xdebug work on any folder?

The folder .vscode with launch.json was missing.
I copied it from another folder and that solved the problem (hopefully forever).

Related

FileNotFoundError: [Errno 2] No such file or directory selenium\\webdriver\\remote\\getAttribute.js'

I'm working with selenium. The script is in :
C:\Users\User\Desktop\Data Analytics Arg\Proyectos\datademia\Py_install\py_ejemplo.py . Venv is activated and chromedriver.exe is in C:\Users\User\Desktop\Data Analytics Arg\Proyectos\datademia\Py_install\chromedriver.exe
The script runs perfectly. Then I created an only .exe-file via terminal :
pyinstaller --add-data "chromedriver.exe;." --windowed --onefile py_ejemplo.py
Folders are created correctly (build and dist). The .exe file (py_ejemplo.exe) was created, but when I try to run it, I get this message:
I've been looking and still can't solve it... I've tried these solutions :
filenotfound
but didn't work for me...Could someone help me? I donĀ“t know what's wrong...
Thanks in advance
I got the same problem but I was working with Firefox and geckodriver.
In my case, I copied the selenium folder from the virtual environment to the dist folder and it worked.
There are a few things you should ensure when packing a script with pyinstaller build with selenium web driver.
It may require to add driver executable when building. I.e. chromedriver.exe
It may also require to add some package files related to selenium such as getattributes.js file when building. It was required at my project.
pyinstaller will extract those files to temp folder in AppData for windows users. So in your code, your relative paths may require to be resolved with a sample function as below (if you are running your code in vs code or you are running through pyinstaller executable the paths should be resolved by function).
For item 1 and 2, you can use --add-binary and --add-data features of pyinstaller for each of them. It is also possible to do this in *.spec file with add-files list, following your first running of pyinstaller (see this explanation) I preferred command-line option as below.
pyinstaller ./app.py --onefile --noconsole --add-binary "./driver/chromedriver.exe;./driver" --add-data "C:\Users\YOUR_USER_NAME\.conda\pkgs\selenium-3.141.0-py38h2bbff1b_1000\Lib\site-packages\selenium\webdriver\remote;selenium\webdriver\remote"
For item 3, to resolve relative paths in your source code, you can use below function in related places (for example when accessing chromedriver.exe)
def resource_path(relative_path):
try:
base_path = sys._MEIPASS
except Exception:
base_path = os.path.dirname(__file__)
return os.path.join(base_path, relative_path)
Use above function once you need to access packaged executables and files in your source code. In below example, my chromedriver is inside driver folder in my workspace. But when it is accessed through pyinstaller executable, it will be extracted to temp folder in AppData, yet function will access it through sys._MEIPASS variable set by pyinstaller.
driver = webdriver.Chrome(executable_path = resource_path('./driver/chromedriver.exe'))
Hope it works.

Unable to open files in VS Code via terminal over SSH

I have a windows10 machine using Remote-SSH to interface with repo on an Ubuntu18.04 system.
Until about a month ago I was able to open files using VS Code's integrated terminal.
Now entering code ./myFile.txt returns immediately. No error, no file opened.
If a non existent file is opened code ./myNonExistentFile.txt the same thing happens.
Running code ./myFile.txt into an entirely local setup (no Remote-SSH) works; the file opens in VS Code.
Remote-SSH is otherwise working.
Has anybody else noticed this behavior?
#Max Lobur may be right. If not, you still feel free to restart the VS Code.
It's expected. You probably don't have vs-code on a remote machine, nor have forwarded the X-server thus nothing will happen when you run this.
I suggest mounting the remote file system to local machine and run code . locally: https://www.digitalocean.com/community/tutorials/how-to-use-sshfs-to-mount-remote-file-systems-over-ssh
As a last resort, try deleting your server's .vscode-server folder, which is located at your home folder, as detailed in https://github.com/microsoft/vscode-remote-release/issues/1443

Java FX JAR File can not find SQL Server Driver

I fought for 8 hours yesterday getting my Java FX (11) Standalone JAR to work at all. I finally did, and now when I run it via java -jar myjar.jar (with path info for fx components), it at least "works" inasmuch as I can see my "own application's" error messages and message boxes lol.
This app needs to connect to SQL Server. It works FINE in IDE (IntelliJ). For JAR, I did not include the SQL Server driver as it is signed. No big deal - figure I'd just deploy it too and put it in the path. However, the JAR file can not "see" the driver (or the class - not sure) when run. Here is the info:
SQL Server driver is mssql-jdbc-8.2.2.jre11.jar
My connection Code is:
connection = DriverManager.getConnection(connectString); and connectString = "jdbc:sqlserver://localhost:1433;database=mydatabase;userName=myuser;password=mypword"
Again - this WORKS FINE in IDE. However, run from jar, it gets "java.sql.SQLException: No suitable driver found for jdbc:sqlserver://localhost:1433;database=mydatabase;userName=myuser;password=mypword"
I have put the mssql-jdbc-8.2.2.jre11.jar into the same directory as the jar. I have included it in the MANIFEST.MF with Class-Path: mssql-jdbc-8.2.2.jre11.jar and also tried it in a "lib" subdirectory from the jar file with Class-Path: /lib. Nothing Works! I just keep getting the "no suitable driver" error. The full manifest file looks like:
Manifest-Version: 1.0
Class-Path: /lib
Main-Class: com.product.Launcher
Here is the full call from command line that actually launches the app: java --module-path C:/Users/KMatson/Documents/JetBrains/openjfx-11.0.2_windows-x64_bin-sdk/javafx-sdk-11.0.2/lib/ --add-modules javafx.controls,javafx.fxml,javafx.graphics -jar myjar.jar This does run the app, but as soon as app tries to connect to SQL, I get the error.
Also tried the old-style Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver") to no avail even thought it should not be necessary, and isn't needed run from IDE.
This is driving me crazy and has taken WAY more time than it should. I'm new to all this, and hope it is something simple I am overlooking or unaware of. Any help MUCH appreciated.
OK - here is the (intermediate) answer that worked for me. Apparently, having the "--module path" declaration in the cmd line was overriding the Class-path in the MANIFEST somehow. Either that or something was - dunno - didn't think i had a "modular" project. I'm not building from Maven, and module-info is not active.
Anyway - I simply put the driver jar in the "module path" I use from cmd, and it worked. I'm now trying to figure out how to make this thing "double clickable" so i don't have to issue from cmd line or use a batch file.

Jenkins/Windows - Launch TestNG suite from .bat

Stackoverflow helped me a lot to reach that point but now I'm completely stuck, here is my problem :
I'm currently developing several tests to check a website. I code with Java in Eclipse, using testNG plugin with ReportNG for report, all of this using Windows 7 pro.
My tests work, and my report is well generated, so now I have to put it on Jenkins for my company so they will run my tests every X hours.
In order to launch my tests, I have made a file, named Run.bat, which runs the Java code, I tested it and it works, here is the code :
Run.bat
set classpath=blex_test_v1\bin;blex_test_v1\lib\*
java org.testng.TestNG blex_test_v1\blex_test_v1.xml
I now try to launch the tests on Jenkins, creating a new job and configuring it with the build section :
Run.bat
And this is my problem, I've tried everything (relative path, only the name of the file etc...) I always get this error :
java.io.IOException: Cannot run program "cmd" (in directory "/var/jenkins_home/jobs/blex_functional_test/workspace"): error=2, No such file or directory
So I checked the Jenkins workspace but my Run.bat is in it :
Workspace
I have read that Jenkins is in Linux so it might cause problem with bat files, so I tried to create a script but I didn't succeed either ..
So my question is : How can I run my test on Jenkins using my file Run.bat ? What am I doing wrong here ?
Thanks a lot !
Finally I can add an answer :
Jenkins is installed on a Unix machine so you can't run a bat file, it has to be a bash script.
To create a bash script, refer here.
Then you have to make sure that the plugin Xvfb is installed (and works) on the computer where Jenkins is installed.
I use testNG with reportNg and it doesn't work with the last firefox version so you I use firefox v34.0.5 and this version must be installed also on the Jenkins computer.
If you want to open the report after the execution, install another plugin and configure it (report HTML or something like that)
God it took me about a week but it's good to see it working !

Run .bat as a Windows Service

I'm here again with another case that is getting me out my mind.
So, this is happening, I'm trying to run an executable java class(.jar) as a Windows Service, and all my attempts failed so far. To make it a little easier, I turned my jar into a batch file, wich only executes the jar in background, here is the code:
start "" javaw -jar C:\LocalService.jar
The batch works fine. However I have tried to install this batch as a service by using the next line in cmd:
sc create "LocalService" binPath= "C:\LocalService.bat"
The Service installs correctly, but as soon as I try to start it, it pops up an error (The code error is 1053, says something about the service did not start correctly)
Also, I have try with a software called NSSM (non-sucking service manager) It installs fine too, but the service does not start either.
Do you guys know what am I missing?
By the way, I'm doing all this on Windows 7 Professional.
Thanks!
thanks for your comments
Both tools didnt work for me, sadly. However I was able to do it with a software called Java Service Wrapper. This is not a free software, so I needed to buy a license to get it to work.
The steps were simple:
1.-Create a folder with the name of the service, then inside add 4 folders: lib,bin,logs,conf
2.-On the lib folder you have to copy your jar and also the wrapper.jar and wrapper.dll (these last two are in the zip you download from the website)
3.-Copy 4 files to the bin folder: InstallApp-NT.bat.in, App.bat.in, UnintstallApp-NT.bat.in and wrapper.exe (this last one is the one that defines your license, if you can get a file wrapper.exe from somebody else who had paid a license it will work fine. These file also came in the zip from the website) Remove the .in from the batch files
4.-The most tricky step is this: You have to copy from the wrapper's folder called conf a file called wrapper.conf.in Remove the .in extension and edit it with a tex editor. The most important lines you have to edit are:
wrapper.java.command=C:\Program Files (x86)\Java\jre7\bin\java //Specify JRE Path. Will work with eviroment variable
wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperJarApp //Choosing this class means your are using a .jar file to execute when the service starts
wrapper.java.classpath.1=C:\LocalService\lib\wrapper.jar //This one is constant.
wrapper.java.classpath.2=C:\LocalService\lib\LocalService.jar //This is the path to your executable jar
wrapper.java.library.path.1=C:\LocalService\lib //Path to your own lib folder (the you created at the begining)
wrapper.app.parameter.1=C:\LocalService\lib\LocalService.jar // again the path to your jar
Then just execute the InstallApp-NT.bat and start the service and your are done
It worked to me with absolute paths, however according to documentation it will work fine with relative path too.
This is how I solved my problem and I hope someone with the same issue will find this helpful
See you next time!

Resources