An annotation processor exception - spring

When i build project using maven and netbeans i got this exception : "java.lang.RuntimeException: com.sun.tools.javac.code.Symbol$CompletionFailure: class file for org.jaxen.FunctionContext not found".
In this article people said that solution is to disable annotation processing in NB, but i don't have this checkbox into the build settings of my project.
Maybe someone knows how to solve this problem or how to disable annotation processing

As for disabling annotations processing part, it's controlled by -proc:none option for javac; thus you can set
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<proc>none</proc>
</configuration>
</plugin>

I was faced with this problem again and found other solution. I just remove "target" folder of my project and project was compiled successfully

If you disable annotations process maybe your project is not going to run on final deploy destination, the best way to solve the problem is downloading the jaxen library at
http://jaxen.codehaus.org/releases.html
And then import jaxen-*.jar into your project.

I had the same exception pop up when using poi and poi-ooxml dependencies. The root cause was that I had a private member of type XSSFCellStyle in one of my classes. Changing the type to CellStyle made this compile time exception go away.

Related

How to avoid "The package is not exported by the bundle dependencies" error in IntelliJ IDEA?

I have created a new Maven project using the CQ5 archetype and imported it into IntelliJ IDEA. IntelliJ marks usages of some classes such as org.apache.felix.annotations.Component, org.apache.felix.annotations.Reference, etc. IntellIJ as erroneous with the following error message:
The package is not exported by the bundle dependencies
Is this a legitimate error?
How can I fix it (as opposed to disabling the inspection)?
I'm using version 12.1.4
The error seems legit. I'm not able to find that package in the ACQ 5.6.1 Doc.
I turn off the inspection by:
Right-clicking on the block in the right margin.
Click "Customize Highlighting level".
Bring the slider down to "None".
Are you exporting those packages as part of the bundle definition? In the maven project, you should have the maven bundle plugin with <Export-Package>your.packages.here</Export-Package> defined. Are these packages included in that definition? If not, those services won't actually be availale in OSGi.
In my case, I accidentally "configured OSGi" when I only wanted to configure Spring. The way I dealt with this issue was by right clicking the right margin at one of the affected lines, clicking "Customize Highlighting Level" --> "Configure Inspections". I think hippoLogic's solution will get rid of all your syntax-level error highlighting as well as helpful inspection-level highlighting. This way you can simply tune the latter to exclude OSGi.
It'd be even better to de-configure OSGi (which I haven't investigated), but here's a quick/dirty fix to reduce the highlighting noise.
To Fix this check if the respective dependencies are present in the pom file, in your case I think it mught be present since you just imported them up from eclipse where it wasn't giving any error. Also check if the settings.xmml being referred to is correct, and is in right place and the correct one is been referred from intellij. your settings.xml is present in the maven home or might be reffered as a symbolic link in the maven home. Hope this helps.
just export related packages on maven build plugins as #Brenn's answer, deteails as below:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${maven.bundle.version}</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-DocURL>${project.url}</Bundle-DocURL>
<Bundle-Activator>
org.apache.tika.parser.internal.Activator
</Bundle-Activator>
<Import-Package>
org.w3c.dom,
org.apache.tika.*,
*;resolution:=optional
</Import-Package>
<Export-Package>
your package here
</Export-Package>
</instructions>
</configuration>
</plugin>
I work on a project clone from github, it's unrelated about OSGI, so i think that's a bug of idea or i accidentally turn on . Then i assume the feature of "OSGI" in idea work depend on plugin,so i diabel this plugin
Disable the OSGI plugin, the error message disappear.
in mac os:
command + shift + a, type plugin
search "OSGI", then disable this plugin.

ClassNotFoundException Netbeans Maven Library wrapper

I was able to follow the tutorial here and convert it to a Maven application.
I got the loading part right, but when I try to use it, it can't find the appropriate swt classes (When ran from windows 64). I did it on a Maven project. Here's the relevant part of the respective pom for the Windows 64 module:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>nbm-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<!-- To have the jar plugin pickup the nbm generated manifest -->
<useDefaultManifestFile>true</useDefaultManifestFile>
<moduleType>normal</moduleType>
swt.windows.64/1</codeNameBase>
<publicPackages>
<publicPackage>org.eclipse.swt</publicPackage>
</publicPackages>
</configuration>
</plugin>
I translates to org.eclipse.swt.*. It seems to be a Maven module issue since it already tries to load from correct module.
Caused: java.lang.ClassNotFoundException: org.eclipse.swt.SWT starting from ModuleCL#25e0dee5[djproject.core] with possible defining loaders [ModuleCL#6783113b[swt.windows.64]] and declared parents [ModuleCL#32821bf7[org.netbeans.api.annotations.common]]
Caused: java.lang.NoClassDefFoundError: org/eclipse/swt/SWT
at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface.initialize_(SWTNativeInterface.java:213)
at chrriis.dj.nativeswing.swtimpl.NativeInterface.initialize(NativeInterface.java:71)
at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface.open_(SWTNativeInterface.java:337)
at chrriis.dj.nativeswing.swtimpl.NativeInterface.open(NativeInterface.java:100)
at synamicd.windows64.support.Windows64BrowserProvider.initialize(Windows64BrowserProvider.java:25)
Any help is more than welcomed!
Edit:
Code is available here.
when I try to build the application at the bitbucket location, it's build order suggests that none of the swt modules are used in the app - http://screencast.com/t/LMxIPy6A6ZUL

Maven: No marketplace entries found to handle castor, antrun, and ear plugins

I am importing a maven project into Eclipse. I have the m2e plugin installed and it is pointing to maven 2.2.1 on my machine.
I am getting these three errors:
No marketplace entries found to handle castor-maven-plugin:1.0:generate in Eclipse
No marketplace entries found to handle maven-antrun-plugin:1.1:run in Eclipse
No marketplace entries found to handle maven-ear-plugin:2.3.1:generate-application-xml in Eclipse
Any resources provided would be greatly appreciated.
Thanks
You can define custom build life cycle mapping for those plugins and make m2eclipse execute certain goals during Eclipse build.
This thread, https://bugs.eclipse.org/bugs/show_bug.cgi?id=350414, contains a discussion and ultimately a patch to make eclipse capable of ignoring the connectors it can't find.
Most people on the thread find the m2e's demand for custom build life cycle mapping problematic.
I faced this issue and I resolved this by enclosing the within the . Here is the example.
<build>
<pluginManagement>
<plugins>
<plugin>
....
</plugin>
</plugins>
</pluginManagement>
</build>
Reference: Link

FileNotFoundException..Classpath resource not found in spring?

I have code like this in Main.java :
AbstractApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
Until recently it was working, but I don't know why it started failing with the below exception:
Exception in thread "main"
org.springframework.beans.factory.BeanDefinitionStoreException:
IOException parsing XML document from
class path resource
[spring-config.xml]; nested exception
is java.io.FileNotFoundException:
class path resource
[spring-config.xml] cannot be opened
because it does not exist
the spring-config.xml is in src/main/resources folder.
Actually I wanted to learn about the annotations: #Postconstruct and #Predestroy, so I changed the build path to Jdk 1.6 from Jdk 1.5.
Since then the problem started...
Any clue why it is not working?
NOTE: If any wants to see my project structure please follow this link
http://code.google.com/p/javapracticeram/source/browse/trunk/SpringExample/
EDIT:
Looking at your classpath you exclude src/main/resources and src/test/resources:
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
Is there a reason for it? Try not to exclude a classpath to spring-config.xml :)
Check the contents of SpringExample/target/classes. Is spring-config.xml there? If not, try manually removing the SpringExample/target/ directory, and force a rebuild with Project=>Clean... in Eclipse.
This is due to spring-config.xml is not in classpath.
Add complete path of spring-config.xml to your classpath.
Also write command you execute to run your project. You can check classpath in command.
Two things worth pointing out:
The scope of your spring-context dependency shouldn't be "runtime", but "compile", which is the default, so you can just remove the scope line.
You should configure the compiler plugin to compile to at least java 1.5 to handle the annotations when building with Maven. (Can also affect IDE settings, though Eclipse doesn't tend to care.)
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
After that, reconfiguring your project from Maven should fix it. I don't recall exactly how to do that in Eclipse, but you should find it if you right click the project node and poke around the menus.
I was getting the same problem when running my project. On checking the files structure, I realised that Spring's xml file was inside the project's package and thus couldn't be found. I put it outside the package and it worked just fine.
Best way to handle such error-"Use Annotation".
spring.xml-<context:component-scan base-package=com.SpringCollection.SpringCollection"/>
add annotation in that class for which you want to use Bean ID(i am using class "First")-
#Component
public class First {
Changes In Main Class**-
ApplicationContext context =
new AnnotationConfigApplicationContext(First.class);
use this.

Anyone who actually got Tycho to work?

I'm trying to get Tycho working with m2eclipse. Problem is that all I find are outdated sites and old versions to download. I've found my way to http://github.com/sonatype/sonatype-tycho and downloaded the source. Problem is that the guide at https://docs.sonatype.org/display/TYCHO/BuildingTycho isn't of much help. When trying to build I run into an error message saying I'm using invalid syntax..... And there seems to be nowhere to ask for further guidance.
So are there anyone out there who actually got this working? Or got a better alternative for continuous integration / automatic build solution for eclipse plug-ins?
Tycho is a maven plugin, so you don't need to download it, just declare it in your pom.xml files.
See http://github.com/sonatype/sonatype-tycho/tree/master/tycho-its/projects/tycho001/ for details of a simple project.
This hint from Igor Fedorenko helped me to get it running:
https://issues.sonatype.org/browse/MNGECLIPSE-2140?focusedCommentId=115527&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_115527
If you are not pressed for time, I'd suggest to wait for the upcoming Update of m2eclipse, though. It was recently announced to follow shortly after Maven 3 release.
Robert, it does work for me as long as you don't try to build an Eclipse application. I have integrated it into CruiseControl and I am quite happy with building and testing plugins.
The main trick for me was to ignore all the P2/target stuff. I couldn't get it to work at all. Instead I call maven with an parameter that points to the Eclipse installation like this:
mvn -Dtycho.targetPlatform=C:\Programmer\eclipse
These are the necessary Plugin definitions:
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
Current Tycho Version is 0.13.0.
I would like to build Eclipse Applications but need support myself for that.
I hope that helps.
Cheers,
Klaus
I had trouble with Tycho for a while until I realized it required Maven 3. If you're running Maven 2 it won't work.

Resources