How to deploy EJB application as an Exe file - deployment

I'm sorry if this question annoys you. I've written an EJB-based application and now I want to deploy it as a single Exe file (not a War file). That means if that Exe file's executed, all related things such as the web server, the database server, ... will be automatically installed to enable my application run smoothly. The JIRA installer's a typical example (http://www.atlassian.com/try).
I've googled a lot but I can't find the right answer. Would you please tell me how I can achieve that?

Glassfish has a embedded Java ee container: http://embedded-glassfish.java.net That will allow you to embedd a Webserver and database into your app (infact a complete Java EE container).
The next step would be to embedd a a java-runtime and bundle it with above as an exe. I havnt tried that. But start with the above step and see if it is enough, then start by reading about this: Embed a JRE in a Windows executable?

Related

FAIL - Failed to deploy application at context path

Before I explain the problem, I just want to point out that I am completely new to NetBeans and Tomcat and I am doing a school project. That being said, the problem is exactly what the title says. Here is the output when I try to run a simple Hello World jsp:
In-place deployment at
C:\Users\lostl\OneDrive\Documents\NetBeansProjects\Project3\build\web
Deployment is in progress...
deploy?config=file%3A%2FC%3A%2FUsers%2Flostl%2FAppData%2FLocal%2FTemp%2Fcontext7180600714574256491.xml&path=/Project3
FAIL - Failed to deploy application at context path [/Project3]
C:\Users\lostl\OneDrive\Documents\NetBeansProjects\Project3\nbproject\build-impl.xml:1058: The module has not been deployed.
See the server log for details.
BUILD FAILED (total time: 0 seconds)
I am using Apache NetBeans 11.2 and Tomcat 9 if it is relevant.
Here is what I tried:
I checked the server log and it displays absolutely nothing.
I tried setting the context path directly to Project3 (i.e. including the -C:/... before Project3) in the context.xml file under META-INF folder.
I tried restarting NetBeans and cleaning and building the project.
I tried running NetBeans under admin privileges.
I might seem like such an idiot for not knowing how to fix this since no one else seems to have this problem, but please help me out.
If you have installed the Apache Tomcat appart from Netbeans, maybe your apache service is already running and it conflicts with Netbeans. You may stop the apache service and then run the application in Netbeans.
Because Netbeans start the apache service in a diffent way, so you don´t need to install the aplication on apache´s folder.
Check out the Windows Services (Services App) and stop the Apache Tomcat if running, then from Netbeans menu select Run->Run Project. Netbean will start Tomcat and deploy your web app onto the Tomcat server.
I fixed it. All I had to do was restart my computer. I feel so dumb.
clean your project if clean project failed to delete some file then,
Just check there must be a java process running at background.
If you are using windows 10 then follow these steps
open command prompt and type below commands
tasklist | findstr java (hit enter now you can see a task list with pid number )
taskkill /F /PID "PID_OF_JAVA_PROCESS" (where PID_OF_JAVA_PROCESS--> task pid hit enter)
now run the project again
I faced this problem and found a solution. It is very simple. All you need to do is stop the Tomcat services or restart your computer and run your program.

How can I let Tomcat run a command after it finishes deploying web application's .war files

We know that during Tomcat startup, it will deploy the .war files of its web applications. My question is after the deployment I need to run a command to modify a file inside WEB-INF/ of the web application which is generated after deployment, and I need to let Tomcat do this automatically for me, is this possible to achieve ? Something like post_run command after deployment.
I found that CustomEventHookListener can probably do this How to run script on Tomcat startup?, but this involves in making a new Java class, and I'm not allowed to do so. I have to figure out way to modify the existing Tomcat configs like server.xml or tomcat.conf in TOMCAT_HOME/conf to do so.
The main issue about not using a Event Hook Listener is that there's no reliable way to tell if the application is ready or not, as Catalina implements it's own lifecycle for each of their components (as seen in https://tomcat.apache.org/tomcat-8.5-doc/api/org/apache/catalina/Lifecycle.html).
Your best shot is to use tail or some external program infer the component's state, but AFAIK there's no way to implement listeners directly in the configuration files.

What language does SmartFoxServer 2x use on the server side?

I have downloaded and started the community version of SFSx2. I read everything on their documentation page:
http://docs2x.smartfoxserver.com/DevelopmentBasics/introduction
Which unfortunately only talks about flash client side code. Nothing about the corresponding server side code, nor about html5 client side which I need.
I downloaded the HTML5 examples, which took me a long time to find (they are here: http://www.smartfoxserver.com/download/get/140 )
None of the examples work, as they can't connect to the server. Presumably, this is because the examples only supply client side code. There are no instructions supplied on how to install or run the examples.
I can find no mention on the smartfox documenation on the following:
1) what language is used on the server side. One assumes its java.
2) how does one deploy java code to the smartfox server? I cant find any mention of this in the docs.
3) how does one find and install the server part of the client side examples (which are Tris, GameLobby, BuddyMessenger, AdvancedChat).
I applied to be allowed to post on the smartfoxserver forums, but no reply yet.
I also found it hard so I share what I've found out.
The server extensions are written in Java. I used Eclipse JUNO to write my code.
You can download Eclipse here. http://www.eclipse.org/downloads/
You export the extension in jar format from eclipse into you extension path. The name of your file has to end in 'extension' eg MyFirstExtension.jar otherwise sfs2x wont recognize it. Your extension path will be something like this: C:\Program Files\SmartFoxServer2X\SFS2X\extensions\MyFirstExtension\MyFirstExtension.jar if your working in windows.
You will find docs on JAVA API here. http://docs2x.smartfoxserver.com/api-docs/javadoc/server/
This is a link to the basic example code: http://www.smartfoxserver.com/download/get/120
Unzip the content into the [SFS2X_install_folder]/SFS2X/www/root/examples folder, overwriting the existing file. Run the index.html file, then navigate to another index.html to open the example. Run the sfs2x-standalone.exe first of course(see below). If you followed the 'server configuration tutorial' on smartfox website and changed the server ports, the examples wont work. Leave the ports alone until you start to understand the server.
This is a link to the flash example code: http://www.smartfoxserver.com/download/get/108
You will find the example code for apps mentioned above. They are written in Adobe Flash Builder and Java extensions. I don't know if there is any code for HTML5 but the Java server code and AS3 is there.
I also found that using the standalone server was the way to go rather than using SFS2x as a service. c:\program files\smartfoxserver2x\sfs2x\sfs2x-standalone.exe. Using the exe gives you the command prompt window. You can use the window for debugging and see the state of the server when it starts.
Most of the examples should work without creating extensions but to create an extension out of source examples:
Create and setup a new project in your Java IDE. You will have already set up a workspace.
Copy the content of the /source/server/src folder to your project's source folder.
Add SFS2X Libraries. Go to properties of the project -> Select Java Build Path -> Click Library Tab -> Add external jar. Add 'sfs2x.jar' and 'sfs2x-core.jar' from C:\Program Files\SmartFoxServer2X\SFS2X\lib folder. To create the extension, export jar file to extension path. Restart server.
Another problem I had was the Java Version I was using. I had to use Java1.6 with my version of sfs2x when writing extensions. This was trial and error as there was no documentation. There may be a newer version out now.
I had to copy all the server source into eclipse to try and understand how things were done. It was a way of having all the code in one place. There was a lot of trial and error as getting help is hard. I eventually accomplished what I set out to achieve. Good Luck.
SmartFox Server is easy to use even with extension. documentation Give try to Nuggeta solution for game development too. No extension needed at first. This is optionnal.
We have full HTML5 open source game walkthrough on github

Installing Tomcat 7 as Service on Windows Server 2008

I want to install my tomcat v7.0.12 as a service on my Windows 2008 Server.
On the tomcat page I found this tutorial. But there isn't a service.bat file in my installation dir.
In the service overview of WS2008 it isn't possible easily create a new service like new->service ...
To Start Tomcat7 Service :
Open cmd, go to bin directory within "Apache Tomcat 7" folder. You will see some this like C:\..\bin>
Enter above command to start the service: C:\..\bin>service.bat install. The service will get started now.
Enter above command to start tomcat7w monitory service. If you have issue with starting the tomcat7 service then remove the service with command : C:\..\bin>tomcat7 //DS//Tomcat7
Now the service will no longer exist. Try the install command again, now the service will get installed and started: C:\..\bin>tomcat7w \\MS\tomcat7w
You will see the tomcat 7 icon in the system tray. Now, the tomcat7 service and tomcat7w will start automatically when the windows get start.
You can find the solution here!
Install the service named 'Tomcat7'
C:\>Tomcat\bin\service.bat install
There is a 2nd optional parameter that lets you specify the name of the service, as displayed in Windows services.
Install the service named 'MyTomcatService'
C:\>Tomcat\bin\service.bat install MyTomcatService
Looks like now they have the bat in the zip as well
note that you can use windows sc command to do more
e.g.
sc config tomcat7 start= auto
yes the space before auto is NEEDED
I just had the same issue and could only install tomcat7 as a serivce using the "32-bit/64-bit Windows Service Installer" version of tomcat:
http://tomcat.apache.org/download-70.cgi
I have spent a couple of hours looking for the magic configuration to get Tomcat 7 running as a service on Windows Server 2008... no luck.
I do have a solution though.
My install of Tomcat 7 works just fine if I just jump into a console window and run...
C:\apache-tomcat-7.0.26\bin\start.bat
At this point another console window pops up and tails the logs
(tail meaning show the server logs as they happen).
SOLUTION
Run the start.bat file as a Scheduled Task.
Start Menu > Accessories > System Tools > Task Scheduler
In the Actions Window: Create Basic Task...
Name the task something like "Start Tomcat 7" or something that makes sense a year from now.
Click Next >
Trigger should be set to "When the computer starts"
Click Next >
Action should be set to "Start a program"
Click Next >
Program/script: should be set to the location of the startup.bat file.
Click Next >
Click Finish
IF YOUR SERVER IS NOT BEING USED: Reboot your server to test this functionality
There are a lot of answers here, but many overlook a few points. I ran into the same issue and it was likely due to a combination of being a complete neophyte when it comes to tomcat. Even more I am rather new to web servers in general. I consider myself somewhat proficient user of windows, but I guess not proficient enough. In particular I don't work with services too much.
I did not have a startup.bat or any bat files. I only downloaded the 32-bit/64-bit Windows Service Installer. The bin that is created for that download is small - only 4 files. My colleagues were surprised that I did not have a catalina.bat etc... and I was too. Only the below four files in the bin. And no %CATALINA_HOME% or %TOMCAT_HOME% etc...
bootstrap.jar
tomcat-juli.jar
Tomcat7.exe
Tomcat7w.exe
With this setup I had some frustrations as setting parameters is done via the gui widget - very helpful I might add.
So nearly all the answers I have perused were not immediately applicable as many said, "go to bin and issue the startup.bat file" I am a neophyte but not so much to not be able to look into the bin and start such a file it is existed!
For my simple purposes (again remember that I am a neophyte at tomcat and even web servers) all I wanted to do was to be able to startup and shutdown the tomcat server from a cmd prompt window. Nothing too heavy duty. I am embarrassed to say how simple it is. It is probably evident to anyone with a shred of experience with services and such.
To Start server: <Tomcat Root>/bin>Tomcat7.exe start
To Stop server: <Tomcat Root>/bin>Tomcat7.exe stop
Found here - http://crunchify.com/how-to-start-stop-apache-tomcat-server-via-command-line-setup-as-windows-service/
I did not realize there was a separate download the 64-bit Windows zip file that has a tomcat server and all the standard array of cmd line tomcat management tools. This zip file has all the common startup/shutdown scripts, batch files for windows, including catalina.bat/.sh etc... Then all the above answers make sense and are rather trivial.
Remember I am a neophyte when it comes to tomcat and web servers. It appears these two downloads are somewhat mutually exclusive in the sense that if I download and install the 32-bit/64-bit Windows Service Installer version and the 64-bit Windows zip file the startup.bat file in the 64-bit Windows zip file version will not run or interact with the 32-bit/64-bit Windows Service Installer tomcat instance. But I am not sure about this point.
Edit service.bat – Swap two lines so that they appear in following order:
if not “%JAVA_HOME%“ == ““ goto got JdkHome
if not “%JRE_HOME%“ == ““ goto got JreHome
Open cmd and run command service.bat install
Open Services and find Apache Tomcat 7.0 Tomcat7. Right click and Properties. Change its startup type to Automatic (with delay).
Reboot machine to verify if the service started automatically
its done through service.bat file in apache tomcat7
visit this blog ..
install tomcat7 on windows
I had a similar problem, there isn't a service.bat in the zip version of tomcat that I downloaded ages ago.
I simply downloaded a new 64-bit Windows zip version of tomcat from http://tomcat.apache.org/download-70.cgi and replaced my existing tomcat\bin folder with the one I just downloaded (Remember to keep a backup first!).
Start command prompt > navigate to the tomcat\bin directory > issue the command:
service.bat install
Hope that helps!

JBoss Application Server redeploy

I need a windows shell script which will redeploy my .ear file. I wrote one:
net stop "JBAS50SVC"
copy /y O:\TEMP\app.ear C:\jboss-4.2.3.GA\server\default\deploy\app.ear
net start "JBAS50SVC"
But the problem is that when I try to stop the JBoss service it does not fully unload itself (my suggestion), so when I start it there's no app deployed in JBoss.
You mentioned that JBoss becomes very slow when you use autoDeploy and keep the server running for a month or more. That's likely to be because your permanent generation memory is filling up over time. See this related question.
I think you'd be best served by using the autoDeploy feature as other suggest, and restarting the entire server periodically to clear out PermGen. There's several ways to track PermGen utilization; I add the following to JAVA_OPTS in run.conf:
-XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution -Xloggc:$LOGDIR/gc.log
Typically to redeploy an application that is self-contained in an ear in jboss just requires replacing the ear. If there is more to the application (such as classes that have to go in the jboss lib directory) then it may require a restart.
In terms of how to restart it, it depends what you are using to start jboss as a service. Some service starters do not actually control the jvm after they start it, so restarting the service just starts a second instance. You can shutdown jboss with the shutdown script in the JBOSS_HOME/bin directory (shutdown.bat) and then deploy and restart the service. Be sure to pause when you do this, as the shutdown command will issue the shutdown request, the server may still be running.
You can just COPY/RENAME the EAR file to deploy directory. JBoss will automatically take care of re-deployment for you.
As mentioned earlier jboss automatically deploys everything you copy into the deploy directory by default.
If not, check if you are working on a vhost that doesnt autodeploy ear files.
<Host name="vhost2" autoDeploy="false" .... />
other than that, I feel like this is a totally different error due to the fact that jboss takes care of deployment for you. Please check the log files for startup errors of your application.
You might want to check the JBoss community wiki on this, there are undoubtedly easier and more reliable methods than a batch file.
Stopping the server should not undeploy the application - that wouldn't make much sense.