Glassfish not running web application independently of Netbeans - java

Please see the steps I have followed below:
1) Start the Glassfish server in Netbeans:
2) Run the Netbeans project, which successfully browses to: http://localhost:8080/CRUDWebAppSQL/StudentServlet I am able to use the application.
3) Close Netbeans, which stops Glassfish (in preparation for the next step)
Then I try this:
1) Run the following DOS commands:
cd C:\Program Files\glassfish-4.0\bin
sadmin start-domain domain1
2) Message received saying server has started. Browse to: http://localhost:4848/ and login. Make sure that CRUDWebAppSQL is listed as an app.
3) Browse to: http://localhost:8080/CRUDWebAppSQL/StudentServlet which display a Glassfish 404 error
Why does step three produce a Glassfish 404 error? Does it have something to do with this: Where does glassfish save your class/project after deployment on Windows?

NetBeans is using a different mechanism to deploy your application to support hot deployment in comparison to a manual deployment.
To run the application without NetBeans first build the web application with e.g. with Maven mvn clean install to get the *.war file.
Start the Glassfish application server and either deploy the war file through the web interface or with command line asadmin deploy war-name
By the way I would suggest to update NetBeans to the current 8.2 release and have a look at Payara, which is a patched drop-in replacement for Glassfish: http://www.payara.fish/downloads

Netbeans glassfirsh server combine with Felix platform.
Download GlassFish Server Open Source Edition.
Unzip it and goto bin folder in the unzipped folder.
double click asadmin.bat
type start-domain
in this command you can start glassfirsh server
(you can find more command in google)
open browser and type http://localhost:8080/
click link as
go to the Administration Console.
it view "GlassFish Console".
in here you can deploy your web app.(Extension ".war" file)

Related

Registering Eclipse Headless build as Windows Service

I currently developed an Eclipse application which also has a headless build available to integrate with some other application. We created a .exe for our application. What I need is when the installation of our application is completed the headless build should be register as window service. The headless build is started using a batch file which contains following :
set WORKSPACE=
java -jar plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar -pluginCustomization plugin_customization.ini -application myapplication.app.HEADLESSAPP -data %WORKSPACE% -noExit -isHeadLess
When we run this .bat file it starts our application in Non UI mode.
I tried following things so far:
Tried sc.exe command but this didn't work.
Then I converted my .bat file to .exe and then tried sc.exe(give error 1053) and NSSM(executable path always refer to nssm.exe instead of my application).
So basically I need a way to to register this .bat or .exe file as windows service so that it launch my headless application.
UPDATE :
Tried this :
set SERVICE_NAME=TESTSERVICE
set SERVICE_TITLE="TESTSERVICE"
set ECLIPSE_DIR=%~dp0
"%~dp0TESTSERVICE.exe" install %SERVICE_TITLE% --Startup=auto --StartMode=java --StartImage="%ECLIPSE_DIR%eclipsec.exe" --StartPath="%ECLIPSE_DIR%\" ++StartParams="-noSplash -pluginCustomization plugin_customization.ini -application com.eu.ales.hvac.ipm.headless.app.HEADLESSIPMDT -data \"%ECLIPSE_DIR%workspace\" -configuration \"%ECLIPSE_DIR%configuration\"" --LogPath="%ECLIPSE_DIR%\" --LogLevel="Error" --LogPrefix="service"
but getting this
To run a headless Eclipse RCP application as Windows service I use successfully Apache Commons' prunsrv.exe (download here) for several years.
Step-by-step instruction to run Eclipse Infocenter (which is a headless RCP application and contained in all Eclipse IDE packages) as Windows service:
Preconditions:
A Java JRE or JDK is installed
An Eclipse IDE is installed, e. g. eclipse-SDK-4.7-win32-x86_64.zip
Download commons-daemon-1.0.15-bin-windows.zip from http://www.apache.org/dist/commons/daemon/binaries/windows/
Extract prunsrv.exe from root directory of the downloaded ZIP archive into your Eclipse installation directory
In the Eclipse installation directory create the file install_as_service.bat with following content:
set INFOCENTER_PORT=8088
set INFOCENTER_TITLE="Eclipse Infocenter"
for %%i in ("%~dp0") do (set INFOCENTER_DIR=%%~dpi)
set INFOCENTER_DESCRIPTION=Port: %INFOCENTER_PORT%, Location: %INFOCENTER_DIR%
"%~dp0\prunsrv.exe" install %INFOCENTER_TITLE% --Description="%INFOCENTER_DESCRIPTION% " --Startup=auto --StartMode=exe --StartImage="%INFOCENTER_DIR%eclipsec.exe" --StartPath="%INFOCENTER_DIR%\" ++StartParams="-noSplash#-application#org.eclipse.help.base.infocenterApplication#-data#\"%INFOCENTER_DIR%info_center_workspace\"#-configuration#\"%INFOCENTER_DIR%info_center_configuration\"#-vmargs#-Dserver_port=%INFOCENTER_PORT%#-Xms420m#-Xmx420m#-XX:MaxPermSize=256m" --StopMode=exe --StopTimeout=300 --StopImage="%INFOCENTER_DIR%eclipsec.exe" --StopPath="%INFOCENTER_DIR%\" ++StopParams="-noSplash#-application#org.eclipse.help.base.infocenterApplication#-data#\"%INFOCENTER_DIR%info_center_workspace\"#-configuration#\"%INFOCENTER_DIR%info_center_configuration\""#-command#shutdown --LogPath="%INFOCENTER_DIR%\" --LogLevel="Error" --LogPrefix="service"
Double-click install_as_service.bat
Press Windows+R, enter services.msc and click OK
=> The list of services should contain Eclipse Infocenter
Start the service Eclipse Infocenter
In a web browser open http://localhost:8088/help/index.jsp
=> Eclipse Help should be shown in the web browser (similar to https://help.eclipse.org)
To uninstall the service, first stop the service and then run prunsrv.exe delete "Eclipse Infocenter"

Could not load the Tomcat server configuration

I have installed apache tomcat7 using sudo apt get in ubuntu. I have added apache tomcat 7 to eclipse using Windows > Preferences > Server > Runtime Environment.But when I'm starting the server from server view by right clicking the shown Tomcat v7.0 Server at localhost [Stopped,Republish]
It says:
Could not load the Tomcat server configuration at /Servers/Tomcat v7.0
Server at localhost-config. The configuration may be corrupt or
incomplete.
The path to tomcat7 that I've provided is /usr/share/tomcat7
I've just been encountering a very similar issue in Ubuntu while trying to get Eclipse Mars and Tomcat7 integrated because Eclipse was expecting the tomcat configuration files etc to be all in the same location, and with the necessary permissions to be able to change those files.
The following instructions from this blog article helped me in the end:
cd /usr/share/tomcat7
sudo ln -s /var/lib/tomcat7/conf conf
sudo ln -s /var/log/tomcat7 log
sudo ln -s /etc/tomcat7/policy.d/03catalina.policy conf/catalina.policy
sudo chmod -R a+rwx /usr/share/tomcat7/conf
I've just solved this exact problem on my Ubuntu 14.04 with Eclipse Mars 2.
This could happen when Eclipse is not finding Tomcat's configuration files where they are expected to be. This place is in
$eclipse_workspace_folder/$version_of_your_tomcat_server_at_localhost/
(by default if you didn't changed server's name). So you have to copy all the files under your $tomcat_installation_folder/conf/* to the workspace server's folder.
But it was easier to just remove the server from your server list and add it again. Eclipse will automatically recreate all these files again into the proper folders. Like in the picture below:
In my case I've downloaded tomcat-8.0.35 from the website, so the configuration files needed are in /opt/apache-tomcat-8.0.35/conf/ filesystem.
Just delete the desired server from the Servers view (Window -> Show View -> Servers) and then go to Window -> Preferences -> Server -> Runtime Environment -> Add and add the server again.
You can install tomcat7 in ~/tomcat7 instead of /usr/share/tomcat7.
Close Eclipse.
Delete org.eclipse.wst.server.core.prefs and org.eclipse.jst.server.tomcat.core.prefs in {workspace-directory}/.metadata/.plugins/org.eclipse.core.runtime/.settings.
Launch Eclipse.
Go to Window->Show View->Other... and choose the Servers.
Select Tomcat v7.0 Server from the server type and press Next.
Enter /home/user/tomcat7 (not /usr/share/tomcat7) into the "Tomcat installation directory" and press Download.
Wait a few minutes and press Finish.
tomcat7 worked correctly with Eclipse 4.4 on my Ubuntu 15.04 in this way.
I know it's an old question and it has been solved already but for me the Tomcat conf/tomcat-users.xml file was created with a different encoding from the rest of the configuration files. The first line of that file looked like this:
<?xml version='1.0' encoding='cp65001'?>
All I had to do to solve the issue was change that line for:
<?xml version="1.0" encoding="UTF-8"?>
And voila.
I have no idea what 'cp65001' means or why it was created like that.
Maybe this will help other users facing the same issue.
The application is trying to load /usr/share/tomcat7/conf/ which doesn't exist. Eclipse assumes conf is in the same directory as bin
In Ubuntu, conf is placed in /etc/tomcat7/ and there is a symbolic link in /var/lib/tomcat7/.
To solve this, you can either
Download package from Apache Tomcat, and place them in a specific directory, say /opt/ or
Create a symbolic link in /usr/share/tomcat7/ pointing to /etc/tomcat7/conf
A quick solution in eclipse to resolve when Tomcat could not load as per the following error:
Just refresh the Tomcat folder should do the trick. If it still does not work, delete all files in eclipse under the Tomcat folder, re-copy the server files then refresh the Tomcat folder. Tomcat should restart correctly after that.
I have Windows 8.1, Eclipse Neon, Tomcat 8.
The solution is to copy all the files from folder ".../Tomcatxxx/conf" to the ".../Workspace_directory/Servers" and try to launch server again.
You tried to start Tomcat and got the following error:
Could not load the Tomcat server configuration at /Servers/Tomcat v7.0 Server at localhost-config. The configuration may be corrupt or incomplete
How to solve:
Close Eclipse
Copy all files from TOMCAT_7_HOME/conf to WORKSPACE_FOLDER/Servers/Tomcat v7.0 Server at localhost-config
Start Eclipse
Expand the Servers project, click on the Tomcat 7 project and hit F5
Start Tomcat from Eclipse
I know it's been a while since this question was posted, but I was just getting this exact error, and I have a really simple solution that MIGHT work for some. All I did was double click on the folder 'Servers', which then allowed me to start the server with no error message. Sometimes the solution is right in front of your eyes. This might work for some people like me who go straight to google without trying fix the issue themselves!
on Centos 7, this will do it, for Tomcat 7 :
(my tomcat install dir: opt/apache-tomcat-7.0.79)
mkdir /var/lib/tomcat7
cd /var/lib/tomcat7
sudo ln -s /opt/apache-tomcat-7.0.79/conf conf
mkdir /var/log/tomcat7
cd /var/log/tomcat7
sudo ln -s /opt/apache-tomcat-7.0.79/logs log
not sure the log link is necessary, the configuration is the critical one.
:
Had the same issue with Kepler (after trying to add a Tomcat 7 server).
Whilst adding the server I opted to install the Tomcat binary using the download/install feature inside Eclipse. I added the server without adding any apps. After the install I tried adding an app and got the error.
I immediately deleted the Tomcat 7 server from Eclipse then repeated the same steps to add Tomcat 7 back in (obviously skipping the download/install step as the binary was downloaded first time around).
After adding Tomcat 7 a second time I tried adding / publishing an app and it worked fine. Didn't bother with any further RCA, it started working and that was good enough for me.
I had the same problem in Eclipse Oxygen with Tomcat 8 in ubuntu 16.04 LTS.
Solution:
1. Give permission to entire tomcat folder (chmod 777 -R /Tomcat)
2. Delete and re-add the server in eclipse
3. Restart eclipse
4. Start the tomcat server. It will work..........
In the Servers tab of eclipse, go to the properties of the server and Switch location to latest downloaded tomcat version.
This resolved the issue for me.
Tomcat Server Properties
I solved this problem. DON'T USE THE .exe
Unistall Tomcat and download the .zip from Tomcat's web site. Then unpack and put it in C:\Program Files. Open Eclipse and set the server. it will work.

apache tomat7 not starting in browser?

Hi i'm using Apache Tomcat 7,with jdk 1.7 in windows 8. and i have installed tomcat successfully in windows 8,now i'm going hit URL in browser like"localhost:8080" it's work fine,after i open eclipse created web-application & i configured tomcat with that web-application,now i try to restart i'm getting error like!!
so for that,i have stopped tomcat in services(task-manger-service).now it will work fine(it get restarted in eclipse and works fine). when i hit URL in browser like"localhost:8080" i' getting error like ! and more i have added java_home,Catalina_home and also path.
can any one help me out it should work in both eclipse & browser?
First do
netstat -a -b -o
and see if ports that are configured in Eclipse Tomcat are free. If they are not free kill that process
taskkill /PID <pid>
Use /F flag if needed. You should get PID fro, netstat command. You should get Eclipse tomcat ports from Server tab of JavaEE perspective
Then start your tomcat.
PS : If you are getting 404 either you are entering incorrect URL or server is not up in the first place. In any case check the logs if you are getting 404.
Follow the below steps
Right click on your eclipse project
Select Refresh
Click the Run icon
It is not straight forward when you invoke Tomcat from within Eclipse. Please read the FAQ section at https://wiki.eclipse.org/WTP_Tomcat_FAQ
It explains how if you start Tomcat from within Eclipse, the binaries of original directories of Tomcat are used, but the web apps etc are stored separately in the Eclipse Workspace.

Glassfish timeout

When a try to start glassfish from within Eclipse the following error occurs:
Unable to start server on time. java.util.concurrent.TimeoutException
And when a try to start via asadmin start-domain or asadmin start-domain domain1 it remains loading and never stops.
Anyone can help me?
Perform the following two steps:
Go to the folder where you store the Glasfish.
Example: My folder is C:\Program Files (x86)\glassfish-4.0\glassfish\bin.
Double click on startserv.bat and wait a few seconds and it will work.
I had the same problem and I solved it like the following :
try to update the GlassFish tools from the Eclipse MarketPlace, and
get the latest update , and check eclipse for any updates .
restart Eclipse , "I don't know why , but it works " .
I was facing the same issue with my Glassfish 4.0 server, I did googled but didn't worked out for me.
You can manually deploy your web application by exporting your project as .war file and then using Glassfish GUI (http://localhost:4848) deploy your application and then access it.
Open the GlassFish Server configuration by double clicking on your server instance in your server windows. You shall find a Timeout section. Expand it and increase the time limit to complete server operations in the Start section. This should work.

debugging java application deployed in tomcat

I have an application that I deployed in tomcat. Later I configured the code as a project in Eclipse. I want to connect to the tomcat via eclipse and debug the application.
Trying to setup a remote debug connection is throwing up errors. Is there any entry that I need to add somewhere in tomcat?
First, you need to run Tomcat in debugging mode. The easiest way to do that is to modify the startup file (.bat or .sh depending if you are Windows or not). Find the line near or at the end of the file that contains the start command, and change it to jpda start. This will cause Tomcat to start in debugging mode listening on port 8000.
Next, to connect to this process via Eclipse, select the Run menu and choose Debug Configurations.... In the pane on the left, choose Remote Java Application and click the New launch configuration button above the list. The important settings to note are the Host and Port fields. The host value must match the hostname of the Tomcat process, and the port should be 8000. You also might need to add entries on the Source tab to ensure that all of the source code is available to step through.
Create a new tomcat server
Create a new dynamic web project
Export war to tomcat server
Tomcat debug configuration(important), first double click tomcat server, then select "Use Tomcat installation (takes control of Tomcat installation)"
Add breakpoints
Run tomcat in debug mode
Test war in web browser
Edit source path
Debug source code in Tomcat
The war file is available here.
yes, you need to configure tomcat to accept remote debugging connections. There is a FAQ on how to do it with various IDEs.
http://wiki.apache.org/tomcat/FAQ/Developing#Q2
Simply change the line in startup.bat (if you are using Windows)
from:
call "%EXECUTABLE%" start %CMD_LINE_ARGS%
to:
call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%
Right Click on the project you want to debug and go to Debug As Menu and in the list click on Debug Configurations.
Then Double click on the Remote Java Application from left menu list. browse for the project u wanna add in then click apply.
Also change the listening port to 7999, then after you started the web app from your localhost click the debug button on the same window. Then any break point's will be hit after that.
Steps to setup the tomcat Debugger with eclipse
Install the following things:
java 1.8+
eclipse EE version
download tomcat 8+
open eclipse and go to servers tab and add a new server(window-> show View-> Others -> Search Servers)
Mark your project as Dynamic web Project(Rightclick on Project-> project facets -> select Dynamic web module)
Export war (File-> Export-> search war -> select module and choose the path)
Run as -> Run on Server
Start the tomcat Server in Debug or Run Mode
check on localhost:8080
Debug worked for me. I was using tomcat 8, configured on centos 7. Debug port opened for me after changing 2 settings.
Open tomcat/conf/bin/startup.sh and added below lines
export JPDA_ADDRESS=8000
export JPDA_TRANSPORT=dt_socket
In the same file startup.sh, added jpda before start command.
exec "$PRGDIR"/"$EXECUTABLE" jpda start "$#"
Restart the tomcat.
In eclipse go to Run>Debug configuration>Remote java application>Add host ip and port(8000) where tomcat is running.
In my case i required to open 8000 through firewall too.
firewall-cmd --zone=public --permanent --add-port=8000/tcp
firewall-cmd --reload
Beside remote debugging, you can debug your app locally within eclipse if you added tomcat in eclipse.
just start server and wright click your app and from debug menu hit debug on server.
If you have multi module maven project, debug on server just shown up for module with war packaging.
If you want debug a class that runs at startup by self, like methods that annotated with #PostConstruct, remember that you should increase server timeout.
To do that, go to server view and double click on tomcat and in server preview tab, increase the timeout value.

Categories