Classes not exposed under Eclipse Indigo (STS) [message #849018] |
Wed, 18 April 2012 20:12 |
Mastah Naleh Messages: 32 Registered: April 2012 |
Member |
|
|
Hi there.
I'm using eclipse indigo to create a dynamic web app using Libra. The OSGi framework I'm using is the one that come by default with eclipse (ie: equinox)
I'm basically following the demo video to use Libra.
It's deploying everything fine (META-INF, WEB-INF, jsp, css, ...) expect the classes (which are in build/classes).
So basically I can't execute any Java code.
I forgot to mention that I'm using Libra (OSGi Bundle Facet - 0.1.2.201202130952 & WAR Products - 0.1.1.201202130952)
[Updated on: Wed, 18 April 2012 20:15] Report message to a moderator
|
|
|
Re: Classes not exposed under Eclipse Indigo (STS) [message #849583 is a reply to message #849018] |
Thu, 19 April 2012 09:14 |
Kaloyan Raev Messages: 201 Registered: July 2009 Location: Sofia, Bulgaria |
Senior Member |
|
|
Hi, what you describe is the expected behavior. By default the compiled Java classes of a Dynamic Web project go to build/classes. However, this should not be a problem for the tutorial you are watching. If you launch an OSGi Framework via the PDE tools, then Equinox will automatically knows to look for the classes in build/classes. If you export your web project to a WAR, then the classes will be included in WEB-INF/classes in the exported WAR. Respectively, if you export your web project to a Bundle JAR via Export > Deployable plug-ins and fragments, then the classes again go to WEB-INF/classes in the exported JAR.
Nevertheless, if you want to have the compiled classes in the WEB-INF/classes during design time, you can do this by changing the default Java output for the project. You can achieve this in two ways:
1. During project creation. Go to the second wizard page for configuring the Java capabilities. At the bottom there is a field "Default output folder". Change it to "WebContent/WEB-INF/classes".
2. In an existing project. Call the Properties of the project. Go to the Java Build Path page. In the Source tab page, at the bottom you will see the "Default output folder" field. Change the value to "WebContent/WEB-INF/classes".
Don't forget to disable the "Java output folder" filter in the Project Explorer, so you can see the compiled classes.
|
|
|
Re: Classes not exposed under Eclipse Indigo (STS) [message #850707 is a reply to message #849583] |
Fri, 20 April 2012 08:52 |
Mastah Naleh Messages: 32 Registered: April 2012 |
Member |
|
|
Actually my classes are deployed correctly.
If I create a servlet and register it, it work properly. The servlet is found and do it's job.
My problem is more specific: using spring-dm and spring-web mvc.
In the big line: spring doesn't manage to find the controller classes (which are supposed to be in the classpath as much as the servlet is). The package containing all the classes is provided so spring can scan for the classes with the proper annotation. But for a reason that I don't understand yet, spring can't manage the find classes with the annotation even if they are supposed to be in the classpath.
If I deploy the bundle manually (ie: install file:/...) spring manage to find the annotated classes.
[Updated on: Fri, 20 April 2012 08:56] Report message to a moderator
|
|
|
|
Re: Classes not exposed under Eclipse Indigo (STS) [message #852863 is a reply to message #852094] |
Sun, 22 April 2012 12:00 |
Mastah Naleh Messages: 32 Registered: April 2012 |
Member |
|
|
I've solved my problem.
Apparently when using PDE+WTP (with libra) spring web mvc can't manage to find the controller classes if you provide them via the package where to look for controllers (ie: <context:component-scan base-package="package.to.web.controller" />)
To make it work you need to declare each controller as a standard bean (ie: <bean id="controller" class="package.to.web.controller.Controller" scope="prototype" />).
If anyone need help on the matter I'll gladly give an hand.
Edit: using the package to declare where the controller can be found properly work, but you need to manually install the bundle, which is not really a solution for development.
[Updated on: Sun, 22 April 2012 12:02] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03472 seconds