Spring Explorer not showing beans from bean definition file - eclipse

I just downloaded the Springsource Tool Suite, and I created a simple bean configuration file called myDefinition.xml and placed it in the root directory of the Spring Project. However, the Spring Explorer is not showing any data. I'm using eclipse 3.5 and the latest SpringSource all-in-one installation.
Also, if I specify invalid property names in the configuration file, I get no error. Autocomplete, however, is working.
Thoughts?

In the Spring Explorer tab in Eclipse, right click on your project > properties. Then go to Spring > Beans Support and select the Config Files tab. You can then select files or scan a directory and that should add them. I haven't found a way to autoscan a directory so I don't have to do this whenever I add a new spring bean file. The beans that appear in that list are stored in the .springbeans file.

Just want to add that if you want to generate a diagram of a webflow of an existing project, you have to right-click said project in Eclipses Project Explorer and "Add Spring Project Nature" by using the Spring Tools entry of the context menu.

There currently (as of 2012-04-10) seem to be problems with the Spring Explorer view when using a purely annotation driven bean definition (i.e. using Java annotations to wire everything up instead of using XML files).
There is a workaround though, by providing a minimum XML file that declares scanning for components.
http://forum.springsource.org/showthread.php?118928-Spring-Explorer-with-Java-based-Web-Container-configuration
Unfortunately, this procedure is still flawed, missing some components.

Just to add Claudio030
Make sure you have JEE perspective selected for your project, otherwise it won't show in Java perspective.

Related

How to get eclipse content assist working in XML files

I have started creating the Spring web application where I need to mention the spring classes in the XML configuration files, for ex, the deployment descriptor (web.xml) where I need to mention the DispatcherServlet class of Spring.
What I am looking for is, I want eclipse to show me the list of packages/classes when I type org.springframework..., like we do in the Java editor. I have googled to find out, but no luck. I am sure there would be plugins available. Can any of you please share me on how to fix this?
Since you are working on a spring project, I'd recommend installing the SpringToolSuite (STS). The info page is here: http://spring.io/tools
Since you already have an Eclipse instance that you are working with, you should go with the update sites: http://dist.springsource.com/release/TOOLS/update/e4.4/
(Make sure to use the correct update site for the Eclipse version you are using.)
Not only does STS include all tools for XML editing, but it also includes special tools for editing your Spring application files.

Is there a way to auto-generate hibernate.cfg.xml file in netbeans/eclipse?

Actually i'm learning jpa, so i must learn with examples.
I found that the manual creation of hibernate is annoying,
every time i have to copy and paste the structure of that file
So i was thinking is there any solution to auto-generate the " hibernate.cfg.xml " file automatically via netbeans/eclipse ?
Netbeans automatically generates a hibernate.cfg.xml if you create a Web Application Project that uses Hibernate (see the Netbeans documentation on Using Hibernate in a Web Application). According to this guide, you can also create the hibernate.cfg.xml file using New → Other and then selecting Hibernate Configuration Wizard in the Hibernate group.
In Eclipse, the Hibernate Tools plugin provides a wizard to create the hibernate.cfg.xml file (see the JBoss Hibernate Tools documentation).
Edit: Add information about the file wizard in Netbeans.

Exporting JSF project as WAR file ends up in RuntimeException: Cannot find FacesContext

When I export my JSF 1.2 project as WAR file, it is not being created properly in Eclipse Indigo. Namely, when I import it again and run it, then it ends up in the "FacesContext not found" error. How is this caused and how can I solve it?
I checked again, when I import it again and run the url pattern is missing /faces/ . when i append it manually it is coming fine. is there any way in which the url pattern will come same in the imported file also?
You're relying too much on the IDE doing all the necessary magic for you. Your initial project had the JSF project facet set and you were running the project by Run on server using the builtin browser instead of just starting the server and navigate to it yourself in the external browser.
The JSF project facet is an Eclipse specific feature which is completely unrelated to the JSF/Servlet spec. This information is nowhere stored in the WAR. When you import it again, it'll become a default dynamic web project without any specific project facets set. You need to rightclick the project, go to Project Facets section and manually add the JSF project facet. This way the IDE becomes aware that the project is a JSF project and will do the necessary magic such as automagically inlining the FacesServlet mapping in the target URL during Run As.

hibernate console configuration disappeared in Eclipse

I'm working with Eclipse Indigo and the Hibernate tools/plugins (3.4.0...) by JBoss Red Hat. For the purpose of reverse engineering of Hibernate value object classes I created several console configurations with the wizard that pops up when clicking on add in the Hibernate Configurations view.
Later when I wanted to regenerate the classes, some of the configurations had dissapeared. When I wanted to add a new configuration with the name of one of the now dissapeared configurations the wizard tells me that the configuration already exists.
Since I couldn't find out where these configurations are stored I'm unable to do anything about it.
Do I have to create a new configuration with a different name?
I have the same problem and finally I found the file in this directory:
.\WORK-SPACE\.metadata\.plugins\org.eclipse.debug.core\.launches\miConsoleConfig.launch
But is better to edit from eclipse. The console configuration is only visible in Hibernate perspective under tab Hibernate Configurations next to the package explorer.

How to jump to Spring context XML file from Java Class in Eclipse

I well read the question How to find Spring XML definition from Java Class in Eclipse but it does not seem to answer similar question from me.
I would like to jump from Java class in editor to the spring context xml file.
If I highlighted a class declaration in editor, by pressing a shortcut key or clicking on some icon, it should open the corresponding spring context xml which have the bean initialization definition and jump to the line which initializes the bean "< bean id=... >". If I highlighted a set method in editor, it will do something similar but jump to where the property is set "< property name=method_name... >"
I am using Eclipse Java EE IDE for Web Developers Indigo SR2. I have installed Spring IDE Developers and SpringSource. I have added Spring nature to the project, added context xml to the project property Spring Beans Support Config Files, and could see the "S" on file icon decorator of the context file and java class, but I could NOT find a way to jump from the Java class to the spring context xml.
My colleague is using IntelliJ and they could see a bean icon in their editor next to class declaration. I would hope to see something similar on Eclipse. Ideally, not only class level, but also next to set methods.
Any advice will be much appreciated!
Thanks
Gerry
The desired action is provided by the Spring Tools (Spring Tool Suite), which can be installed the usual way, i.e. as Feature, or via the Eclipse Marketplace.
your current project needs the "spring project nature"
moreover, your build must include the "spring project builder"
and, in your project configuration project>properties, "Spring" tab, you need to define all your Spring XML files.
In Eclipse Mars, all of this will be setup automatically, when importing a Maven project and using the M2E plugin. Moreover, there is also a setting in the "Spring" tab, which allows to autodetect your Spring XML files. Anyhow, the spring project configuration needs to parse and evaluate those XML files during the incremental build of your project. So far for the prerequisites.
The actual function is called "open spring bean"
By default, there is no keybinding for this operation, so either
invoke it by name: press ctl-3 and start typing the name "open spring bean"
set up a custom key binding: press ctrl-shift-L and ctrl-shift-L again, to get the keybindings editor. Use the search to get to the function "open spring bean", make sure you select "in windows" as scope and add the key binding you like (e.y. I used ctrl-y, which is good to type with the left hand while using the mouse with the right hand).
This function will give you a Eclipse typical quick-hover-and-search box, where you can start typing. If the cursor is on the class name of the bean implementation Java class, the view will be populated already and you just need to hit enter.
<Rant>
This is such a crucial and basic feature. Why the Spring and Eclipse folks are incapable to set up and document the very basics in a way easy to discover is beyond me. No wonder every idiot thinks that IntelliJ is vastly superior, which it is not. In reality, both are on equal footing and have their strengths and weaknesses here and there.
</Rant>
I don't know if SpringSource or such have any specific keys for these, but good old Ctrl-shift-R (Navigate -> Open Resource) can be used to search for and open non-Java files in the workspace (like .xmls and .properties), for classes you can use Ctrl-shift-T (Navigate -> Open Type). When the search window opens, just start typing file- or class name (you can also use wildcards like * and ?).
Use Alt+Shift+B if you are using Spring Tools Suite.