Maven install - SQL problem / suitable driver - sql

I have two Maven Project with exactly same code.
I'm running project number one just from public static void main method and it connects to database and works perfectly, but when I use maven install and try to run it as a plugin in BukkitMC server it tells me all the time
"no suitable jdbc driver found"
I have dependencies at pom.xml in both project the same, so I'm pretty sure it works.
It's just all about this MAVEN INSTALL.
Have you got an idea?
public static void main(String[] args) {
App app = new App();
app.insertData("INSERT INTO users (login,password,email) VALUES ('a','b','c');");
}

Basically install goal do also package goal.
In package your project is archived (eg:jar) and after on install is deploy.
Could check what is inside archive(jar) and if not any sql-driver then you could search for the appropriate way to be packages from maven also with driver.
Other option is to add driver maybe manually on your server.

Related

call pydev server from custom eclipse plugin

I am trying to build an eclipse plugin and want to start PyDev debugger server locally. Is it possible to make a call like this?
Calling the pydev server from the Handler's execute method:
#Override
public Object execute(ExecutionEvent event) throws ExecutionException {
//call PyDev Debug server from here
PydevRemoteDebuggerServer.startServer();
}
But, I'm getting an unsupported version error. (Tried updating the version on the class path and build. Yet, it results in same issue). Is the approach wrong or is it because of the variations in versions?
Please, correct me on this.
Add all the required pydev plugin jars. Though, I just wanted to start Pydev's Remote Debugger Server locally there are few other dependencies that needs to be handled.
Best way is to add these jars -
core.jar
pydev-debug.jar
shared_core.jar
debug.jar
Note: Update the class path after adding the jars.

Hot re-deployment of a RESTlet

I'm interested in setting up a super lightweight web server with Restlet mostly for proofs-of-concept and low impedance collaboration with other developers. A full servlet container feels too heavy. Literally, I'm starting with something pulled directly from the "Getting Started" guide.
public class Dummy extends ServerResource {
public static void main(String[] args) throws Exception {
new Server(Protocol.HTTP, 8182, Dummy.class).start();
}
#Get("json")
public String hello() {
ST hello = new ST();
hello.add("name", "World");
return "{ \"hello\": \"World\"}";
}
}
However, I'd like to be able to watch for changes and redeploy automatically as I change code. I know Jetty can do this with some config. Has anyone done this without setting up a full servlet container? Is there something simpler?
I use Eclipse as my IDE to edit the code and launch the app, but the ideal solution wouldn't rely on that.
This what I call Continuous Delivery.
In a nutshell:
I usually use
SVN or Git to store and version source code
Jenkins to schedule the build and deployment
Gradle or Maven to build and test
The SCM plugin is able to poll the repository and invoke the process only if there is changes, or you can trigger the build with a hook.
There are plugins to copy your artifact to the target server and restart the application.

TeamCity - Testing with JUnit

I am using Intellij Idea version 12 (ultimate). Just installed Team City (version 8). One default agent, running in linux.
I've created a very simple test application:
public class Main {
public static void main(String[] args) {
System.out.println("Hello World!");
}
public int sum(int x, int y) {
return x+y;
}
}
... and a very simple test...
import junit.framework.Assert;
import org.junit.Test;
public class MainTest {
#Test
public void testSum() throws Exception {
Main test=new Main();
Assert.assertEquals("Sum should be 7",7,test.sum(4,4));
}
}
If I run this in IntelliJ, the test gets run and fails just like it should.
If instead I commit this project and push it up to github, TeamCity sees the change and begins a build. The build fails fairly quickly with the following errors:
/home/ctb/TeamCity/buildAgent/work/742505fa88794219/test/MainTest.java:1: package junit.framework does not exist
import junit.framework.Assert;
^
/home/ctb/TeamCity/buildAgent/work/742505fa88794219/test/MainTest.java:2: package org.junit does not exist
import org.junit.Test;
^
/home/ctb/TeamCity/buildAgent/work/742505fa88794219/test/MainTest.java:12: cannot find symbol
symbol : class Test
location: class MainTest
#Test
^
/home/ctb/TeamCity/buildAgent/work/742505fa88794219/test/MainTest.java:15: cannot find symbol
symbol : variable Assert
location: class MainTest
Assert.assertEquals("Sum should be 7. Loser!!",7,test.sum(4,4));
^
So yeah, I see that TeamCity is not seeing JUnit.
On the TeamCity Discussion forum, one respondent to my question there asked me if junit.jar was added as a dependency (module or library) in the build. It was listed as a module dependency, but for kicks I tried it as a library dependency. I also tried checking and unchecking export and trying the compile and test scopes, but each time I get the same errors. My run configuration is shared.
I am not using Ant or Maven. Perhaps someday, but I'd like to start as simple as possible.
Clearly, I'm missing something, but the documentation on the subject is sparse.
Thank you.
So I heard back from Jetbrains tech support this and, in the interest of completeness and saving someone else the trouble, here's the response I received:
Seems the problem is that junit.jar is not placed in version control
under your project. In order to build your project on TeamCity agent,
the project ideally should be self contained. In your case junit.jar
only exists on your local machine, I suppose there is no such file on
agent at required location. So you have two options actually: put
junit.jar under version control into your project, or define global
library in IDEA and configure this global library on IDEA Project
runner page (Check/Reparse must be started), after that put library
files on all of the agents where your build will be executed.
Personally, I think the first approach is much simpler and better.
I added junit to version control and now the build works properly in TeamCity.

FindBugs shows only first error in method (Jenkins, IntelliJ IDEA)

I'm using Jenkins with FindBugs plugin installed for static code analysis. Also, every developer on the team have FindBugs IntelliJ IDEA plugin installed to do the same.
The problem is that in Jenkins, only first occurence of an error in a method is reported. In Idea, all problems are reported as single errors. For example:
public String myMethod() {
StringBuilder sb = new StringBuilder();
sb.append(String.format("First \n"));
sb.append(String.format("Second \n"));
sb.append(String.format("Third \n"));
sb.append(String.format("Fourth \n"));
return sb.toString();
}
in this method, Idea reports 4 errors of type VA_FORMAT_STRING_USES_NEWLINE. On jenkins server, there is actually only one error, on line with string First \n.
Is there a way to configure either Jenkins or Idea to behave uniformly?
Versions:
IntelliJ Idea Enterprise 12.1.3
FindBugs-IDEA plugin 0.9.97
Jenkins 1.513
Jenkins findbugs plugin 2.0.2
The only solution I've found so far is to use a different plugin, eg. QAPlug Findbugs. This one reports results exactly the same as Jenkins does.
The downside is it is a bit more clumsy than FindBugs-IDEA plugin.

Eclipse Juno : TestNG installed but inaccessible

I need to use testNG for a studies' project, so I tried to install the ecplipse plugin by two ways: first using a distribution package (I'm using Eclipse Juno on Archlinux) https://aur.archlinux.org/packages/eclipse-testng/ and the second time using the eclipse add-ons installer ("help">"install new softwares...") following these steps : http://selftechy.com/2012/01/09/setting-up-testng-with-eclipse
But, each time, I've this problem : The plug-in seems correctly installed but I do not find it in the menus, like it'd be disabled... for example, I can't see its window in
"Window">"Show view">"Other...">"java".
However, when I go to
"Help">"About Eclipse SDK">"Installation Details...">"Installed Software",
I see it well : "TestNG 6.8.0.20121120_1820 org.testng.eclipse.feature.group Cedric Beust"
So what's happening??
After you've installed the plugin simply right click on your class file -> Run As -> TestNG Test
Make sure your test methods are properly annotated, i.e.
public class Test {
#Test
public void test1(){
System.out.println("test1");
}
#Test
public void test2(){
System.out.println("test2");
}
}