How to remove cantFindType warning with aspectj agent? - aspectj

With aspectj agent, I receive
[Xlint:cantFindType]
[Loader#203d1d93] error can't determine whether missing type org.slf4j.Logger is an instance of java.net.InetAddress
when weaving type org.eclipse.jetty.util.log.Slf4jLog
when weaving classes
when weaving
How I can remove this warning ?
Thanks

Use a META-INF/aop.xml file with
<aspectj>
<!--<weaver options="-verbose ">-->
<weaver options="-warn:none -Xlint:ignore">
</weaver>
</aspectj>

Related

ArrayIndexOutOfBoundsException deploying to GlassFish 4.1.1 with no web.xml Jersey

I got this strange error deploying my Jersey server (with no web.xml) to GlassFish 4.1.1 using Maven glassfish plugin (in fact, I had switched my (Maven) build from embedded Grizzly to GlassFish, updating standard Jersey dependencies from compile to provided):
[ERROR] remote failure: Error occurred during deployment: Exception
while loading the app : java.lang.IllegalStateException:
ContainerBase.addChild: start: org.apache.catalina.LifecycleException:
org.apache.catalina.LifecycleException:
java.lang.ArrayIndexOutOfBoundsException: 0. Please see server.log for
more details
The deployment was successful when I didn't declare the #ApplicationPath in my ResourceConfig implementation. But then, I got a 404 error when trying to consume the service. According to Jersey documentation, the #ApplicationPath is needed for no web.xml deployment (Example 4.3).
The deployment error log is extracted below:
[2015-12-28T09:33:40.826+0800] [glassfish 4.1] [SEVERE] []
[javax.enterprise.web] [tid: _ThreadID=123
_ThreadName=admin-listener(6)] [timeMillis: 1451266420826] [levelValue: 1000] [[
WebModule[/BBQuay-Entertainment-1.0-SNAPSHOT]StandardWrapper.Throwable
java.lang.ArrayIndexOutOfBoundsException: 0 at
org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:505)
at
org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:182)
at
org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:348)
at
org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:345)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315) at
org.glassfish.jersey.internal.Errors.process(Errors.java:297) at
org.glassfish.jersey.internal.Errors.processWithException(Errors.java:255)
at
org.glassfish.jersey.server.ApplicationHandler.(ApplicationHandler.java:345)
at
org.glassfish.jersey.servlet.WebComponent.(WebComponent.java:390)
at
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)
at
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:362)
at javax.servlet.GenericServlet.init(GenericServlet.java:244) at
org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1583)
.....
It turned out to be a Maven configuration. Since I was testing with Grizzly before, when switching to GlassFish, I left the two dependencies jersey-weld2-se and jersey-cdi1x default Maven scope. The latter is fine but the first is provided by GlassFish container. Corrected as following helps solve the problem (though the deployment error was really not helpful..)
<dependency>
<groupId>org.glassfish.jersey.ext.cdi</groupId>
<artifactId>jersey-weld2-se</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.ext.cdi</groupId>
<artifactId>jersey-cdi1x</artifactId>
</dependency>
The following is sufficient on Glassfish 4.1.1 (without web.xml):
import javax.ws.rs.ApplicationPath;
import org.glassfish.jersey.server.ResourceConfig;
#ApplicationPath("rest")
public class ApplicationConfig extends ResourceConfig {
}
And an example class:
import javax.ws.rs.GET;
import javax.ws.rs.Path;
#Path("info")
public class InfoStub {
#GET
public String getInfo() {
return "hello sir";
}
}
You can access it under http://localhost:8080/YOUR_PROJECT_NAME/rest/info
Make sure that you set your standard Jersey dependencies in your pom.xml to provided.

Importing External JAR to Websphere Liberty? [NoClassDefFoundError]

I want to use this JSON parser in my JAX-RS application that runs on Websphere Liberty.
I have done the following:
1) Right-click on Project -> Properties -> Java Build Path -> Add External Jar -> C:\javalib\quick-json.jar
2) Added C:\javalib to enviroment variable CLASSPATH
3) Added fileset xml to serverl.xml
<library id="ExternalLibs">
<fileset dir="C:\javalib" includes="*.jar"/>
</library>
4) Unchecked 'Enable project specific settings' in 'Java Compiler'
5) Cleaned the Project
[EDIT]
I was initially creating a new instance and then I turned it into an #ApplicationScoped bean and injected it. Now I get this error:
The JNDI lookup failed for JNDI name java:module/ConsoleREST with the following Exception CNTR4007E: An error occurred creating the websphere.jaxrs.service.ConsoleREST interface for the ConsoleREST enterprise bean in the WebApiConsole.war module in the WebApiConsole application. The enterprise bean look up failed using the java:module/ConsoleREST JNDI name. Exception: com/json/parsers/JsonParserFactory.
CNTR4007E: An error occurred creating the websphere.jaxrs.service.ConsoleREST interface for the ConsoleREST enterprise bean in the WebApiConsole.war module in the WebApiConsole application. The enterprise bean look up failed using the java:module/ConsoleREST JNDI name. Exception: com/json/parsers/JsonParserFactory
The first step was enough to get it to compile. Now I'm getting what I learned to be a runtime error. I would appreciate help!
You also need a <classloader> element in your application definition in the server.xml, which references the shared library. For example,
<application id="myapp" name="My App" type="war" location="somewhere.war">
<classloader commonLibraryRef="ExternalLibs" />
</application>
Alternatively, if your application is the only user of the library, you could package it in the WEB-INF/lib folder of your war. (Putting it in WebContent/lib in Eclipse should accomplish this.)

Jboss as7 to WildFly migration weld unsatisfied dependencies for type

I'm trying to migrate a jboss as 7 application to WildFly.
For some reason I am getting the weld unsatisfied dependencies for type Set.
For just about every class that uses the #Inject (Using guice).
I can not think of any way for solving this and have been stuck for several hours now.
Exception 0:
org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type 'classNameHere' with qualifires #Default
at injection point [BackedAnnotatedField] #Inject cant.tell.du.services.data.syly.nbp.syll.gkfsn
at cant.tell.du.services.data.syly.nbp.syll.gkfsn(syll.java:0)
at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProbloms(Validator.java:368)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:289)
at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:135)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:166)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:514)
Ok, now I got the point that you are using guice instead of cdi.
You could try to exclude the weld subsystem from your deployment like so:
<exclude-subsystems>
<subsystem name="weld" />
</exclude-subsystems>
This should disable CDI for your deployment and you should not run into the same problems anymore.

ClassNotFoundException while dynamic class loading in JBoss 7.1.1 from OSGi-bundle

I deployed a simple OSGi test-bundle into JBoss 7.1.1 and try to dynamically instantiate the Jacorb ORB by doing
Class clazz = Class.forName("org.jacorb.orb.ORB");
All I got is
java.lang.ClassNotFoundException: org.jacorb.orb.ORB from [Module "deployment.test:1.0.0" from Service Module Loader]
What I already did:
in the JBoss configuration standalone.xml I added for the osgi-subsystem the capability <capability name="org.jacorb" startlevel="1"/>, so that the org.jacorb module is loaded. That already solved the problem, that the installation of my test bundle fails.
I declared the Dependencies-Descriptor on org.jacorb in my MANIFEST.MF (also tried with and without the export option): Dependencies: org.jacorb export
I added the jboss-deployment-structure.xml to my META-INF with the following content
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.jacorb" />
</dependencies>
</deployment>
</jboss-deployment-structure>
Also I did experiments with the ClassLoaders and realized, that the ContextClassLoader is null. But in the end, I cannot effect this as the non-test-code, because the Class.forName() cannot be changed to use a specific classloader.
So why do I get this ClassNotFoundException?
Thanks in advance
Alex
After hours of digging I did the puzzle ;-)
In standalone.xml/domain.xml JBoss configuration I added <capability name="org.jacorb" startlevel="1"/> in the <subsystem xmlns="urn:jboss:domain:osgi:1.2" activation="lazy"> section under <capabilities>
In the META-INF/MANIFEST.MF I added DynamicImport-Package: org.jacorb.orb to allow the classloader to dynamically extend the classpath during runtime
Set the context classloader by Thread.currentThread().setContextClassLoader(getClass().getClassLoader() that has been null before
If you have a normal OSGi bundle and it should see the org.jacorb.orb.ORB class,
then you should have:
1. ALL org.jacorb packages and subpackages have to be exported in the osgi framework.
2. Your bundle has to import ALL of the packages you use - e.g. with
"Import-Package:org.jacorb.orb"
Check that the versions are compatible.
Check that you import all packages and subpackages. Import of org.jacorb doesn't imply org.jacorb.orb.
If both conditions are satisfied, then the Bundle Classloader of your bundle should be able to see org.jacorb.orb.ORB.

How do you use JPA objects with GWT in a different project?

I'm new to GWT, and I'm setting up a project to hold the UI portion of a complicated application. The JPA data objects are defined in a separate project using MyBatis generated POJOs. Once I manually modify the JPA objects to include 'implements Serializable' (this is a separate problem I need to solve), the gwtc step in the build process can't continue because it needs the source code for the JPA object, but can't find them.
I've created the 'core' project's jar files so that it includes the source .java files, but this didn't work. I've tried adding a classpath element to the gwtc ant java call.
How can I make my UI project compile while keeping the JPA objects defined in a separate project?
Errors:
Buildfile: /Users/user/source/user_interface/build.xml
libs:
javac:
gwtc:
[java] Compiling module org.mysite.ui
[java] Validating newly compiled units
[java] [ERROR] Errors in 'file:/Users/user/source/user_interface/src/org/mysite/ui/client/MyService.java'
[java] [ERROR] Line 21: No source code is available for type org.mysite.core.model.Person; did you forget to inherit a required module?
[java] [ERROR] Errors in 'file:/Users/user/source/user_interface/src/org/mysite/ui/client/MyServiceAsync.java'
[java] [ERROR] Line 19: No source code is available for type org.mysite.core.model.Person; did you forget to inherit a required module?
[java] [ERROR] Errors in 'file:/Users/user/source/user_interface/src/org/mysite/ui/client/presenter/MainTabPresenter.java'
[java] [ERROR] Line 75: No source code is available for type org.mysite.core.model.Person; did you forget to inherit a required module?
[java] Scanning for additional dependencies: file:/Users/user/source/user_interface/src/org/mysite/ui/client/MyApp.java
[java] Computing all possible rebind results for 'org.mysite.ui.client.MyService'
[java] Rebinding org.mysite.ui.client.MyService
[java] Checking rule <generate-with class='com.google.gwt.user.rebind.ui.ImageBundleGenerator'/>
[java] [ERROR] Unable to find type 'org.mysite.ui.client.MyService'
[java] [ERROR] Hint: Previous compiler errors may have made this type unavailable
[java] [ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly
[java] [ERROR] Errors in 'file:/Users/user/source/user_interface/src/org/mysite/ui/client/MyApp.java'
[java] [ERROR] Line 23: Failed to resolve 'org.mysite.ui.client.MyService' via deferred binding
[java] [ERROR] Cannot proceed due to previous errors
BUILD FAILED
/Users/user/source/user_interface/build.xml:39: Java returned: 1
Total time: 26 seconds
Ant gwtc target:
<target name="gwtc" depends="javac" description="GWT compile to JavaScript (production mode)">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
<classpath>
<pathelement location="src"/>
<pathelement location="../core/src"/>
<path refid="project.class.path"/>
</classpath>
<!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->
<jvmarg value="-Xmx256M"/>
<arg line="-war"/>
<arg value="web"/>
<!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
<arg line="${gwt.args}"/>
<arg value="org.mysite.ui.MyApp"/>
</java>
</target>
GWT has always had this problem.
The approach I have taken in the past is to make a .gwt.xml module in the other JAR including the JPA POJOs and putting the JPA annotation classes in an "emul" javax.persistence folder. This won't work w/ many providers that use lazy fetching of course, so Gilead (as mentioned in another answer here) will be needed.
Another way is to make copies of the JPA objects and just Dozer them before sending across RPC
Luckily, GWT 2.1 has solved this problem. Use Entity proxies and request factories. It works well.
Either use the new GWT 2.1 RequestFactory / EntityProxy approach, or
Better, ditch the JPA and use Objectify or Twig.
We use Objectify, because JPA is not a good fit for Datastore. JPA was created with SQL-based relational databases in mind, while GAE Datastore is an entirely different thing.
Google ported JPA layer to Datastore to lure in developers, pretending that Datastore is just a plain old SQL relational database. This later blows up in their faces once projects grow big.
You really need to understand the Datastore tradeoffs if you want to use AppEngine. JPA is not making you a favor here.
Your best bet if you want to serialize POJOs to GWT is to use Gilead http://noon.gilead.free.fr/gilead/
All you have to do on your POJO is extend LightEntity and implement Serializable
The tutorial is pretty straight forward in how to set up the RPC.