Is there a way within Eclipse (MyEclipse specifically) to have code assist functionality within a JSF (or XHTML, or JSP, etc) file where I am attempting to access managed bean properties?
See section 8.1.2.1.2.2. Content Assist Based on Project Data # http://docs.jboss.org/tools/2.0.0.GA/jsf/en/html/jbds_editors.html for clarification.
The docs you referenced are a perfect way to achieve way you need. Contrary to what its name may suggest, JBossTools is universally useable without the need to deploy to JBoss or otherwise have any JBoss specific things in your code.
The only thing is that MyEclipse, being a massively modified Eclipse, will probably not work together with JBossTools (but actually it is supposed to offer exactly this kind of functionality already).
Related
I am attempting to learn java EE by developing an app from scratch. What I have now is JSPs, EJBs, Servlets, jQuery script. I feel my progress is very slow right now.
I am afraid to consider JRebel-like tools at the moment.
Is there a step by step cycle I can follow to be more efficient?
When should I trigger the .reload file?
When should I delete/restart glassfish, when I modify: java, jsp, jsp fragment, dependent project?
Do I need to restart every time I modify a java file or only on major changes like add/remove class, add/remove method?
Do I need to run in debug mode every time so I can immediately see my changes on the fly?
Since your last comment, I think maybe I understand a little better what you're after.
I know you're looking for a glassfish solution, which I don't know very well, but if you're willing to work with other application servers, there are some good solutions for fast turnaround.
The JBoss IDE is free and integrates tightly with the JBoss Application Server. If you use the default directory layouts created by the Eclipse project wizards, turnaround for most changes is completely transparent and nearly simultaneous. I think you can find other IDEs with similar characteristics. (BTW - I don't use JRebel myself but hear very good reports from those I know who do.)
I have an exported Eclipse Java Project in my server and I want to be able to compile the project and use ASTParser with JDT.
I'm able to compile the project using BatchCompiler, however it runs on console and gives me PrintWriters instead of an array of problems and errors. Also I want to be able to use proposals in Eclipse and BatchCompiler didn't built for this purpose.
Therefore I tried to use ASTParser, it can be used with either char[] or ICompilationUnit. CompletionProposalCollector and org.eclipse.jdt.internal.compiler.Compiler.Compiler needs ICompilationUnit so I have to create an ICompilationUnit which only can be created by an IJavaProject (https://dl.dropboxusercontent.com/u/10773282/2012/eclipse_workspace.pdf) in order to be able to use these features.
It seems the only way to create IJavaProject is to use ResourcesPlugin.getWorkspace(), however it returns java.lang.IllegalStateException: Workspace is closed. on my computer and it seems the reason is that the program that I coded is not an Eclipse plug-in.
Is there any way to create IJavaProject without Eclipse environment?
From the comments, it looks like you are trying to do more than just parsing, you actually want to get some form of content assist.
I'm afraid that you're asking for too much. There is no simple way to get the power and flexibility of JDT outside of a running Eclipse instance (believe me, I've tried). There's no simple way, but if you are brave and strong willed, you can one of try following:
Run a headless Eclipse on your server that works on top of an actual workspace. This would be the easiest to implement, but would be the most resource intensive and least flexible way of doing things.
Use the jdt core jar, and create alternate implementations of the IResource hierarchy, and the parts of JFace that are used by the the parser and the CompletionEngine. This would likely be the most feature-rich way to go, but also the most brittle. I can't guarantee that this would work as you may need to create some very complex stubs for internal Eclipse non-API classes.
Avoid the CompletionEngine and the ASTParser entirely and just use the batch compiler. You would then need to provide an alternate implementation of org.eclipse.jdt.internal.compiler.env.INameEnvironment. This implementation would be able to find types, files, and compilation units in your actual project structure. You'd need to reimplement support for content assist, but this would most likely work reasonably well.
I am actually fairly interested in doing something like this (but I lack the time to do it). If you are seriously considering creating a headless JDT that can run on a server, feel free to ask for more information. I am quite familiar with JDT internals.
I've had a similar problem. Here is how to use ASTParser without Eclipse (it just needs the core JDT JAR on the classpath): http://blog.pdark.de/2010/11/05/using-eclipse-to-parse-java-code/
I got a little problem. I want to use hibernate in an eclipse rcp. (i'm new to osgi and eclipse rcp). So I added the jar into the plugin-project folder and the build path and the bundle build path, but when I try to use hibernate from my bundle, it crashes with a ClassNotFoundException.
What is the proper way to do this?
Pls look at eclipse buddy policy. This might help you if you are facing class not getting loaded because of osgi classloading.
Hibernate, and many other classic Java programs (ab)use dynamic class loading to to connect the different parts. They classes they use are read from a file and then loaded with Class.forName. This is fundamentally not-modular since these classes are by definition implementation classes, which should be hidden.
Since OSGi is a modularity framework it puts fences around a module (a bundle) and refuses to load anything that is not properly exported and imported. So if Hibernate does its Class.forName it will run right into this fence, as it should be to get the advantages of modularity.
Eclipse Buddy policy is like a huge hole in this fence, moving things back tot he bad old classpath: linear search. With a buddy policy, Eclipse will just start searching if there is a class somewhere that has that name. Since this ignores versions, you can no longer rely on proper version handling. The good news is that it works most of the time. The bad news is that you loose privacy and when it does not work you get weird errors.
With Hibernate, only solution is to not use the text file setup but use the API and give Hibernate the actual classes. In those cases Hibernate will use the class loader of those classes and that works. In OSGi, as long as you follow the Java language rules there are no problems.
To handle the kind of problems that class loading hacks address OSGi uses services.
I'm looking for an eclipse plugin which can at least search where the current JSP is included (or the path mentioned for example in custom "include like" tags or comment or anything). Similar like doing copy qualified name and do a file search with the correct path.In IDEA it's called Analyze Backward Dependencies and it works for JSPs too (at least for the standard includes).
A better one would be to show all the JSPs where the current one is included and show all the included JSPs recursively as a tree maybe so I can navigate in it easily. I'm not sure if this can be done to be usable (I think it would be slow).
Another feature I would like if I click on a variable's name it jumps to where it's declared with even if it's declared in a different JSP.IDEA can do this too.
I have a simple solution for the first one but I can't add more functionality to it as I'm not familiar with the eclipse plugin system and RCP and I don't really have time to learn it.
And please don't tell me to use IDEA because unfortunately that's not an option at work.
Apologies if this is a rehash of an earlier question that I can't find, but is there any way to stop eclipse (ganymede irc) flagging unresolved java references as a problem?
I have a web app that I want to deploy via eclipse in order to debug. However, it contains .jsp files including other .jsp files, which reference java objects defined in the includer e.g. (writing this from memory so the syntax will be all over the place):
includer.jsp:
<%String myname="bob"%>
<jsp:include check.jsp>
then
check.jsp contains
<% if ( myname.equals("bob") ..... etc
eclipse is validating check.jsp in isolation, doesn't like it, won't let me deploy.
I'm sure if I changed the filetype of check.jsp I could get it to work, but it's not my app and there load of other's like it that I'd rather not have to edit.
So, is there any way to configure the eclipse jsp validation to ignore the unresolved reference?
In your specific case Eclipse is quite right. The include page doesn't have any access to the scriptlet local variable of the parent page. Better use request attributes, you can use JSTL's c:set or a Servlet for this.
As to configuring the JSP validator of Eclipse, I've answered similar question shortly back. I wonder if you didn't see this topic in the list of possibly matched topics which popped up while you entered this question? Here it is: JSP EL (Expression Language) causing problems in Eclipse
Not to mention that using scriptlets is a bad practice. If you can, immediately stop using it and go ahead with taglibs/EL in JSP. It also less or more automagically forces you to write clean JSP code according the MVC ideology.