java.lang.NoSuchMethodError: javax.servlet.ServletContext.getServletRegistrations()Ljava/util/Map; - servlets

I followed the steps in BalusC's answer at JSF 2.0 File upload. The only step in which I went differently is the Tomahawk upload link in the answer. The link is broken, so I got tomahawk-1.1.11 from another place. When I try to start Tomcat 7.0.14 from Eclipse I get the following error:
java.lang.NoSuchMethodError:
javax.servlet.ServletContext.getServletRegistrations()Ljava/util/Map;
And Tomcat doesn't start. Any ideas? Also, the answer in the link is from March. Any developments with file upload in JSF 2?

The /WEB-INF/lib of your web project is cluttered with servletcontainer-specific libraries of a container of a different make/version, such as servlet-api.jar, javaee.jar, etc. Get rid of them.
The mentioned method is introduced in Servlet 3.0 and this error indicates that you've libraries of a Servlet 2.5 container or older in your /WEB-INF/lib. If you have included them to circumvent Eclipse's compilation errors on javax.servlet.* imports, then you should have solved it differently. Namely, by integrating the servletcontainer which you're actually going to use (which is Tomcat 7 in your case) as target runtime in Eclipse and associating the project with it.
Please note that this problem is not related to JSF 2.0. You got an exception pointing to a method of the javax.servlet package, not javax.faces package.
See also:
How do I import the javax.servlet API in my Eclipse project?

Related

Is there a direct way to get a full ejb/servlet application example for glassfish

I have an application that is currently running on JBoss AS but does not work on Glassfish. I'm trying to work through the documentation here but I'm having trouble figuring out things like what the file structure of the application should be and what (if any) additional files are needed. This documentation also refers to examples but to get the examples you need to install Netbeans and access an update tool tied to the glassfish instance installed with Netbeans. When I do this the server won't start, the update tool won't run, and I can't get the examples. Is there an easy way to get these examples (e.g. a simple download)? I've found other examples such as this one, but they are also dependent upon Netbeans.
Is there a simple and complete ejb/servlet example for Glassfish that can be simply downloaded and does not depend upon Netbeans or other IDE?
The obvious example is the Java EE CargoTracker. It was written to show what a "real" application might look like with pure Java EE APIs so should work on both JBoss and GlassFish. You will need Maven installed to build and run it, but there are more complete details in the readme for the project. Note that some of the information is a little out of date (mostly links to java.net which has been sunset in favour of a GitHub site) but the application itself is still a good example of Java EE 7 APIs.
https://github.com/javaee/cargotracker
I found the examples on github here:
https://github.com/javaee/glassfish-samples
To get and build the examples you will need Git and Maven. These examples are small, complete, and concise. The example that was helpful for my particular problem was this example:
glassfish-samples\ws\javaee5\enterprise\servlet-stateless-ear
It demonstrated that I needed to change the structure of my project such that the servlet was in a .war file and not in a .jar file in the lib folder of my project.

How to / where to find info on JBoss client dependencies? Any documentation?

It may be pretty basic question. But no luck Googling.
I was going through this URL. Because I had an issue accessing EJBs deployed on JBoss. After following this, it worked. Mainly this line.
jboss-ejb3-client.jar, jboss-aop-jdk50-client.jar, jboss-aspect-jdk50-client.jar and jbossall-client.jar -
all these .jar files are found in client folder of JBoss installation directory
But for a newbie of EJBs like me, this is following the steps without understanding the dependencies. So my question, can we find documentation like this somewhere? How do we know the jars we need to copy to client application classpath?
jbossall-client.jar for JBoss 4.X is enough - it contains all needed libraries.
For JBoss 5.X the story is more difficult - you need to reference in your project only jbossall-client.jar, but inside this JAR there are no actual classes, only MANIFEST file, which lists needed dependencies.
So, on JBoss 5, you need to have jbossall-client.jar added to classpath of your client plus all listed JARs lying next to it. Crazy, isnt't it?
JBoss 7 has sane approach. There is bin\client\jboss-client.jar that contains all dependencies needed by clients.

Jar to include to use javax.annotation.*

I'm a bit confused. I need to compile a project in jDeveloper 11.1.1.6.0. The server side of the project is deployed on the Glassfish server. On the machine of the project's creator everything compiles without any problems.
Using project properties -> Libraries and Classpath I added the libraries such as gf-client.jar, security etc. from $glassfish_home/glassfish/modules and some others (e.g. hibernate3.jar from hibernate dir).
When I try to compile the project I receive the following errors:
package javax.annotation.security does not exist
and
package javax.persistence does not exist.
I suppose that I miss some jars to include. I tried to find which jars (from Glassfish or from JDK) contain javax.annotation.* and javax.persistence.* but I couldn't.
If you have any ideas I would be thankful!
I was having the same problem and was able to solve it by adding a couple of dependencies to the Maven pom.xml file. See this answer for more details.
So I found the source of the problem. The application consists of 2 projects, of which only one (mentioned in the question) uses EJB. I'm not sure if it is the way it should be, but I tried adding ejb-files to another project. And after clean all and rebuild all it compiled like a charm for me. I hope this will help somebody in the future.

Upgrading Flex from 3.2 to 4.5 - Errors and Warnings

I've inherited a large codebase written primarily in Flex 3.2 using Parsley and Cairngorm.
The entire build process is done through maven using FlexMojos.
I'm relatively new to Flex and I've been told to upgrade Flex from 3.2 to the latest 4.5.1 version.
While I have made a good progress, I have run into some errors that are beyond my understanding or Google search has not been able to help.
Things I have done:
Changed all namespaces to mxml 2009 and fx.
Put all non-visual components in fx:declarations.
Added namespaces in my stylesheet
Upgraded version of FlexMojos to 3.9 - not 4 because there isn't a stable version yet
Upgrade all cairngorm dependencies to the Flex 4 dependencies, although keeping the same versions.
Exclusively declared that the theme I want to use in the compiler settings is halo.swc
Fixed a lot of compilation warnings and errors which were trivial.
Things I don't know how to fix:
While compiling, I get a lot of warnings with regards to CSS.
An example of warning I get is the following:
[WARNING] C:\repo\com\adobe\flex\framework\framework\4.0.0.14159\framework-4.0.0.14159.swc$defaults.css:[487,-1]
The style 'dropShadowVisible' is only supported by type
'mx.controls.List' with the theme(s) 'spark'.
For a start, I'm not using 4.0.014159, although something's telling me that the dependency is being pulled through a Cairngorm library such as validation or module.
If so, any solutions to that?
Additional warnings I get which I don't understand how to fix are the following:
[WARNING] The swc
'C:\repo\com\adobe\flex\framework\framework\4.5.1.21328\framework-4.5.1.21328.swc'
has style defaults and is in the library-path, which means
dependencies will be linked in without the styles. This can cause
applications, which use the output swc, to have missing skins. The
swc should be put in the external-library-path.
Regarding the above, I read somewhere that the swc file has to be loaded as an external library path instead. I did that but the warning didn't go away.
Finally, the app fails to compile as a result of these errors.
[ERROR]
C:\repo\com\adobe\flex\framework\mx\4.5.1.21328\mx-4.5.1.21328.swc$defaults.css:[469,-1]
Invalid Embed directive in stylesheet - can't resolve source
'Embed(source = "assets/CalendarIcon.png")'.
There's no reference of the CalendarIcon.png asset in my codebase. Google pointed me out to this http://python.mmitd.com/bugs.adobe.com/jira/browse/SDK-22746, but I'm afraid nothing I've done worked.
As you can see the majority of my warnings/errors (at least for now) lie around default.css warnings.
Any help will be greatly appreciated!
Flex compiler, by default uses a css, which is named as "defaults.css". If you have the css named as "defaults.css", change the name of it.
It will also look for flex-config, which should be same as application name or it will take a default flex-config from the sdk folder. There are couple of css properties, which are only available in Flex 3 components. Now as we have the Spark component architecture in place, few properties may not work at all and give you warning messages.
If you have Flash Builder installed on your machine, you can import your project in it and go through the warning messages one at a time and fix your .css file.
Hope it helps you somewhat in resolving the problems..

ActionScript error #1053 - Illegal override of allowInsecureDomain in _MonkeyContacts_mx_managers_SystemManager (FlexMonkey code generation example)

I'm following along the MonkeyContactsCodeGenExample guide and when I run the ant target for test-with-launcher, I get a popup saying:
VerifyError: Error #1053: Illegal override of allowInsecureDomain in _MonkeyContacts_mx_managers_SystemManager.
This is followed by:
ReferenceError: Error #1065: Variable _MonkeyContacts_mx_managers_SystemManager is not defined.
These popups are from the debug flash player - the normal flash player would silently supress these errors.
It seems that these sorts of errors occur when different files or swc components are compiled under different SDKs. If so, what parts would I need to recompile in this situation?
I checked out the flex project sources and have rebuilt them under SDK 3.4, and I also got the project sources for fluint and have recompiled those already. The newly compiled fluint.swc was then copied to the lib directories of the MonkeyFluintAirTestRunner and MonkeyTestLauncher projects and then everything was re-built, but I still get this error with the MonkeyContacts example.
I just ran into this myself today. I just needed to recompile the MonkeyAgent.SWF.
As per a note on the FlexMonkey site, I used the Easy2BuildMonkeyAgent project to do this. I didn't look into why they recommended this, but it worked for me.
Beware, I ran into a problem compiling this because I use the standard 3.4 SDK that was installed separate from Flex Builder. The the standard 3.4 SDK, the automation.swc file (and others) aren't there, so I had to grab copies from the FlexBuilder 3.0 SDK folder into the 3.4.
Don't forget to copy the corresponding files from locale/en_US: automation_agent_rb.swc, automation_rb.swc

Resources