Fixing "The default package '.' is not permitted by the Import-Package syntax." with maven-bundle-plugin
Overview I found this problem when I was trying to bundle a maven project as an OSGi bundle to use with Tycho. The bundle I was trying to make was effectively a shaded/uber JAR that has all the dependencies inlined inside of the final artifact JAR. The cause This problem is caused by a Java class file existing in the default/unamed package. It could come from anywhere in the dependency chain, including your own project, but in this case it came from one of my dependencies; JDOM.
Problem The Xtext project I’m working with had, what I assume is, the default project structure where all the java source code lives in a src directory and the generated code goes into src-gen. I wanted to change the structure to a more maven-like structure and have the java code living under src/main/java. I wasn’t too fussed about the src-gen directory, that can stay where it is. I Googled for a while but I couldn’t find anyone asking the same question as me so hopefully this will help any others (and my future self).
Note: I’m working in Eclipse with Spring 3 and using jUnit for my tests. Background I was writing a unit test for a file upload method on a controller that looks like: mockMvc.perform(fileUpload("/fileUpload") .param("description", "blah") ) .andExpect(status().isOk()); The test was failing with the message: java.lang.AssertionError: Status expected:<200> but was:<400> This isn’t super helpful because I wasn’t sure why I was getting the 400. I tried changing the URL that I was testing and the error code changed to a 404 so I knew the request was trying to get to the right controller method.
Note: this was done on a rooted Android. It may work on Apple devices but you definitely require root on Android. Background I’ve become a bit addicted to this game and in the course of playing it, I’ve had it rip me off a few times. This happened when I’d open the game after, it’d been sitting for a while, but then it would crash a few seconds after and when I relaunched it, the extra money I’d earned wouldn’t be there.
The problem As some background, I’m running the following: Jersey 1.15 Apache Tomcat 7 The specific error that we’re going to fix is: SEVERE: The following errors and warnings have been detected with resource and/or provider classes: SEVERE: Missing dependency for method public au.com.your.package.YourResponse au.com.your.package.YourClass.someMethod(au.com.your.package.YourRequest) at parameter at index 0 SEVERE: Method, public au.com.your.package.YourResponse au.com.your.package.YourClass.someMethod(au.com.your.package.YourRequest), annotated with GET of resource, class au.com.your.package.YourClass, is not recognized as valid resource method.
How to clear the APT cache to fix failing updates.
I came across this problem the other day and thought I’d post up the fix because it’s simple to fix but a show stopper if you can’t. I’m running Linux Mint 64-bit Cinnamon and Postgres 9.1 as a refenece in case you can’t copy-paste my commands. Basically, when I copied an already running version of postgres to a new box and it failed to start. When I took a look in the postgres log for when you try to start it, I could see that it was complaining about a missing locale.
ssh-add on a remote machine.
My current infrastructure has an instance of Jenkins as the Continuous Integration server and Sonatype Nexus as the repository manager. The POMs for my project and the settings.xml file for maven are configured so that Jenkins can automatically deploy SNAPSHOTs to the Nexus repository but the problem arose when I had a build that went to production and I needed to deploy that pre-built artifact to Nexus' RELEASE repository. This was easier that going back and checking out the correct versions of the many dependencies.
When you generate a Java project using maven and then import it into Eclipse, often you want to add extra directories that are treated as source directories. This guide will show you how to do it. First lets look at (a snippet of) the Super POM to see what we get by default: <build> <sourceDirectory>src/main/java</sourceDirectory> <scriptSourceDirectory>src/main/scripts</scriptSourceDirectory> <testSourceDirectory>src/test/java</testSourceDirectory> <resources> <resource> <directory>src/main/resources</directory> </resource> </resources> </build> We can override what we get from here which is probably what you’ll do most of the time; adding another resource directory.