Running GWT Speedtracer without Jetty - java

We are trying to run the GWT (2.1) Speedtracer, but have trouble with it, since Jetty doesn't accept our JDBC resources (they work fine in Tomcat) - probably because the JAR containing the drivers is not found by it.
Is there a way to make the GWT speedtracer run without the Jetty Server?
Or how do I make the web.xml/context.xml compatible with both Tomcat and Jetty?
I would prefer to run it in Jetty - as long as this won't cause problems with tomcat.

If you want to use Tomcat:
The GWT documentation mentions, that you can use Speed Tracer on the server-side with the SpringSource tc Server (which is a Tomcat server).
If you want to use Jetty:
Using DataSources with the embedded GWT Jetty server is possible, but not easy. It's explained in this Google Group post for GWT 1.6. I have tried this with GWT 2.1, and it basically remains the same procedure. Here's a quick outline:
enable JNDI for the embedded Jetty:
add jetty-naming-*.jar, jetty-plus-*.jar
modify the JettyLauncher,
add the VM arg -Djava.naming.factory.initial=org.mortbay.naming.InitialContextFactory (or use jndi.properties)
create a jetty-env.xml (similar to Tomcat's context.xml)
define a resource-ref in the web.xml

Related

Java Spring MVC deploy .war on GlassFish

At first i want to say that i'm a beginner in java servers and never deploy an java .war app on server other than localhost in my intellij.
I have a simple only REST app Which work fine in localhost, i also created war file and deploy it by command "asadmin deploy --port 4849 war_name", but when i go into url http://stachurskipiotr4.usermd.net/cookbook-1.0-SNAPSHOT there is an server error.
I completely don't know what it is, i will be grateful for any help.
Access the domain port for that case. Default is 8080 if you haven't configured.
http://stachurskipiotr4.usermd.net:8080/cookbook-1.0-SNAPSHOT
Also, please use or log in your admin console to see the apps if it's deployed. You can also access it directly from there.
Glassfish already provides the Jackson libraries and the version conflicts with the one Spring depends on. Glassfish is an enterprise container, is there a specific need for the enterprise container? Try a regular servlet container like Tomcat instead. If you do want enterprise, maybe you shouldn't need using Spring
EDIT:
Removing jackson jars from your project won't help you; Spring code wants the version it wants. You can try to find out which version Glassfish provides and then see which version of Spring depends on that and use that version of Spring. This is a wrong thing to try as this will be just the tip of the iceberg. Do not try to deploy Spring code in an enterprise container, these are competing specs.
Your options are
1) figure out why is Tomcat not working. Tomcat is a battle-tested servlet container with thousands of production deployments.
2) Try a different servlet container such as Jetty.
3) Rewrite your code to the JEE specification and deploy to an enterprise container such as Glassfish or Wildfly (there are others).
4) Use Spring Boot to embed the container and package your app as an executable jar.
EDIT2:
If you chose Spring Boot, your artifact will be an executable jar, you do not deploy it into a container since the container is embedded. You start the jar via a java command. You remove the container from your deployment entirely. I don't know your deployment environment, but you do not use Glassfish at all at this point, you have to run the java command to start the server.
If Glassfish is a requirement, you have to rewrite your code

Tomcat and OSGi

I was wondering if it is possible to embed an OSGi container like Karaf inside a Tomcat instance. According to this SO question and a few others, it seems like its possible, but I can't seem to find any solid details on how to do this or what pitfalls/caveats to watch out for.
So:
Is it possible to embed an OSGi container inside Tomcat, so that I can hot-deploy OSGi bundles at any point to this container without having to restart Tomcat?
If the answer to #1 above is "yes", then what system services/ports does embedding OSGi inside Tomcat expose? I ask because I would like to deploy OSGi in a Tomcat server hosted on a Java PaaS where I don't have admin rights. And I'm wondering if - when I try to deploy the embedded OSGi container to Tomcat, that it will try to start listening on ports, or perhaps start doing something to the local file system. If this is the case I will likely receive security/permission errors.
Thanks in advance!
Is it possible to embed an OSGi container inside Tomcat?
Yes. In fact if you download Karaf and look in <KARAF_HOME>/demos/web you'll find a demo project that does exactly that.
what system services/ports does embedding OSGi inside Tomcat expose?
That would depend on what you install in it and how you configure it. Here is somewhat old (but IMHO stil relevant) discussion about default ports and how to configure them.
We deploy our application in the same fashion. We have deployed karaf in tomcat & on weblogic using a servelt bridge. The reason for using the container was to get past environment constraints where some customers are a "oracle" or an "ibm" shop and want all deployments done on these servers.
Since you will be using a servlet bridge it does not need to open a new port to list to http traffic. You may have issues with the karaf console if that port is blocked. Also I recall having issues with running cxf due to an embedded jetty instance it starts on another port.
Other than the ports you will need a karaf home directory with write access.

glassfish, tomcat and jersey

If I use Glassfish and only need jersey for jax-rs and grizzly for servlet/jsp, will glassfish load all other Java EE components I don't need and take more up more resources than just running jersey/tomcat or will glassfish just load jersey/grizzly and will use almost the same resources? I have tried running starting default glassfish and default tomcat, glassfish takes much more ram.
Is there any reason not to run jersey with tomcat? maybe because the integration is done better by Glassfish?
There are lots of people who use Jersey with Tomcat. Tomcat is a servlet container only but will not interfere with other Java EE technologies that you choose to support through other means (e.g. Jersey). You may have to manage some of the initialization of the frameworks, etc. that other full-J2EE containers like Glassfish already provide, but it shouldn't be too painful.
You can use the 'web profile' to help minimize the download, initial memory and start-up time.
The most recent web profile is http://dlc.sun.com.edgesuite.net/glassfish/3.1.2.2/release/glassfish-3.1.2.2-web.zip
The start-up time is between Tomcat and the GlassFish 'full' profile.
The web profile includes an integrated implementation of Jersey.

mod_pagespeed and java app servers

Can one use mod_pagespeed with tomcat application server? directly or indirectly?
Am i correct in stating that you can use mod_pagespeed with tomcat if you use apache webserver as a proxy to tomcat webserver? (does this work with mod_jk?)
You can use mod_pagespeed with Tomcat. You're right that you'll need to use Apache as a proxy to Tomcat. I know that it definitely works with mod_jk since we use it in production. I assume it also works with mod_proxy and mod_proxy_ajp, however I can't confirm those.

How can I embed Weblogic server in java?

I am searching any way for embedding Weblogic server in Java , I know its possible because we have maven plugins for Weblogic which embeds Weblogic in maven, But googling for it did'nt gave me useful output, Does anybody know how can we embed wemlogic in java program ?
WebLogic doesn't provide an embedded API so, even if it's a pure Java Server and if you can thus call weblogic.Server from Java code, you will have to handle everything yourself (starting the container, waiting until it's started, deploying things, waiting until they are deployed, etc). In other words, this will require some work.
Maybe have a look at the sources of Cargo, although Cargo isn't really starting an embedded Weblogic (i.e. running weblogic.Server in the same JVM). This will give you an idea of what has to be done. Or, depending on your needs, use Cargo Java API.
But if you need a full Java EE server and if this is an option, I would use GlassFish v3 in embedded mode instead of WebLogic, it will be much simpler. Check the following links and see yourself:
Embedding Glassfish V3 in Unit Test - Two Jars, Three Lines Of Code And Five Seconds Start With Deployment
Embedding EJB 3.1 Container Into Your Unit Tests - Boot Time: 5 Seconds
Using the EJBContainer API with or without Maven (but with GlassFish v3)
TOTD #128: EJBContainer.createEJBContainer: Embedded EJB using GlassFish v3
Do you need WLS specifically, of any servlet container would do? If the latter is OK, then use Jetty.
WLS is not designed to be embeddable. But you can do it. After all, WLS is just a class named weblogic.Server. Setup classpath correctly, setup PATH and other environment variables (see setDomainEnv.sh and startWeblogic.sh), start that class from Java, and you have an "embedded" WLS.
There is probably a way, but I don't know it. My experience from writing maven plugins tells me that the most likely way that the plugin works is that it starts up a new command line process just like you would normally start up the server. So in a sense, not really embedded it.
The best way to see is to track down the source of the plugin and see how they did it.
WebLogic doesn't support embedded mode like Glassfish but you can have control over your Weblogic using "WebLogic Maven Plugin", this provide several maven goals for managing and working with Weblogic instance.
See this link for further information.

Categories