Change part of Java class code after deploying to server as webapp - java

I have a Java servlet web app (.war) which I deployed to Tomcat Ubuntu server.
Can I change the content the Java classes at: myProject/WEB-INF/classes/
without re-export-and-deploy the entire app ?
Thanks in advance.

I could thought of below to re deploy your app without restarting tomcat:
Modify your java file
Generate .class file
Replace it with your existing file in Tomcat
Trigger your app restart by touching WEB-INF/web.xml

Disclaimer: I don't recommend doing this because it can give unexpected results. I am aware that sometimes you need to do "quick-and-dirty" fix, but consider yourself warned :)
I assume you have a Web application, let's call it 'MyApp'. Go to <TOMCAT-DIR>/webapps and locate your MyApp.war file. Put new .class file into the MyApp.war (open it with some archiver) and then delete the folder <TOMCAT-DIR>/webapps/MyApp. Deleting the folder means undeployment for Tomcat. After some time, Tomcat will figure out that it has a .war file in his <TOMCAT-DIR>/webapps folder that needs to deploy and it will automatically do it. You will see in Tomcat's log something like:
Aug 25, 2015 9:24:55 AM org.apache.catalina.startup.HostConfig undeploy
INFO: Undeploying context [/MyApp]
Aug 25, 2015 9:24:55 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /home/tomcat/apache-tomcat-7.0.55/webapps/MyApp.war
Aug 25, 2015 9:25:17 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deployment of web application archive /home/tomcat/apache-tomcat-7.0.55/webapps/MyApp.war has finished in 21,937 ms
And there you go, you just refreshed your application without redeployment and without restarting server.

Related

GlassFish server core.jar is not contained in the list of the installed bundles

Launching GlassFish on Felix platform
gru 05, 2016 2:02:02 PM
com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner createBundleProvisioner
INFO: Create bundle provisioner class = class com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner.
gru 05, 2016 2:02:02 PM com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner$DefaultCustomizer getLocations
**WARNING: Skipping entry because it is not an absolute URI.**
gru 05, 2016 2:02:02 PM com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner$DefaultCustomizer getLocations
**WARNING: Skipping entry because it is not an absolute URI.**
gru 05, 2016 2:02:11 PM com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner startBundles
**WARNING: Can not start bundle file:/C:/Users/MyName/Desktop/Servers/glassfish4/glassfish/modules/core.jar because it is not contained in the list of installed bundles.**
Registered com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishRuntime#294d3883 in service registry.
I can't run my project.
What already I did:
- clear&build
- tryed to change ports from 8080 to 9090
- closed connections in TCPView on localports
- closed Java Binary process in task menager and still not working.
When i running project i got this:
C:\Users\MyName\Desktop\Java Web Profile\MyProject\nbproject\build-impl.xml:1048: The module has not been deployed.
See the server log for details.
1047-1049 lines from build-impl.xml:
<target if="netbeans.home" name="-run-deploy-nb">
<nbdeploy clientUrlPart="${client.urlPart}" debugmode="false" forceRedeploy="${forceRedeploy}"/>
</target>
Any ideas? :)
I found this solution/cause on another site, didn't resolve the issue for me but hopefully it can help you:
Reasons: In mac OS Sierra ,the new update blocks the sites which uses system proxy settings, where localhost,127.0.0.1 all connections are blocked.
Solution:
Step 1: Go to system preference >Network>Select your wifi connection>Advanced>select proxies tab.
There check 3 options 1) Auto proxy Discovery 2)Automatic Proxy configuration 3) web proxy(http)
Step 2: Go to Netbeans>preferences>General> select use system proxy> reload> test connection
You may get connection successful.
If connection gets successful, Now Clean & build your Applications in netbeans and press run .
Hope it will work . In my case it works.
https://discussions.apple.com/message/30715103#message30715103
https://netbeans.org/bugzilla/show_bug.cgi?id=268076

War deployment in Embedded Tomcat

I have an embedded tomcat (7.0.64) on MAC and am deploying a war file, running on java 1.7.067. For some reason my tomcat server hangs on the call "Tomcat.start()".
I know for sure that it's getting stuck deploying the war file. The way i figured this i plugged in a different war file(a simple hello world) and that worked.
I tried hooking up tomcat log.properties and got the logs directed to file with hope of getting any clues. But i don't see any exception, the logging stops at these lines,
FINE: Loading class from parent
Nov 16, 2015 9:30:01 PM org.apache.catalina.loader.WebappClassLoader loadClass
FINE: Loading class from parent
Nov 16, 2015 9:30:01 PM org.apache.catalina.loader.WebappClassLoader loadClass
FINE: loadClass(com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl, false)
Nov 16, 2015 9:30:01 PM org.apache.catalina.loader.WebappClassLoader loadClass
FINE: loadClass(com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl, false)
Nov 16, 2015 9:30:01 PM org.apache.catalina.loader.WebappClassLoader loadClass
FINE: loadClass(com.sun.org.apache.xerces.internal.impl.dv.dtd.DTDDVFactoryImpl, false)
Nov 16, 2015 9:30:01 PM org.apache.catalina.loader.WebappClassLoader loadClass
FINE: loadClass(com.sun.org.apache.xerces.internal.impl.dv.dtd.DTDDVFactoryImpl, false)
Not sure if it can't find "DTDDVFactoryImpl", since this is part of the jdk libraries itself as well as i am including xercesimpl.jar as well.
Basically i am looking for ways that can help me figure out, what or which class is blocking from the web deployment from happening.
Any ideas/pointers?
TIA
Updated - My log.properties looks like,
handlers=java.util.logging.ConsoleHandler, org.apache.juli.FileHandler
org.apache.juli.FileHandler.level=ALL
org.apache.juli.FileHandler.directory=./logs
org.apache.juli.FileHandler.prefix=tomcat-
java.util.logging.ConsoleHandler.level=ALL
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
org.apache.catalina.level=FINEST
org.apache.catalina.handlers=org.apache.juli.FileHandler
the line -
FINE: loadClass(com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl, false)
The above message means that a web application have already been
stopped, but the TimerTask tries to load a class from it.
What web application has started this timer?
If the timer was started by this web application, then it is your
fault. You should have configured a
javax.servlet.ServletContextListener to stop (cancel) the timer when
the web application stops. You cannot load classes when web
application have already been stopped.
OR
If the timer was started by a different web application, it means
that you have PermGen memory leak somewhere. Ensure that you have
JreMemoryLeakPreventionListener configured in server.xml.
It is known that there was a PermGen memory leak in Java XML APIs. A
workaround to suppress it was added to JreMemoryLeakPreventionListener
in r884341 [1]
Mark has a presentation on Memory Leaks
http://people.apache.org/~markt/presentations/2010-11-04-Memory-Leaks-60mins.pdf
OR
Bundling a separate copy of Apache Xerces with the web application
may help. It will not help if the root cause is your failure to cancel
the timer.
[1] http://svn.apache.org/viewvc?view=revision&revision=r884341
hope this helps.

Issue with deploying application using tomcat7

I am trying to deploy an application using spring in tomcat7 running on ubuntu12. When I drop the war file in the webapps directory, the directory is created for the application inside webapps - yet the application does not load up. Latest issue is copied below. Any thoughts on troubleshooting this will be appreciated.
Java versions are the same on the computers where the war file was generated vs the one where I am deploying the application. I do not see a file permission issue - there is a logging.properties file in tomcat7.
Jan 31, 2014 10:43:05 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Jan 31, 2014 10:43:05 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/test-webapp] startup failed due to previous errors
Jan 31, 2014 10:43:05 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/test-webapp] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak.
Update:
I missed an error message. I will update this ticket shortly.
Update:
I was missing a file in tomcat meant for the application deployment - pilot error. Thanks to everyone for sharing their thoughts- much appreciated!
It looks like a known issue of MySQL over tomcat, have you tried yet any of the suggested solutions in
http://bugs.mysql.com/bug.php?id=69526
http://bugs.mysql.com/bug.php?id=68556
?

Tomcat 7 war file deploy

I am trying to load a WAR file to my Tomcat 7,
and I am using eclipse to start or stop the Server.
I pasted the war file in TOMCAT_HOME/webapps folder and I started the server.
The server Started fine and i got the below console message.
10 Dec, 2012 9:10:46 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: F:\Program Files\Java\jdk1.6.0_37\jre\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;F:/Program Files/Java/jre6/bin/client;F:/Program Files/Java/jre6/bin;F:/Program Files/Java/jre6/lib/i386;C:\Program Files\AMD APP\bin\x86;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Windows Live\Shared;C:\Program Files\QuickTime\QTSystem\;.;F:\Program Files\Java\jdk1.6.0_37\bin;F:\apache-maven-3.0.4\bin;;F:\eclipse-juno;;.
10 Dec, 2012 9:10:46 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8090"]
10 Dec, 2012 9:10:46 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
10 Dec, 2012 9:10:46 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 484 ms
10 Dec, 2012 9:10:46 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
10 Dec, 2012 9:10:46 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.33
10 Dec, 2012 9:10:46 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8090"]
10 Dec, 2012 9:10:46 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
10 Dec, 2012 9:10:46 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 211 ms
But when i try to access my application it gave me ERROR 404, File not Found.
I checked the application TOMCAT_HOME/webapps there i found both my war file and a folder of same name - "JavaServerFaces"
TOMCAT_HOME/webapps directory :
The Server is ON, war file is present, A folder structure is generated, but still i am not able to access my application which gives
HTTP Status 404 - /JavaServerFaces/xhtml/hello.xhtml
Any solutions for proper deployment and running of war file on tomcat 7?
In your console message, I do not find the deploying of "JavaServerFaces.war".
In eclipse,
open your server setting file,under "Server Location " check if the option "Use tomcat installation (.......) ".
if it is checked, then check the deploy name if it "webapps". if not then, change it to "webapps".
And if, this all are correct, then possibly your .war file is making fault.
There is problem with tomcat to start or stop with eclipse.
Its best to start and stop tomcat with the bat files in bin folder.
There are 3 steps to find error
1) copy the folder name which contains all application file and paste it into url. Now copy your servlet application url from web.xml and paste after folder name. If that works that means your Servlet application have some error..see the server console
2)On clicking on your application name in Manager App, and then your html file didn't run then there must be error in you your xml file try to rename your html file to index.xhtml
3)4** error shows that there is an error on xml or html file. while 5** series error shows there is error in your tomcat server.
Check the server setting in your eclipse. Check where the Configuration path is pointing. Also notice the Server location. By default it's Workspace Metadata, so set it to Tomcat Installation in your case.

tomcat not starting

suddenly for some reason tomcat server is not runnin/starting/stopping.
below is the result I get when i run the startup command,
C:\Program Files\jasperserver-3.5.0\apache-tomcat\bin>startup
Using CATALINA_BASE: C:\Program Files\jasperserver-3.5.0\apache-tomcat
Using CATALINA_HOME: C:\Program Files\jasperserver-3.5.0\apache-tomcat
Using CATALINA_TMPDIR: C:\Program Files\jasperserver-3.5.0\apache-tomcat\temp
Using JRE_HOME: C:\PROGRA~1\JASPER~1.0\java\jre
The tomcat window pops up for a split of a second and goes away.
(I have another java instance installed under c:\program files)
Help!!!
Update:
Logs from catalina file
Mar 22, 2011 3:41:50 AM org.apache.coyote.http11.Http11BaseProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Mar 22, 2011 3:41:50 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1017 ms
Mar 22, 2011 3:41:51 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Mar 22, 2011 3:41:51 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.20
Mar 22, 2011 3:41:51 AM org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
Mar 22, 2011 3:42:06 AM org.apache.coyote.http11.Http11BaseProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Mar 22, 2011 3:42:06 AM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Mar 22, 2011 3:42:06 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/43 config=null
Mar 22, 2011 3:42:06 AM org.apache.catalina.storeconfig.StoreLoader load
INFO: Find registry server-registry.xml at classpath resource
Mar 22, 2011 3:42:06 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 15374 ms
Use catalina.bat run instead of startup.bat. Then the window won't go away and you can see what's going on
In my case that was a problem with final slash in %CATALINA_HOME% path: final slash should not be there!
C:\tomcat\8.0.30 - correct
C:\tomcat\8.0.30\ - wrong
See http://blackandwhitecomputer.blogspot.de/2015/09/tomcat-debug-cannot-startup.html
Honestly, I had not expected modern applications may be depended on final slash in environment variable path!
I ran into a similar problem. I open cmd prompt and cd to tomcat\bin\startup.bat. The issue was my JRE_HOME not defined in the environment variables. I added and it worked.
I had the same problem and I solved it this way:
First, following #ykaganovich suggestions, I tried to start the server using the catalina.bat start command; it did not solve the problem, but at least it showed a log that specified the error, which was really helpful.
In my case, the log said that the problem was because of the java versiĆ³n. I had the JAVA_HOME variable pointing to the JDK7, but my tomcat version needed it to point to the JDK8.
I changed the JAVA_HOME variable to point to JDK8 (instead of JDK7) and then , when I executed the catalina.bat start command again, it worked perfectly and the server started. I hope my suggestion could be helpful to someone.
Hmm it's very strange problem because in the log you have that server started, so try this:
restart computer :) - the best solution for strange situations
change tomcat port
close every unnecessary applications: skype, ip phones etc (I've encountered similar problem someday and application ip phone "softly" blocked this port ("softly" - in tomcat log everything was OK but in reality webapp doesn't work)
Add tomcat in your eclipse and start it from there. Configure tomcat as 'Use Tomcat installation'. It will work
Had same problem with apache Tomcat 9 version.
Solution very simple.
Apache Tomcat 9 is supported by Java 8 and later versions.
So, i had JRE_HOME with JRE7 path, I binded it to new JRE8 and everything works fine.
Different versions of Apache Tomcat are available for different versions of the Servlet and JSP specifications. The mapping between the specifications and the respective Apache Tomcat versions is:
Hope this will work for you guys, cheers!
If Tomcat was earlier working fine and Tomcat not starting happens unexpectedly, it's because some other process has started using the port you were using Tomcat on. In my case, I had shutdown Tomcat and was trying to run my servlet directly from Eclipse. So Eclipse took control of the port. After I closed Eclipse and tried restarting Tomcat (with startup.bat), everything worked fine.
ykaganovich's answer helped me track down my issue.
Non of the solutions above worked for me.
I found my way out by removing my current tomcat and replace it with a new one and setting up again my workspace.
I hope this may help someone
Open up the Tomcat users file (tomcat-users.xml)and check that you've closed all your speech marks. That is what fixed it for me.
Now double-check the role names:
<tomcat-users>
<role rolename="admin" />
<role rolename="manager" />
<user username="admin" password="secret" roles="admin,manager" />
</tomcat-users>
Finally, execute startup.bat file from bin
Try to open Tomcat7w.exe or follow the below steps.
(I have installed Tomcat under folder C:\Program Files\Apache Software Foundation\Tomcat 7.0)
open command prompt as Administrator
run --> "C:\Program Files\Apache Software Foundation\Tomcat 7.0\bin\Tomcat7w.exe" //MS//
now you can see icon in the system tray
double click on icon and start/stop

Categories

Resources