JSF / Spring Security : view wrapper generates LinkageError - java

I'm having an issue with JSF rendering. Here's my setup:
CentOS
TomEE Plus 1.5.2
Icefaces
Spring Security 3
And my app is set up like this:
/opt/tomee/lib/[all the normal TomEE jars]
/opt/tomee/lib/[all the Spring Security jars]
/opt/tomee/lib/icefaces.jar
/opt/tomee/lib/icefaces-compat.jar
/opt/tomee/lib/icepush.jar
/opt/tomee/webapps/UI/index.xhtml
/opt/tomee/webapps/UI/WEB-INF/lib/icefaces-ace.jar
/opt/tomee/webapps/UI/[normal jsf 2 configuration]
There isn't anything obvious in the logs but when the JSF attempts to render I get the following error:
com/sun/crypto/provider/HmacCore
viewId=/index.xhtml
location=/opt/tomee/webapps/UI/index.xhtml
phaseId=RENDER_RESPONSE(6)
Caused by:
java.lang.LinkageError - com/sun/crypto/provider/HmacCore
at com.sun.crypto.provider.HmacSHA1.(DashA13*..)
The stack trace on the error page is massive, so I'm not going to dump a novel here, but here are the calls of note.
java.lang.LinkageError: com/sun/crypto/provider/HmacCore
at com.sun.crypto.provider.HmacSHA1.(DashA13*..)
{...}
at java.security.Provider$Service.newInstance(Provider.java:1221)
{...}
at org.apache.myfaces.shared.util.StateUtils.encrypt(StateUtils.java:328)
{...}
at org.icefaces.impl.renderkit.RenderWrapper.encodeEnd(RenderWrapper.java:53)
{...}
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
I dumped the contents of all the jars in tomee/lib but com.sun.crypto isn't anywhere that I can find in the web server. Apps that don't use Spring Security work just fine.
Any thoughts?

OK. I got it to work so I'm going to be 'that guy' and answer my own question. I hope that it helps save someone else from the migraine it gave me. The problem went away after I did the following:
delete my war
let tomcat clean up the webapps dir
stop tomcat
delete the related directories from work
add the spring security taglibs jar to my app
remove the encoder declaration from my applicationSecurity.xml
rebuild the app
start tomcat
redeploy
drink heavily
profit
Step 10 wasn't actually a part of debugging process but I wouldn't have complained if it was. Share and enjoy.

Related

Upgraded Spring, Now Freemarker throws NoSutchMethod error

I had a perfectly working Spring applicaton (4.2.7 -> 4.3.7) Simple upgrade, but now when I deploy catalina.out is giving me a:
Caused by: java.lang.NoSuchMethodError: freemarker.template.Configuration.<init>(Lfreemarker/template/Version;)V
at org.springframework.ui.freemarker.FreeMarkerConfigurationFactory.newConfiguration(FreeMarkerConfigurationFactory.java:320)
I looked through the API but doesn't look like anything changed. I also can confirm the freemarker-2.3.20.jar is in the lib directory, but this looks like a spring issue
Took a bit of searching, but Spring also upgraded Freemarker to 2.3.23 -- So use that in your pom and it should work.

Project doesnt deploy to localhost root but deploys to localhost/projecttitle

Alternative title: Unable to find [main.SearchServlet], mapping my servlet in Tomcat whilst using annotations
I'm trying to migrate my web application from java netbeans glassfish jdk 1.8 to eclipse tomcat jdk 1.7.
I keep getting a 405 then 404 error when I try to perform my POST by pressing a button on my loaded index jsp.
javax.naming.NameNotFoundException: Name [main.SearchServlet/annj] is not bound in this Context. Unable to find [main.SearchServlet].
I thought that setting a <context root>/</context root> in web.xml would fix this. It did move my loading page from localhost/animelist/index and localhost/animelist down one level to localhost/ and localhost/animelist however it did not fix my error.
As it stands, my project does not run at http://localhost:8080/ or http://localhost:8080/index.jsp . It DOES run at http://localhost:8080/animelist1/ and http://localhost:8080/animelist1/index.jsp
The project works fine in my netbeans setup so my question is what do i need to do for my servlets to be mapped properly in tomcat?
Someone said that " Likely the only problem you have is that the application deployment in your secondary Eclipse isn't working properly yet. As in: the servlet class file is not deployed to the server at all." I'm not sure how to go about fixing this (or googling for it).
I have my classes instanced with
#EJB
private AnnJAXB annj;
and servlet with
#WebServlet(name = "SearchServlet", urlPatterns = { "/search" })
and like i said it all works in netbeans setup.
so do i have to do something with tomcat config or application properties, since deployment should be done automatically? why isn't mainClass.SearchServlet being found?
thankyou for reading. i am near the end i feel . it has been 15 hours trying to deploy this to a host and it is exhausting.

Switch java spring maven project from linux to windows

I am new to spring development so i am stuck here. Is there any configuration while switching spring + maven project from linux to windows. I am running on tomcat server 7. The project is initially developed in linux. I have moved all the file from linux to wondows. While running on server, i get error The requested resource (/myproject/login/) is not available. Do i need to make any changes or add add in configuation.
Thanks in advance.
I think you have missed something.
Try this.but i'am not sure this is working or not.
Tomcat, by default invoker servlet disabled (commented out in the web.xml file). You have to create a 'servlet' and a 'servlet-mapping' entry in your web.xml.
Once you do, you can get rid of the "servlet/" part of your url.
Check out the following URL for more information regarding the invoker servlet:
http://faq.javaranch.com/view?InvokerServlet

java.lang.NoClassDefFoundError: javax.servlet.ServletInputStream Error deploying on websphere

I have created a jersey web service with neatbeans using glassfish as my server, everything works fine but i have issues trying to install the same app on websphere 7.
i get this error "Error 500 An error occurred while processing request: /ibm/console/upload.do Message: java.lang.NoClassDefFoundError: javax.servlet.ServletInputStream".
I even tried creating a simple web app and tried to deploy on websphere, again, i have the same error.
Anybody with ideas? I need your help so badly ya'll. Thanks in advance
Make sure you don't have servlet-api.jar in your WEB-INF/lib. If its there it may interfere with the one already present in websphere a trick the classloader
I did below steps which worked for me :
Go to the server in console(which was stand - alone in my case i.e no DMGR)
Change the class loader policy to "multiple".
I suppose I am not too late to reply to this question. The HttpServlet class can be found in the j2ee.jar. WAS does not bundle it in servlet-api.jar, the way Tomcat does it.
You need to bundle servlet-api.jar file in your application.

unable to redeploy web application on glassfish3

I m trying to deploy a web application using netbeans to glassfish 3.01 but i m not able to do so
Glassfish says
Inconsistent Module State
the web app has some jars and a ejb jar for a local ejb
Open the domain.xml file that you will find in this folder:
"your glassfish installation"/domains/"your domain"/config
In this file look for your application deployment configuration to manually remove it:
1) Remove the web-module tag
<applications>
...
<web-module availability-enabled="false" context-root="yourapplicatoinContext" ... />
...
</applications>
2) Also remove the application-ref to your application:
<server config-ref="server-config" lb-weight="100" name="server">
...
<application-ref ... ref="your application name" ... />
...
</server>
Just try this:
undeploy
stop Glassfish
start Glassfish
deploy
If you can't undeploy, try the other steps anyway. If you don't have any luck, you could try it this way:
stop Glassfish
edit domain.xml (probably in domains/domain1/config)- back it up first; remove all references to your app (probably under application / application-ref); just make sure it's still valid xml
start Glassfish
deploy
It should have solved it. If still no luck anyway, remove every file or directory related to your app, probably under domains/domain1/generated and domains/domain1/applications/....
You could always recreate a new domain, but above steps will solve your problem.
You could be in such a situation after stopping Glassfish middle in a deploiyment, for example.
The other answers are really extreme. There is no need to create a new domain or re-install if you cannot redeploy your web application during development.
If you app is very complex, then consider scripting any clean up needed in a Production environment. The below steps will keep you up and working in the short term.
To re-deploy a web app to a single domain on Glassfish 3.1, do the following:
Stop Glassfish from the command line.
Delete all the files in the following directories:
glassfish\domains\domain1\generated
glassfish\domains\domain1\applications
Start Glassfish from the command line.
Deploy your app via the Admin Tool or command line.
In Glassfish 5, I searched for my app name in the domain.xml and deleted all the tags mentioning it. There was one occurence in the beginning (<system-applications>) and one at the end at approx. line 460 (<applications>). Then redeploy worked!

Categories