WAR file deployment not connecting to MySQL - java

I made a dynamic web project in Eclipse IDE and generated a .war file to uploaded it on tomcat localhost for testing using XAMPP server
I deployed the war file in tomcat manager and all the pages are getting displayed properly.
I have made a few connections for connecting to mysql database for insertions. But the deployed does not interacts with the XAMPP phpmyadmin
I checked the username and password for connection string in my java program and made changes in config.inc.php file accordingly in phpmyadmin folder
All the database operations are being executed inside the eclipse environment but when I deploy the war file it is not executing.

Check your XAMPP Apache server configuration..
Go to, config -> phpMyAdmin(config.inc.php) and check this username & password related to Your Java Program.
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = ''
If Mysql has any different password, Change root password to empty.

Related

Does IntelliJ support remote deployment to Websphere Liberty?

This is a possible duplicate of Intellij docker with live update of EAR inside websphere, but that question is 3 years old and the answer "not supported" is maybe outdated.
Via IntelliJ IDEA (2020.3 Ultimate) on Windows 10, I want to deploy an application (EAR) into a Websphere Liberty server which is running in a docker container. This worked with traditional websphere, now we are switching to WLP. Is this possible at all?
The server is up and running. I'm perfectly able to copy the ear to the (mounted) "dropins" folder and the server picks it up, expands it and deploys it without problems.
I'm also able to attach the debugger in IntelliJ to the server and it will stop at breakpoints, it can even successfully update code ("hot swap classes").
What I did already:
I configured ports (7777,8880,9043,9443,9080) to forward 1:1 from the container to my local machine. I can successfully access at least port 9080 through a local browser.
I downloaded Websphere Liberty, Full Java EE 8 Profile, the same version as in the docker container, from IBM official website to my local hard drive, and expanded the zip.
Then I tried to follow the guide https://www.jetbrains.com/help/idea/run-debug-configuration-websphere-server.html and added a Run/Debug Configuration "Websphere Remote", I chose the expanded folder for IntelliJ for the "Application Server" configuration (I know that IntelliJ needed a local installation of Websphere for traditional version, so this may hold true for WLP as well).
I added the EAR-artifact for deployment in the Run Configuration. I copied the server name from the one inside docker and set the connection settings (localhost:9080).
The first try ("Test Connection") resulted in an error from IntelliJ: Error running 'WebSphere Application': JMX file not found: C:\[...]\wlp-javaee8-20.0.0.12\usr\servers\defaultServer\workarea\com.ibm.ws.jmx.local.address
Then I tried and copied this file from my docker container, it had the content
service:jmx:rmi://127.0.0.1/stub/[... some seemingly byte64-encoded string] to the local path. This resulted in a different error: Error connecting to the Application Server: java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is: java.net.ConnectException: Connection refused: connect
I also tried to use the content of the file com.ibm.ws.jmx.rest.address which was service:jmx:rest://localhost:9443/IBMJMXConnectorREST, (where I replaced the internal host name of the docker container by "localhost"), but that resulted in Error running 'WebSphere Application': java.net.MalformedURLException: Unsupported protocol: rest
If I start the local server on my machine (not in docker), connection works and deployment too. But this is not my aim.
PS: My server.xml contains <applicationMonitor updateTrigger="mbean"/>.

insert a file into postgres

How do I insert a file that resides in windows in c:\temp\sample.txt
I have tried
insert into lob_file VALUES (5, pg_read_file('c://temp//sample.txt')::BYTEA);
and got
ERROR: could not start file c://temp//sample.txt. No such file or
directory.
Is data base running locally or on a Windows server and you have moved the file to the server. See Docs
The functions shown in Table 9.94 provide native access to files on
the machine hosting the server. Only files within the database cluster
directory and the log_directory can be accessed unless the user is
granted the role pg_read_server_files. Use a relative path for files
in the cluster directory, and a path matching the log_directory
configuration setting for log files.

What is the correct procedure for adding SQL Server JDBC to GlassFish 3.1.2

I am setting up a test GlassFish Server to learn NetBeans, Java, GlassFish web application development. I was able to do a basic deployment successfully and am moving on to databases.
I am trying to set up a MS SQL Server connection pool in the GlassFish admin. After configuring the datasource as javax.sql.Datasource and setting the properties, it fails to successfully ping the connection.
When I try to ping the connection, I get this error
Ping Connection Pool failed for SQLDB. Class name is wrong or classpath is not set for :
com.microsoft.sqlserver.jdbc.SQLServerDataSource
It looks like the .jar file isn't being loaded. I have placed the sqljdbc4.jar in the glassfish\modules folder.
What is the correct process for setting up a JDBC connection pool for SQL Server?
In case you are using JRE 7 : use JDBC41
in case you are using JRE 8 : use JDBC42
Unzip the exe from the following link : https://www.microsoft.com/en-us/download/confirmation.aspx?id=54671
Paste the jar in the lib folder of glassfish .
Once done define property under connection pool as URL and pass full qualified connection name as : jdbc:sqlserver://localhost\MSSQLSERVER:1433;databasename=AdventureWorks2016;integratedSecurity=true

Eclipse - Could not publish server configuration for Tomcat8.0 server at localhost

I have created some example web service methods and trying to publish in my localhost with Tomcat v8.0. I use Eclipse Java EE IDE for Web Developers with Mars version 4.5.0.
I configured the server Tomcat v8.0. I got the configured server in Eclipe's Servers list. I Start the server. But Eclipse prompts saying
Publishing to tomcat v8.0 Server at localhost..." has encountered a problem.
And the error details shows that Multiple context have a path for /HelloWorldServlet and /com.vogeila.jersy.first. These are the servlet projects I created in my workspace.
You can refer this screen shot:
I followed this answer.
"Server Tomcat v7.0 Server at localhost failed to start" without stack trace while it works in terminal
But It didn't work for my case.
Share your ideas.
The prompted message helped me. The Server.xml file under Servers has multiple entries of <Context> tag. I deleted everything by leaving only one entry. It worked for me. 
Delete Existing tomcat server...
Then add new server.. its work for me

Location of log file in the server

I have created logs for my project in a log file. I have provided the location of log file as 'logs/LogFile.log' in the java code. When run on a local server(Tomcat or Websphere), a new folder named 'logs' is created in the classpath of the server and i can find the 'LogFile.log' with logs in it.
Now my project is converted to EAR and it is up in the Dev Server. Where will my log file be created? How can i see those logs?
For a local server, the logs will be appended in the destined log file, which will be in the server installed directory or a remote user created directory.
In case of a remote server, say Unix server, the logs will be generated in the specified location inside the server. We need to login to the unix server via putty or Techtia and can view the logs in the specified locations.

Categories