Custom TeamCity plugin is uploaded but doesn't seem to get executed - plugins

I'm developing a TeamCity plugin and I fail to even get it executed by TeamCity.
I upload the zip file with the plugin and restart TeamCity, then I can see the plugin on the list of external plugins, it also gets unpacked into .BuildServer/plugins/.unpacked but other than that nothing happens.
It doesn't seem that the plugin is running. (I don't even see the plugin name in any logfile)
My simplest attempt was to just create a plugin from maven archetype:
mvn archetype:generate -DarchetypeRepository=http://download.jetbrains.com/teamcity-repository -DarchetypeArtifactId=teamcity-server-plugin -DarchetypeGroupId=org.jetbrains.teamcity.archetypes -DarchetypeVersion=RELEASE
and then only add some logging:
package com.example.plugin;
import jetbrains.buildServer.log.Loggers;
public class AppServer {
public void run() {
Loggers.SERVER.info("I'm running");
}
}
and create the necessary bean with init method:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
default-autowire="constructor">
<bean id="appServer" class="com.example.plugin.AppServer" init-method="run"/>
</beans>
I upload the plugin, restart TeamCity but the log message from AppServer does not appear in any logfile.
What am I missing? How to log this message?

I would expect to see an exception (plus a stacktrace) in the teamcity-server.log file. Are you sure you checked that file?
The behaviour you're describing can be symptomatic of you having built the plugin with a JDK version incompatible with TeamCity's JRE. For example, you build your plugin with Java 8 but your TeamCity is running under Java 7. In that case, the plugin will be detected (as it is in your case) but will crash when TC tries to invoke it.

Related

How do I get JBoss AS 7.2 to register my OSGi services when the bundle is loaded?

I have created a small sample project to have a reference implementation of OSGi with Spring (i.e. Blueprint), and I can get all bundles to install, resolve and start OK, but my service is not registered when the bundle starts.
I've made the entire project available on github so you can take a look at the source - the jars output from the build are in the artifacts folder, but you can also build the project yourself by running gradle assemble.
As I've understood the Blueprint specification, and particularly this guide, there is no need for an activator class to register the services if the configuration files are in the right place - in my jar, I have the following under OSGI-INF/blueprint/sillyservice.xml:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<bean id="sillyService" class="se.sunstone.silly.service.ServiceImpl"
init-method="startService">
</bean>
<service ref="helloservice"
interface="com.sample.blueprint.helloworld.api.HelloWorldService" />
</blueprint>
When deploying this bundle, JBoss reports the bundle as ACTIVE.
When I then deploy the client bundle, there is an activator class that runs the following snippet to list all registered services:
ServiceReference[] refs = context.getAllServiceReferences(null, null);
if (refs != null) {
logger.info(String.format("There are %s references", refs.length));
for (ServiceReference ref : refs) {
logger.info(ref);
}
} else {
logger.info("There are no registered services.");
}
A bunch of services that are registered by the OSGi framework inside JBoss are listed, but not my SillyService.
What do I need to do to make this work?
To enable Blueprint functionality, you need to install a Blueprint Extender bundle. There are two implementations available: Apache Aries and Eclipse Gemini. I recommend Aries, which is available from http://aries.apache.org/

Spring context:component-scan fails to find components in another Eclipse project dependency referenced in POM

I am working on a GWT web application split across two Eclipse Projects (myclient & myservice).
The myclient project references the myservice project via a dependency in the POM.
<dependency>
<groupId>com.myproject</groupId>
<artifactId>myservices</artifactId>
<version>1.0.0</version>
</dependency>
The myclient project has a WAR directory src/main/webapp. The output folder for the myclient project is src/main/webapp/WEB-INF/classes.
The myclient project has a Spring descriptor application-context.xml with the following
<context:component-scan base-package="com.myproject.myclient, com.myproject.myservices"/>
and the web.xml
<web-app>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/application-context.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
...
</web-app>
I have several files in the myservices project annotated as spring #Component, #Service, #Configuration but these are not picked up by the component scan when I run the GWT application in Eclipse. As a test I experimented with placing an #Component in the myclient project and this was successfully created.
I believe the following log entry during application startup indicates the source of the problem
org.springframework.core.io.support.PathMatchingResourcePatternResolver - Resolved location pattern [classpath*:com/myproject/myservices/**/*.class] to resources []
the location pattern for the myclient project resolves to all the resources on the classpath but for myservices no resources are found.
I experimented with building the myservices project JAR and placing this JAR into the src/main/webapp/WEB-INF/lib folder of the myclient project. When I do this the component scanning works. However for development I don't want to have to build and copy a JAR everytime I make changes to the myservices project. I imagine that the component scanning should work on a project referenced through the POM without having to the build that project but after much experimenting I have been unable to get this working.
Be sure that in the deployment assembly (right click your web project and select "deployment assembly" of your myclient project it is configured to deploy the jar that is outputted by the myservices project. If you are using maven, the m2e, m2e-wtp project configurators should do this deployment assembly setup automatically.
Once you have deployment assembly settings properly configured, now when you deploy a project to your server using the Eclispe server adapter publish mechanism, everything should get deployed and the myservices jar would get placed in the right spot for your myclient project.
But make sure you the latest version of m2e-wtp installed. This way your configuration in your pom.xml and deployment assembly will get correctly configured.
Try splitting your application-context.xml into 2 separate files:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:service-context.xml,classpath:client-context.xml</param-value>
</context-param>
myservices/src/main/resources/service-context.xml:
<context:component-scan base-package="com.myproject.myservices"/>
myclient/src/main/resources/client-context.xml:
<context:component-scan base-package="com.myproject.myclient"/>
Try this :
<context:component-scan base-package="com.myproject"/>
Please check the following things:
Is your serviceproject present "only" as jar or is the whole project available via workspace resolution. This can be checked via maven-context-menue (Disable/Enable Workspaceresolution)
The layout of the webapp under src/main/webapp is okay. BUT do i get you right that all classes are copied there? If so, you should make sure everything is under target directory. So please check whether a maven call "clean package" generates a webappstructure under the target folder and all required libs (e.g. myservice) exist under target\$your-webarchivename\WEB-INF\lib
Check that packaging in myservice pom.xml is set to jar (you probably have this, right?)
it's obvious that your service jar is not included in your client project's build path. this is the only root cause.
Make sure 3 points:
you have run mvn clean install under your service project which has correct pom.xml.
you have run mvn eclipse:eclipse under your client project. this will pull out all your dependency project.
check your client eclipse project's build path dialog. is there your service jar in the list? Make sure this
You better once look this tutorial
http://fusesource.com/docs/framework/2.2/deploy_guide/CXFServletDeploySpring.html

failed to run wicket examples on tomcat7

I downloaded wicket examples 1.6.0 and built successfully in netbeans7.2. but got errors when I tried to deploy on tomcat 7:
Cannot deploy the module. The context.xml file seems to be broken. Check whether it is well-formed and valid.
The module has not been deployed.
See the server log for details.
at
org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:210)
at
org.netbeans.modules.maven.j2ee.ExecutionChecker.performDeploy(ExecutionChecker.java:178)
at
org.netbeans.modules.maven.j2ee.ExecutionChecker.executionResult(ExecutionChecker.java:130)
at
org.netbeans.modules.maven.execute.MavenCommandLineExecutor.run(MavenCommandLineExecutor.java:212)
at
org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
heres the contents in context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<!-- <Loader className="org.atmosphere.util.AtmosphereClassloader"/> -->
<Loader delegate="true"/>
</Context>
I prefer to run wicket in eclipse as it negates the requirement to mess around with an external tomcat instance.
If you are comfortable with eclipse and maven i would download wicket 1.6 example archetype via maven, import into eclipse and then in the test directory you can run the run.java class to get an internal jetty server host wicket for you.
this should get you started quickly without having to wrestle with tomcat configurations too.
Not really an answer but an alternative route to the same end point
Add parameter path to context tag, same path that app will be served:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/application-path-name/">
<!-- <Loader className="org.atmosphere.util.AtmosphereClassloader"/> -->
<Loader delegate="true"/>
</Context>
Answer obtained from this question.

How to enable compile-time aspectj weaving for Eclipse embedded Tomcat

I'm having a problem trying to make eclipse and aspectj work for Dynamic Web Projects. I'm looking for compile time weaving so I can use the Eclipse Visualisation features.
I've followed the steps given here:
https://forums.oracle.com/forums/thread.jspa?messageID=8591748
using Eclipse Indigo (3.7) with the latest Aspectj eclipse plugin (2.1.3).
The steps were as follows:
[1] Create basic servlet
//imports omitted
public class MyServlet extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response){
PrintWriter out= null;
try {
out = response.getWriter();
out.write("hello from MyServlet");
} catch (IOException e) {
e.printStackTrace();
} finally {
if(out!=null)
out.close();
}
}
}
[2] Add servlet to deployment discriptor (web.xml)
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>com.myCompany.MyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/MyServlet/*</url-pattern>
</servlet-mapping>
</web-app>
[3] Create aspect
package com.myCompany;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public aspect MyServletAspect {
pointcut doGet() :
execution(public void MyServlet.doGet(HttpServletRequest,HttpServletResponse));
after() returning : doGet() {
System.out.println("Hello from doGet (via aspectj)");
}
}
However when I run this no dice - the aspect just doesn't run (servlet writes to response, aspect to console). I did something similar for a regular java project and that works fine.
I note there are guidelines for adding aop.xml into the web app's META-INF directory, however this didn't work for me.
Our goal is to run aspectj non-invasively in development via eclipse for a non-Spring framework (or Maven) project - this should be easy.. but I haven't been able to make it work.
Any suggestions / reference to tutorial for compile-time weaving for web apps in eclipse would be useful. The app server is embedded Tomcat 6 (but can be upgraded to tomcat 7 if required).
The ability to tweak the development environment at runtime without impacting the production code would be great - if it can be made to work.
Responses much appreciated.
I recommend you just download and use Spring STS (Spring's Eclipse) and download/create a Spring Roo project.
Your just going to use the Roo project to boostrap your own project with the correct AspectJ libraries. That is you'll just use its pom file that it generates. You can try to use plain Eclipse and download all the plugins (which is what I do) but its PITA to get everything setup correctly.
The key thing is to get the AspectJ compiler to run instead of the regular Java compiler. This requires a special Maven plugin or Ant plugin. Also you do not need the aop.xml file.
If your using Eclipse you need to make sure that the AspectJ nature is added to the project (usually you right click on the project and select "add natures" "Or convert to...".)
You'll also in Eclipse need to add the Spring Aspects jar to the "Aspect Libraries" which is not the classpath/buildpath.
To use compile time weaving in maven, you need to use the aspectj compiler plugin. See this:
http://maven.apache.org/maven-1.x/plugins/aspectj/
To get your project working in Eclipse, you need to install the AspectJ project configurator for m2eclipse (assuming you are using m2eclipse). You can install it from going to Preferences -> Maven -> Discovery. Open the catalog and look for the AJDT configurator.

How can I deploy a web app with sbt 0.11?

it seems that both the jetty-run and jetty commands are missing from SBT 0.11. Either that or I am doing something very wrong. I am simply running sbt, then trying to run jetty-run. I have defined a web.xml file in src/main/webapp/WEB-INF/web.xml which contains the following information:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"> </web-app>
I am simply trying to deploy a blank web-app using the latest SBT. I cannot find any documentation or updated examples for doing so. Any ideas?
Thank you in advance.
Starting from sbt 0.8 (xsbt branch), if I remember correctly, web support goes as a standalone plugin. Here you can find instructions on how to install and use it. In general, this new plugin fully supports the regular workflow of a legacy SBT (e.g., jetty-run, jetty-reload, etc.).