start spring boot app installed in a server from another machine - java

I installed my spring boot application in another server (linux machine) with the following run jar :
java -jar myapp.jar --spring.profiles.active=dev
--spring.config.location=file:/opt/myapp/conf/application.yml
where in my application.yml , i defined the port 8081 which is available, with a context root myApp.
The start of the jar is going well, the DB connected, the app started with the profile dev, in port 8081 and with context myApp properly.
But when i tried to connect from other machine http://serverIP:8081/myApp , the browser sham me ERR_CONNECTION_TIMED_OUT and no adress exist with this name.
i tried to run the app in my machine and i can access with localhost.
I don't know what is the problem, maybe i'm missing somthing.
I also verified the port and it's open, the ping with ip server was responding also.
Maybe there are other conf that i missed ?
UPDATE:
i followed this link stackoverflow.com/questions/29885274/… , with the telnet serverIP 8081 told me no connection, so as the link explain that tomcat is not correctly connected to the ip chossen, in application.xml i added server.adress = serverIP, and the same problem shown

Related

Cannot load keystore from system environment

I have a simple spring boot application running on HTTPS with SSL enabled
application.properties
server.port=8443
server.ssl.key-store=${SERVER_KEYSTORE}
server.ssl.key-store-password=${SERVER_KEYSTORE_PASSWORD}
where SERVER_KEYSTORE and SERVER_KEYSTORE_PASSWORD are system env variables
I generate a jar using mvn clean package and then run the executable jar. But I get the following error
***************************
APPLICATION FAILED TO START
***************************
Description:
The Tomcat connector configured to listen on port 8444 failed to start. The port may already be in use or the connector may be misconfigured.
Action:
Verify the connector's configuration, identify and stop any process that's listening on port 8444, or configure this application to listen on another port.
I have confirmed that port 8443 is not in use by any application.
Now, when I rewrite application.properties as
server.port=8443
server.ssl.key-store=/etc/ssl.keystore
server.ssl.key-store-password=secret
The application runs fine on port 8443 with HTTPS. But I don't want to have the path and password part of my codebase.
I even tried specifying the complete path to the env file as
server.ssl.key-store=/etc/environment/${SERVER_KEYSTORE}
server.ssl.key-store-password=/etc/environment/${SERVER_KEYSTORE_PASSWORD}
It still gives the same error
Some help will be highly appreciated. Thanks
The following error clearly says that tomcat cannot stat on 8444 port. If you want to verify, open command prompt and type the command netstat -a. This will give you which are the ports already occupied. You can run in different ports like 8090, 8091 etc. Besides, if you want to know more details, start spring boot in debug mode using your ide.
The Tomcat connector configured to listen on port 8444 failed to
start. The port may already be in use or the connector may be
misconfigured.
So I guess your question is how to read env properties in Spring application.properties.
Try this : https://docs.spring.io/spring-boot/docs/2.1.0.BUILD-SNAPSHOT/maven-plugin/examples/run-env-variables.html

Remote Debug for Cloud Foundry application fails when connecting eclipse remote debugger to forwarded local port

I'm trying to remotely debug a Spring boot application deployed on a cloud foundry Instance. Below are the steps that I'm following to setup remote debug using eclipse:
Setting up JBP_CONFIG_DEBUG: '{enabled: true}' environment variable for the application.
After that I'm setting up the local port forwarding to my app container with cf ssh -N -T -L 8000:localhost:8000 <APP_NAME>
Then I'm setting up the remote debug configuration in eclipse as shown below image:Eclipse remote debug setup
After that when I try to start remote debug session, It tried to connect to the app but fails with the message at the port forwarded terminal:
connect to localhost:8000 failed: ssh: rejected: connect failed (dial
tcp 127.0.0.1:8000: getsockopt: connection refused)
Please help, if anyone has any clue about this error!!
You might have to restage the application for the change to take place, debug configuration to change.
You can use alternatively ssh into the container using cf ssh <application name> and check that the debug port is opened on not using netstat -an
We had some issues as well, but with a specific java buildback, but anyway mabe it'll help you in your case as well, try:
cf set-env <app-name> JBP_CONFIG_JAVA_OPTS '[java_opts: "-XX:+ForceDebuggingOnDemand"]'
cf restage <app-name>
try to change debugging port like this:
JBP_CONFIG_DEBUG "{enabled: true, port: 8001}"

Intellij 14 Glassfish Server is not connected. Deploy is not available

I'm trying to get my web app, which was developed and deployed successfully in Eclipse, to run on Intellij, but I failed. So I'm trying to get a basic app to run on Intellij with Glassfish first.
I'm following the steps in this tutorial https://confluence.jetbrains.com/display/IntelliJIDEA/Getting+Started+with+Java+EE+7+and+GlassFish+4.0. However, I can't deploy my app on to glassfish server. When I start the server from Intellij, this message appears:
C:\glassfish\bin\asadmin.bat start-domain domain1
[2015-06-25 10:45:58,857] Artifact Glassfish:war: Server is not connected. Deploy is not available.
Detected server admin port: 4848
Detected server http port: 9090
Waiting for DAS to start .........
Started domain: domain1
Domain location: C:\glassfish\glassfish\domains\domain1
Log file: C:\glassfish\glassfish\domains\domain1\logs\server.log
Admin port for the domain: 4848
Command start-domain executed successfully.
I'm using Java 6 with glassfish 3.0.1 (required by my company).
Glassfish server & deployed apps are running perfectly with eclipse.
I can't find any solution on the Internet. Please kindly help.
I had the same problem and I did the following:
Run my IDE as an administrator in Windows.
Credentials I entered in the glassfish configuration for domain1 were incorrect.
here
I change the user and the password by user: admin and password: admin .Entering the directory:
/glassfish4/glassfish/domains/domain1/config
Open the file admin-keyfile and replace what I was for:
admin;{SSHA256}t6QSpkyxWhpNFiV3RQ+LYgVczWIJVylE3f6akcXTRLJm9MKs983QAA==;asadmin
Open the file local-password and replace what I was for:
6588CB5CBF61A96DB036AC047837A1C4468EC2C4
And ready new user and new password!and Enter the credentials in intellij.
I hope it helps you!

Unable to access the resource from Tomcat server in windows

On machine1, I installed apache tomcat 7 listening on port 9999 and copied a sample.html file in ../webapps/dummy folder of tomcat machine.I was able to access the resource with URL http://localhost:9999/dummy/sample.html
On machine2, Tomcat is already part of some product listening on port 8080 which i thought of utilising it for my sample test. So, I copied a sample.html file in ../webapps/dummy folder of tomcat machine. I was unable to access the resource with URL http://localhost:8080/dummy/sample.html
On machine2, I have existing servlet programming modules running in another folder ../webapps/xyz.
My question:
I am trying to understand, What are the list of things that i need to verify on machine, which let me know, why i have an issue in accessing the URL(above) on machine2? Is this something to do with http access configuration like basic.user/basic.groups file?
It has nothing to do with the port on which tomcat is running.
Did you restart Tomcat after copying file over? It might be that on machine2 it's not configured to run in a dev mode so it doesn't pick up changes at runtime.
or
(if this is linux/unix/mac computer) Tomcat on machine2 is running as tomcat:tomcat user, but file you copied can't be read by this user. Change the permissions of the file.
HTH,
Jan

Unable to open debugger port in IntelliJ

Unable to open debugger port in intellij.
The port number 9009 matches the one which has been set in the configuration file for the application.
<java-config debug-options="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9009" system-classpath="" native-library-path-prefix="D:\Project\lib\windows\64bit" classpath-suffix="">
<jvm-options>-XX:MaxPermSize=192m</jvm-options>
<jvm-options>-client</jvm-options>
<jvm-options>-XX:+UnlockDiagnosticVMOptions</jvm-options>
<jvm-options>-XX:+LogVMOutput</jvm-options>
<jvm-options>-XX:LogFile=${com.sun.aas.instanceRoot}/logs/jvm.log</jvm-options>
<jvm-options>-Djava.endorsed.dirs=${com.sun.aas.installRoot}/modules/endorsed${path.separator}${com.sun.aas.installRoot}/lib/endorsed</jvm-options>
<jvm-options>-Djava.security.policy=${com.sun.aas.instanceRoot}/config/server.policy</jvm-options>
<jvm-options>-Djava.security.auth.login.config=${com.sun.aas.instanceRoot}/config/login.conf</jvm-options>
<jvm-options>-Dcom.sun.enterprise.security.httpsOutboundKeyAlias=s1as</jvm-options>
<jvm-options>-Djavax.net.ssl.keyStore=${com.sun.aas.instanceRoot}/config/keystore.jks</jvm-options>
<jvm-options>-Djavax.net.ssl.trustStore=${com.sun.aas.instanceRoot}/config/cacerts.jks</jvm-options>
<jvm-options>-Djava.ext.dirs=${com.sun.aas.javaRoot}/lib/ext${path.separator}${com.sun.aas.javaRoot}/jre/lib/ext${path.separator}${com.sun.aas.instanceRoot}/lib/ext</jvm-options>
<jvm-options>-Djdbc.drivers=org.apache.derby.jdbc.ClientDriver</jvm-options>
<jvm-options>-DANTLR_USE_DIRECT_CLASS_LOADING=true</jvm-options>
<jvm-options>-Dcom.sun.enterprise.config.config_environment_factory_class=com.sun.enterprise.config.serverbeans.AppserverConfigEnvironmentFactory</jvm-options>
<jvm-options>-Dosgi.shell.telnet.port=4766</jvm-options>
<jvm-options>-Dosgi.shell.telnet.maxconn=1</jvm-options>
<jvm-options>-Dosgi.shell.telnet.ip=127.0.0.1</jvm-options>
<jvm-options>-Dfelix.fileinstall.dir=${com.sun.aas.installRoot}/modules/autostart/</jvm-options>
<jvm-options>-Dfelix.fileinstall.poll=5000</jvm-options>
<jvm-options>-Dfelix.fileinstall.debug=1</jvm-options>
<jvm-options>-Dfelix.fileinstall.bundles.new.start=true</jvm-options>
<jvm-options>-Dorg.glassfish.web.rfc2109_cookie_names_enforced=false</jvm-options>
<jvm-options>-XX:NewRatio=2</jvm-options>
<jvm-options>-Xmx2048m</jvm-options>
</java-config>
Configuration in IntelliJ:
When I try and enable the remote debugging in for this application it comes up with the following error:
You may have to change the debugger port if your port is already used by another program. To do so:
Run
Edit Configurations
Startup/Connection tab
Debug
Change the port here
Or, maybe in other versions:
Run
Edit Configurations
Remote > Remote debug in the list on the left
Configuration tab, Settings section
Port: change the port here
Add the following parameter debug-enabled="true" to this line in the glassfish configuration.
Example:
<java-config debug-options="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9009" debug-enabled="true"
system-classpath="" native-library-path-prefix="D:\Project\lib\windows\64bit" classpath-suffix="">
Start and stop the glassfish domain or service which was using this configuration.
I had the same problem and this solution also did the trick for me: Provide the IP 127.0.0.1 in the Intellij Debug configuration instead of the host name "localhost", in case you're using this hostname.
You must set CHMOD +x (execute for *.sh or *.bat files). For example, I am using macOS
cd /Users/donhuvy/Documents/tools/apache-tomcat-9.0.12/bin
sudo chmod +x *.sh
Then IntelliJ IDEA, and Apache Tomcat running or debugging just good.
In glassfish\domains\domain1\config\domain.xml set before start server
<java-config classpath-suffix="" debug-options="-agentlib:jdwp=transport=dt_socket,address=9009,server=y,suspend=n" java-home="C:\Program Files\Java\jdk1.8.0_162" debug-enabled="true" system-classpath="">
or set debug-enabled="true" server=y,suspend=n in http://localhost:4848/common/index.jsf
In current Idea 2018 - Server Run Configuration - Debug - Port - address
I'm hoping your problem has been solved by now. If not, try this... It looks like you have server=y for both your app and IDEA. IDEA should probably be server=n. Also, the (IDEA) client should have an address that includes both the host name and the port, e.g., address=127.0.0.1:9009.
This one worked for me--
If the issue still persists (in case you are not using a glassFish server), then close your JIdea and stop the server. This will disable the ports connectivity. Then start your server and JIdea, this will start fresh connectivity with the ports, resolving the issue.
For me, the problem was that catalina.sh didnt have execute permissions. The "Unable to open debugger port in intellij" message appeared in Intellij, but it sort of masked the 'could not execute catalina.sh' error that appeared in the logs immediately prior.
This error can happen Tomcat is already running. So make sure Tomcat isn't running in the background if you've asked Intellij to start it up ( default ).
Also, check the full output window for more errors. As a more useful error may have preceded this one ( as was the case with my configuration just now )
Answer is pretty simple,
I also faced the problem finally I got perfect solution.
Create Debug
Create Remote debug with following configuration
Firstly run by debug.
It gives you waitng for socket 5005
then run with remote debug
Try to connect with telnet , if it connects then it shows below:
$telnet 10.238.136.165 9999
Trying 10.238.136.165...
Connected to 10.238.136.165.
Escape character is '^]'.
Connection closed by foreign host.
If port is not available (either because someone else is already connected to it or the port is not open etc) then it shows something like it shows like below:
$telnet 10.238.136.165 9999
Trying 10.238.136.165...
telnet: connect to address 10.238.136.165: Connection refused
telnet: Unable to connect to remote host
So I think one needs to see whether:
the application is property listening to port or not
or someone else has already connected to it
Also try to connect on that m/c itself first like
$telnet localhost 9999
Set the MAVEN_OPTS. It should work !!
export MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n"
mvn spring-boot:run -Dserver.port=8090
Run your Spring Boot application with the given command to enable debugging on port 6006 while the server is up on port 8090:
mvn spring-boot:run -Drun.jvmArguments='-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=6006' -Dserver.port=8090
Your Service/ Application might already be running. In Search enter Services and you will get list of services. Stop yours and then try again.
I had the same issue, I just have to remove the HTTP protocol from the URL. That's it.
I hope it works for you.
I once have this problem too.
My solution is to work around this problem by kill the application which is using the port.
Here is a article to teach us how to check which application is using which port, find it and kill/close it.
In my case, I was not setting the debug port while starting the application.
I am using tomcat to deploy 3 war files, and I forgot to configure the debug port.
Tomcat allows us to configure this via setenv.sh.
Here are the commands to create setenv.sh file in the bin directory of my tomcat installation and provide the debug arguments/port.
tee /usr/share/tomcat9/bin/setenv.sh << EOF
export CATALINA_OPTS="$CATALINA_OPTS -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"
EOF
service tomcat9 restart
Merely hitting the debug icon again fixed my problem in a few seconds.
Make sure to specify an SDK and Project SDK for your app under File --> Project Structure (Project | SDKs)

Categories

Resources