Win a copy of Java XML & JSON this week in the XML and Related Technologies forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Making my webapp accesible by public domain (using xampp)  RSS feed

 
Master Rancher
Posts: 1042
17
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All
I'm hosting my own website, using xampp, that part works great. My website is online and runs like it supposed to, that website is only html and js (and css of course) and it runs on the appache webserver from my xampp installation.
Now I'm creating a webapp in java, my intention is to simply have a link on my website that points to the war of my app.
When I try to deploy directly to my tomcatserver the installation fails,

Stacktrace when deploying from intelij:

but if I remeber coreectly (it's bin a long time since I tinkered with tomcat) alternatively you can just build your project with maven and put the war in de webapps folder of your tomcat.
My maven build is successfull, but when I place the war in the mentioned folder in it's own subfolder and go to localhost:8080/myApp or any other adress on my server I just get a blank page, not a whitelabel error, just a page with no content
I've seen comments online that say I should surf to localhost and don't specify the port, but that points to my webserver not my tomcat

These are the logs of today:

The acceslogs:

Catalina:

ANyone an idea?
 
Master Rancher
Posts: 3887
45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the root cause:
.ClassFormatException: Invalid byte tag in constant pool: 19

What version of Tomcat and Java are you using to run Tomcat?
 
Daniel Demesmaecker
Master Rancher
Posts: 1042
17
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java 8.0.191
Tomcat: 7.0.56, I know it's an old one, but it came with my xampp installation.
I also should mention, when I run the app as an application in intelij, everything works fine, and I can see in my xampp controlpanel that it uses that tomcat
 
Dave Tolls
Master Rancher
Posts: 3887
45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Going by this SO thread:
https://stackoverflow.com/questions/23541532/org-apache-tomcat-util-bcel-classfile-classformatexception-invalid-byte-tag-in

There are issues with annotation scanning and code compiled with Java 8.

Don't know why the IntelliJ one works, if it's the same version.
 
Daniel Demesmaecker
Master Rancher
Posts: 1042
17
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So since it's caused by my tomcat version, and you're right it was, I removed my xampp provided tomcat and installed a newer one. The deployment was succesfull (and way faster then with tomcat 7), after which my browser window opens and I'm getting this error:

It normally just should return my indexpage right?
When I look in the rootfolder of my tomcat I can't see the war eather
Same thin when I put my war manually there
 
Dave Tolls
Master Rancher
Posts: 3887
45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where exactly are you putting the war file?
 
Bartender
Posts: 20307
110
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Daniel Demesmaecker wrote:
Now I'm creating a webapp in java, my intention is to simply have a link on my website that points to the war of my app.



Technically, that's not what you'd do. For one thing, a WAR isn't an application, it's an application deployable package. You can even use the same package (WAR) to create multiple application instances in the same Tomcat server. Something most of us don't do, but you might if, for example, you had multiple customers and each would be running their own copy of the app.

Also, since you have Apache as part of your stack, it's actually a lot tidier if instead of linking from Apache apps to Tomcat apps that you use an Apache/Tomcat proxy.

There are 2 different proxy options available these days: mod_proxy, and mod_jk. The mod_proxy module is simpler to use in my opinion, although I think mod_jk is probably more powerful if you need very heavy distributed workloads. Actually, it appears that mod_jk is also recommended if you have lots of static content in your WAR.

Actually, what you build is a [i]reverse proxy[/b], when the client sees a URL assigned to a Tomcat webapp, translates that URL to its Tomcat equivalent, and forwards the request down an internal network pipe to Tomcat (port 8081).

You get several benefits from this:

o   First, since unless you send an HTTP request to port 80 or an HTTPS request to port 443, your URL would have to include an explicit port number (such  as 8080 or 8443 for Tomcat). And you'd have to have additional firewall ports opened to allow the request to come in to the server.

o  Secondly, you can have Apache handle the HTTPS/SSL. That eliminates the need for installing a separate cert on the Tomcat server. Or a keystore or configuration of port 8443). Much less work.

The only downside to this is that you have to ensure that ProxyPass and ProxyPassReverse are properly configured or Bad People can exploit your Apache server as an email spammer.

Well, actually, there's one more downside. Since the URL that people actually request is going to be different from the Tomcat URL, you need to make sure that any links that the webapp presents point at the external URL, not the internal URL (which won't be visible on the open Internet).

Just as an example of how that works:

Apache URL:

https://myserver.com/mickey/images/mouse.jpeg

Tomcat URL:

ajp://internalserver:8081/minnie/images/mouse.jpeg.

The proxy module has re-routed the request to another machine hidden behind the firewall, and the application that the world sees as "mickey" was actually deployed as "minnie.war" (assuming Tomcat default URL context rules)

The actual proxy defintion in Apache would be like this:



You can put Apache and Tomcat on the same machine and use "localhost", too. People often do.

Here's the details for Tomcat 7, which for some reason was what Google brought up first, but should be about the same for any version of Tomcat.

https://tomcat.apache.org/tomcat-7.0-doc/proxy-howto.html
 
Daniel Demesmaecker
Master Rancher
Posts: 1042
17
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It was actually the last suggesting that I was trying to do, it seems redundant to try set up a proxy if I can't even install my webapp on my tomcat. I also thought of rewritting the program to merge the website with the app, so everything would be on one project and I would only have to use tomcat, but that would take a lot of work
 
Tim Holloway
Bartender
Posts: 20307
110
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
XAMPP implies that you're expecting a lot of non-Java stuff, since the main virtue of Apache is that it can serve up apps from other platforms (for example, PHP and Perl - the "PP" part).

However, an Apache, Nginx, or other standard webserver as a proxy for Tomcat is a good thing, regardless. To avoid making people type ":8080" on their URLs, you'd have to re-configure Tomcat to listen on port 80 (and 443). Which would require Tomcat to run as a privileged user, since ordinary user's cannot listen on ports below 4096. And that's a serious security issue.

Apache, nginx, et. al. don't have that problem, because although they launch as privileged users, as soon as they have their listening ports opened, they switch to a non-privileged user context. Tomcat cannot do that, because there's no "write once/run anywhere" way to switch user IDs - it's very OS-dependent. So by using a (reverse) proxy ahead of Tomcat, Tomcat can run on safe ports as an unprivileged user and still use the default URL notation.

And no, you can't put "8080" in DNS. DNS only returns IP addresses. Port numbers are assumed by convention on the clients.
 
Daniel Demesmaecker
Master Rancher
Posts: 1042
17
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think xampp wasn't a verry good choice to begin with, it only comes in 32bit version and the servers supplied are pretty old, but it took some doing to configure the webserver since I don't have a static ip, everything is working now so I don't feel like starting over
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!