Using Spring Aspects with Jetty - spring

I have an application that uses Aspects with Spring 3.1. It runs perfectly with Tomcat 7. The advised methods get called as expected.
I want it to work with Jetty. I've previously used Aspects with Spring 2.0 and Jetty with no major problems apart from adding a JVM agent. However I've had no luck with Jetty 6.22 and my Spring 3.1 application. I start Jetty with the javaagent thus
-javaagent:./spring-instrument-3.1.3.RELEASE.jar
where the Spring Instrument jar is in my CWD.
There is a similar question on StackOverFlow but no-one was able to come up with a working answer.

First of all, I'd highly recommend to use jetty 9 instead of jetty 6. Jetty 6 is End of Lifetime since a while now and it's missing lots of features and bugfixes!
Besides that, are you using the --exec option somewhere in your configs? That will start a second jvm and probably that second jvm is not started with the javaagent setting place. You could verify that with "ps -ef | grep jetty" on *nix systems.

Related

How to use Jetty Quickstart in spring-boot?

Jetty's startup-time can be decreased by using it's ability to Quickstart.
I am using spring-boot, in special, my spring-boot project does not use the default Tomcat, but Jetty.
How can I use Jetty's Quickstart feature in a spring-boot (using Jetty) project?
I managed to to run my spring-boot application, as a dedicated webapp in a Jetty, which uses Quickstart (all done via docker).
It is not worth it. The described setup is still slower than using embedded-Jetty from within the application (the setup was of course even slower, not using Quickstart).

Writing a JSF based spring boot app so that it can also run on a Java EE app server without change

Spring boot is great - we have an app that runs standalone fine, using JAXRS 2, JSF 2.1.6. They versions are irrelevant really, other than they are under our control.
Our corporate deployments are on fully blown Java EE app servers though, so we don't have the option of deploying the app to something simple such as Tomcat or even as a jar with embedded Tomcat.
Trying to get a Spring boot app to work on these ends up being a world of pain, as the Java EE app server will either stop you completely or partially from using different versions of jars to the ones it ships with.
So my question is, is there a magic bullet that allows Spring boot apps to fully blown app servers like WildFly,Glassfish etc. Or what are the general approaches to getting around this issue?
The only one I can think of is to code the application to exactly the same spec as the app server, and then use Maven profiles to ship the jars for the embedded up, but to have them as provided when using them in an app server. Of course this immediately takes away the advantage of Spring not being tied down to a particular version of Java EE.

How do i migrate application from Tomcat 6.0.35 to JBoss AS 7.1.1

Is there any tool or set of guidelines to migrate application using Spring, from Tomcat 6.0.35 to JBoss AS 7.1.1 ? Or is it better to just host app in JBoss and work backwards to fix issues one by one as suggested by some?
There is a migration center, but it says Tomcat is coming soon.
The biggest issues you would likely face are dependencies that you've included in your application that JBoss AS or WildFly already include. This is a little old, but might be helpful too.
Other than that it's tough to say what would need to be changed without knowing your environment and current configuration. The main idea behind Java EE is ideally it should work on any application server. That said, Spring isn't a Java EE standard and Tomcat is just a servlet container :) Not that there is anything wrong with either.

does Spring Insight need tcServer, or can it work with Eclipse and Tomcat?

does Spring Insight need tcServer, or can it work with Eclipse and Tomcat? I see some tutorials on Spring Insight, but all of them seem to use tcServer.
Technically, Spring Insight does not need tcServer to do its work. It can work with JBoss and other containers. However the easiest packaged solution for VMware is to distribute it as a template for tc Server. VMware does not document the classpath / JVM settings / setup needed for Insight to run with other containers. Again it's technically possible, but not currently supported. I believe that configuration will be out as supported in the near future (within a month or 2)
Since tc Server is free for developers and essentially the same as Tomcat, why can't you use it with tc Server? The integration is quite nice (especially with STS/Eclipse)

Any issues migrating from JDK6 to JDK7 with Spring & Tomcat?

I'd like to take advantage of some JDK7 features. What issues might I run into given that I use Apache Tomcat 7.0.x (latest) and Spring 3.1 (latest)?
There were a few compilation gotchas where JDK 6 could infer the generic type properly where JDK 7 could not. This was apparently a bug in JDK 6 as referenced here.
If you are using container-specific resources (e.g., data sources, etc.) be sure to verify these are still operating properly (though this will be immediately obvious on Spring startup if any of these are wired in).
If you are using Spring Security, and you upgrade, you do not need to make any changes per se to get get things running. However, you should take advantage of their less verbose configuration options (especially for REST URL's) that are available in Spring Security 3.1.
Other than that, our upgrade was seamless.
With the last Ubuntu update (11.10) I switched to JDK 7 (OpenJDK 1.7.0_147). I'm using Spring 3.0, Tomcat 6, and JRE 6 on the server (we have both VM and "physical" server installations). The code, compiled with JDK 7 runs on this configuration without any problems. I'm sure, switching to Spring 3.1 won't cause any changes. Not so sure about Tomcat 7, but hopefully this information will be useful to you.
You might run into a problem if you're using Java 7 features in a JSP. Tomcat by default user Java 1.6 for JSP compilation. See http://tomcat.apache.org/tomcat-7.0-doc/jasper-howto.html#Production%20Configuration
To solve the problem you'll want to override the compilerSourceVM and compilerSourceVM init parameters in your application's web.xml file. More on that here: https://stackoverflow.com/a/20194823/1029261

Resources