First, you should look at portal.log to see what it reports as the
error. I expect spring should have a stack trace. Typically you'd look
toward at the end of the exception chain to see what the root cause
was. It would likely tell you it had failure to inject into the
property when creating the bean and it often hints why (duplicate bean,
no bean of type XXX found, etc.).
The other thing you should be aware of is how Spring contexts are in a
hierarchy.
web.xml - defines the root Spring application context:
* Beans in the root Spring application context cannot see beans in the
child contexts
* typically your service and DAO beans go in the root Spring
application context so the web application contexts can see them.
* See
https://github.com/Jasig/uPortal/blob/uportal-4.2.0-M1/uportal-war/src/main/webapp/WEB-INF/web.xml#L33
web.xml - defines child Spring web application contexts
* In a webapp environment, you'd define a child Spring web application
context for the spring servlets.
o See spring web servlets at
https://github.com/Jasig/uPortal/blob/uportal-4.2.0-M1/uportal-war/src/main/webapp/WEB-INF/web.xml#L336
+
https://github.com/Jasig/uPortal/blob/uportal-4.2.0-M1/uportal-war/src/main/webapp/WEB-INF/web.xml#L342
(this is actually the parent of the portlet web MVC
application contexts)
+
https://github.com/Jasig/uPortal/blob/uportal-4.2.0-M1/uportal-war/src/main/webapp/WEB-INF/web.xml#L352,
etc.
* In uPortal, we use these as well but you typically don't need to
concern yourself as much with these.
* Beans in the child application context (Spring web application
context) can see beans in the root application context, but cannot
see beans in sibling child application contexts
portlet.xml - defines a child (portlet web) application contexts
* The child context can see beans defined in the root application
context and in the Spring MVC web application context (since the
portlet application context is actually a child of the Spring MVC
web application context).
* If there are multiple portlets in a portlet.xml, beans defined for
one portlet cannot see beans defined in another portlet.
I hope this helps.
James Wennmacher - Unicon
480.558.2420
On 05/20/2015 11:48 PM, Benito J. Gonzalez wrote:
> Devs,
>
> Wondering if someone can help me out.
>
> I am writing a class in /org.jasig.portal.portlets.groupadmin/ that is
> similar to the existing helper class there. Both are annotated with
> @Service. The existing one uses @Autowired on a setter for
> IGroupListHelper. In my class, I use the annotation on the field,
> which compiles and deploys just fine.
>
> In my class, I have three DAOs from the PAGS JPA package. They are
> annotated with @Repository. For example,
> @Repository("personAttributesGroupDefinitionDao”) is one. My
> understanding is that this creates a bean with the specified ID.
>
> In my class, I have tried
>
> @Autowired
> private JpaPersonAttributesGroupDefinitionDao
> personAttributesGroupDefinitionDao;
>
> And
>
> @Resource(name="personAttributesGroupDefinitionDao")
> private JpaPersonAttributesGroupDefinitionDao
> personAttributesGroupDefinitionDao;
>
> Both compile but when the war file is deployed uPortal fails. If I
> comment out the annotation for the DAO, uPortal works fine. (The class
> is not used yet.)
> Exceptions all over catalina.out on failure is:
>
> java.lang.IllegalStateException: Illegal access: this web application
> instance has been stopped already. Could not load
> [META-INF/services/javax.xml.stream.XMLInputFactory].
>
> @Autowired is suppose to match on class, so I tracked down a duplicate
> DAO bean in the import/export context. I removed those beans and
> switched the references in that file to the IDs used in the
> @Repository annotation in the three DAO classes. The import works fine
> with this change.
>
> Digging further, I noticed that some packages are excluded in the main
> context scan directive. In particular, the portlets package my class
> is in is excluded. The package is included in another context:
> /mvcServletContext.xml/.
>
> I am a bit stumped at this point. Anyone have advice on what to try
> next? Any overview on the contexts?
>
> Thank you and good night!
>
> Benito J. Gonzalez - Unicon
> [email protected] <mailto:[email protected]>
> 480.558.2360
>
>
>
> --
>
> You are currently subscribed to [email protected] as:
> [email protected]
> To unsubscribe, change settings or access archives, see
> http://www.ja-sig.org/wiki/display/JSG/uportal-dev
--
You are currently subscribed to [email protected] as:
[email protected]
To unsubscribe, change settings or access archives, see
http://www.ja-sig.org/wiki/display/JSG/uportal-dev