I cannot find anywhere ngbit support for NetBeans 7. I have to install Struts2 for my Web Applications development. For NetBeans 6.9 my older version of ngbit 0.4 works fine, but for NetBeans 7 doesn't work. I need NetBeans 7 because of HTML5.
When I try to install org-netbeans-modules-web-frameworks-struts2.nbm, NetBeans gives the following error:
Some plugins require plugin Editor Library to be installed.
The plugin Editor Library is requested in version >= 2.10.1.10.2 (release version 2) but only 3.8.1.13.8 (of release version different from 2) was found.
The following plugin is affected:
Struts2 Support
Thanks.
The Struts 2 framework is used to develop MVC (Model View Controller) based web applications. Struts 2 is the combination of webwork framework of opensymphony and struts 1.
The major difference is that in Struts1. x the request directly goes to the servlet, whereas in Struts2. x the request and response traval though the stack of interceptor or filter. The regular logic can be placed in Filter classes and developer can concentrate on the Business Logic.
Apache Struts 2 is an elegant, extensible framework for creating enterprise-ready Java web applications. This framework is designed to streamline the full development cycle from building, to deploying and maintaining applications over time. Apache Struts 2 was originally known as Web Work 2.
Struts2 is a popular and mature web application framework based on the MVC design pattern.
If you're familiar with using maven in NB just follow http://struts.apache.org/2.2.1.1/docs/create-struts-2-web-application-using-maven-to-manage-artifacts-and-to-build-the-application.html
and you'll have a S2 project in no time. (I'm using NB7 with Struts2)
If you have any difficulties let me know.
Edit: How to create a new Struts2 Maven Web Application with the Netbeans 7 GUI.
1) File > New Project, Under Categories: Maven > Under Projects : Web Application > Next > On "Name and Location Screen" fill out things the way you want...
2) Edit: With updates to the state of the online repositories, you should not need to add any further repositories at this time, please skip to #3. I will leave the following as a reference should someone need it.
Now on the left hand side you should see a new Project in the "Projects" pane. Expand "Project Files" and open pom.xml.
Now this file explains how to build your project... to help you add dependencies we are going to tell maven about several online repositories which it may use to search for jar files
Locate the blank line between </properties>
and <dependencies>
and paste the following in between them...
<repositories>
<repository>
<id>JBoss Repo</id>
<url>http://repository.jboss.com/maven2</url>
<name>JBoss Repo</name>
</repository>
<repository>
<id>ibiblio mirror</id>
<url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
</repository>
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Maven Repository Group</name>
<url>https://repository.jboss.org/nexus/content/groups/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
<repository>
<url>http://ftp.ing.umu.se/mirror/eclipse/rt/eclipselink/maven.repo</url>
<id>eclipselink</id>
<layout>default</layout>
<name>Repository for library Library[eclipselink]</name>
</repository>
</repositories>
Perhaps they are not all needed... but these cover all the dependency bases I have right now so they should do quite well for you. If you do not do the above step, I think you can still complete the following steps but may run into issues when adding spring and or hibernate dependencies
Save and close the file. Now maven will handle a lot of the dependancy work for us as you'll soon see.
3)
a) Next under our project tree, right click the dependencies folder: In the Query field enter: "struts2-core", expand the drop down which will appear under "Search Results" and select the "2.2.1.1" version from the ibiblio mirror.
Alternatively: You could have done (a) from above by entering the correct values into the Group ID, Artifact ID, and Version fields (known in maven speak as co-ordinates). You should know the correct values because the are spelled out on http://struts.apache.org/2.2.1.1/docs/create-struts-2-web-application-using-maven-to-manage-artifacts-and-to-build-the-application.html under Step 3
b) Follow the alternative instructions above to use the gui to add a dependency with the following co-ordinates:
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.8.0.GA</version>
</dependency>
If you inspect your pom.xml file you'll see how the above xml was added to the pom for you.
c) Now you're an expert at adding dependencies add:
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
That takes care of the jar files.
4) Adding the configuration files. First we need to know where your project is on disk. You might already know this off the top of your head, if not right click the root of your project and select "properties" under "sources" it will tell us.
a) Outside Netbeans using your operating systems file navigator go into the root of your project. Open the src/main folders here you should see the "java" and "webapp" folders, create a new folder called "resources" and then go back into Netbeans 7.
You should see a new node called "Other Sources" under your project tree.
b) Expand Other Sources, expand "src/main/resources", right click the default package, new > other, Categories: XML, File Types: XML Document, then next. Enter: struts (be sure not to put .xml on the end it will be added for you), leave it on well formed document, finish.
Replace the contents of struts.xml with:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true" />
</struts>
c) Add another another xml file as you did in b called "log4j.xml" (remember not to add the .xml in the filename).
Paste the following into that file:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration PUBLIC "-//log4j/log4j Configuration//EN" "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p %c.%M:%L - %m%n"/>
</layout>
</appender>
<!-- specify the logging level for loggers from other libraries -->
<logger name="com.opensymphony">
<level value="DEBUG" />
</logger>
<logger name="org.apache.struts2">
<level value="DEBUG" />
</logger>
<!-- for all other loggers log only info and above log messages -->
<root>
<priority value="INFO"/>
<appender-ref ref="STDOUT" />
</root>
</log4j:configuration>
d) Configure web.xml, under the project root, expand the "Web Pages" node, create a folder called "WEB-INF" if it does not exist. Create a new xml file under the WEB-INF folder called web.xml.
Paste the following into the web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
Final Test: Now you should be able to hit the run button select your preferred web server (tomcat or glassfish) and see the hello world page... Sounds like success. But it isn't yet (if you created a new Maven Web Application and did nothing but hit the run button you'd see the same page, what you need to do is enter a url that does not exist such as entering "test" onto the end of your action.
If you get a web page saying: There is no Action mapped for namespace / and action name test. Then struts2 is handling the requests and we know all is well.
I hope I wrote this out correctly, if you need instruction on how to add spring or hibernate to struts2 in NB7 I could outline those too at that time.
the plugin have been updated to work in Netbeans 7.x!
http://plugins.netbeans.org/plugin/39218
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With